How can I get it to stay where it transformed to?
I haven't checked, but is the link you're broadcasting the transform for part of your URDF? If it is, both the robot_state_publisher
and your own script will be broadcasting transforms for it, leading to the behaviour you describe.
Edit:
Yes, it is part of the URDF
Ok. That would make robot_state_publisher
broadcast transforms for it.
and I removed the robot_state_publisher
node from the launch file and initialized the positions of both links directly in the python file. Is this common practice, or is there a more standard way? I ask because although I could now represent the rotations of the links using quaternions, the model is no longer listening to joint_state_publisher
.
re: common practice: I'm not sure what you're asking exactly.
A TF frame can have multiple broadcasters, but if those broadcasters do not agree on what the transform should be, the frame will appear to "jump" between different locations, as you experienced.
This makes sense to me: there are essentially multiple "oracles" trying to convince us that frame X is at location Y and location Z and location W. In most cases, this is impossible, and it also leads to visualisation strangeness, as the frame is jumping between these locations.
By having the link in the URDF, robot_state_publisher
will assume it is responsible for publishing the transforms related to the link
. If you then start broadcasting the same transform(s), problems occur.
I could now represent the rotations of the links using quaternions, the model is no longer listening to joint_state_publisher
.
And this makes sense: robot_state_publisher
listens to the joint_states
topic to receive input for its forward-kinematics (FK). That FK is used to broadcast the transforms for the links in the URDF.
You've removed the links from the URDF -> robot_state_publisher
is not longer responsible, so doesn't listen for any joint states for the joints connected to those links -> no transforms -> no "response" when manipulating the sliders in the joint_state_publisher
.
Originally posted by gvdhoorn with karma: 86574 on 2019-12-17
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by Victoria Bentell on 2019-12-17:
Yes, it is part of the URDF, and I removed the robot_state_publisher
node from the launch file and initialized the positions of both links directly in the python file. Is this common practice, or is there a more standard way? I ask because although I could now represent the rotations of the links using quaternions, the model is no longer listening to joint_state_publisher
.
Comment by Victoria Bentell on 2019-12-17:
It seems to me like I have to choose between using robot_state_publisher
in my launch file (where I'm allowed to move the robot with joint_state_publisher
) and using a TransformBroadcaster
(where each link can move using quaternions, but can also detach and joint angles are lost). So as far as the "common practice" comment goes, when working with a single robot, is it best to control it with robot_state_publisher
or TransformBroadcaster
?
Comment by gvdhoorn on 2019-12-17:
You're presenting this as an either/or, but that's not the case.
It's possible to get both, but you'll have to make sure to parent your transforms to the ones robot_state_publisher
is publishing, listen to JointState
messages yourself and do FK. Then you could have both.
robot_state_publisher
does fairly simple FK. If you need something more complex, or you don't have JointState
messages but some other way to derive the transforms for your robot, you could use a broadcaster.
where I'm allowed to move the robot with joint_state_publisher
pedantic, but: you're not moving the robot. You're making joint_state_publisher
(RSP) publish different values for certain joints in its JointState
message, which is then picked up by robot_state_publisher
and via FK these changes are forwarded to the transforms. This is then used (by RViz for example) to update the 3D visualisation of a robot model. I feel this is important as RSP is not directly "moving the robot".