Rosanswers logo

Hi everybody, As stated in this post (see answer of Ahendrix) one should load the urdf model using the param tag in the launch file. This is exact what happens in this tutorial, where the author wrote in his launch file the following line of code:

<param name="robot_description" command="cat $(find r2d2)/model.xml" />

That’s ok, but taking a look into the tutorial above I cannot figure out how the robot_state_publisher receives informations about joints defined in the URDF file.

My guess: I suppose that the joint_state variable, defined in the tutorial as:

  20     sensor_msgs::JointState joint_state;
  29         joint_state.name[0] ="swivel";
  31         joint_state.name[1] ="tilt";
  33         joint_state.name[2] ="periscope";

identifies the joint by name (as defined also in the URDF file). I m right? One possibility is that names in the model correspond to the joint_state.name[k] in the broadcasted variable.

I can imagine that joint’names are loaded in the memory of the system by the launch command:

<param name="my_robot" command="cat $(find my_pkg_robot)/my_urdf_model.xml" />

and later recognised by the robot_state_publisher:

<node name="state_publisher" pkg=" my_pkg_robot " type="state_publisher" />

By doing that and publishing datas on joint_state I can move my robot. Is it like that, or I m wrong?

More: i really don t understand why he launched a second node with the command:

<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />

Why does he need 2 nodes? Was the first not enough to load the URDF model of the robot and to publish joint_state position every 1/30th seconds? Which is the relation between both nodes?

<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="state_publisher" pkg="r2d2" type="state_publisher" />

I think the tutorial is not clear, it doesn’t explain well enough how the package works, it just publishes an example. This is the most importa keypoint that should be understood in the tutorial.


Originally posted by Andromeda on ROS Answers with karma: 893 on 2014-08-15

Post score: 1


1 Answer 1


Rosanswers logo

The state publisher publishes joint state messages that specifies the positions (state) of the joints in the robot.

The robot state publisher subscribes to the joint state messages and uses that and the info in the URDF to publish transforms to all of the links.

Originally posted by David Lu with karma: 10932 on 2014-08-15

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by Andromeda on 2014-08-16:
Thankx David, But am I right about the concept that the urdf file is going to be parsed so the name of the joint must be the same as in the code?

Comment by David Lu on 2014-08-16:
Yes. That is correct.

Comment by Andromeda on 2014-08-25:
Sorry again David. But in this tutorial it explain that the /joint_states is going to be publish but later 2.1.1 it is under Subscribed Topics. Is the wiki page wrong?!!?

Comment by David Lu on 2014-08-25:
The robot_state_publisher subscribes to the joint_state messages, which is what that page and I said before.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.