ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

why does joint state publisher publish joints in a messed order?

asked 2012-10-25 15:52:56 -0500

updated 2012-10-25 17:19:37 -0500

i use the following launch file to start a joint state publisher and robot state publisher for my robot:

<launch>
<arg name="gui" default="true" />
<param name="robot_description" textfile="$(find My_Robot)/My_Robot.urdf"/>
<param name="use_gui" value="$(arg gui)"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find My_Robot)/urdf.vcg" />
</launch>

it works well. then i write another node to subscribe to the joint states. once the node receive the joint states, it just print them out with the following code:

for(size_t i=0;i<jointStates.name.size();i++)
    std::cout<<i<<" , "<<jointStates.name[i]<<std::endl;

but the joint states are in a messed order. that is, my robot is an arm with 7 rotational joints: base_to_link1, link1_to_link2, link2_to_link3, so on and so forth. so i hope the printed message is :

0 , base_to_link1

1 , link1_to_link2

2 , link2_to_link3

but in fact, the printed message is :

0 , link1_to_link2

1 , base_to_link1

2 , link2_to_link3

but in the gui panel, all the joints are in the right order from top to bottom.

does anybody know why? thanks.

Edit:

it would be convenient if they are in correct order. e.g., i can use the following code to send these joint value to another node through UDP simply:

StringStream ss;
for(size_t i=0;i<joints.position.size();i++) 
   ss << joints.position[i] << ","
send(ss);

of course, i know there are other methods to send them in order. but i think it's better to have them in order.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2012-10-25 16:24:37 -0500

David Lu gravatar image

Short answer: The JointStatePublisher builds the message with a series of python dictionaries, which are not explicitly ordered. Other than convenience, is there a particular reason why you need them in a set order?

edit flag offensive delete link more

Comments

thanks man. other than convenient, no other reason :)

yangyangcv gravatar image yangyangcv  ( 2012-10-25 17:21:31 -0500 )edit

It would make it much easier to quickly debug joint states via rostopic echo. And I had to add sorting in the schunk_gui. Not that implying a physical order would give flawless reusability, though..

felix k gravatar image felix k  ( 2012-10-29 02:37:42 -0500 )edit

I've updated the wu_robotics version of joint_state_publisher here to print in order: https://wu-robotics.googlecode.com/svn/trunk/urdf_tools

David Lu gravatar image David Lu  ( 2012-11-08 08:22:46 -0500 )edit

I'll eventually get around to pushing it to the WG repo.

David Lu gravatar image David Lu  ( 2012-11-08 08:23:09 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2012-10-25 15:52:56 -0500

Seen: 1,842 times

Last updated: Oct 25 '12