0
$\begingroup$

Rosanswers logo

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.


Originally posted by yangyangcv on ROS Answers with karma: 741 on 2012-10-25

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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?


Originally posted by David Lu with karma: 10932 on 2012-10-25

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by yangyangcv on 2012-10-25:
thanks man. other than convenient, no other reason :)

Comment by felix k on 2012-10-29:
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..

Comment by David Lu on 2012-11-08:
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

Comment by David Lu on 2012-11-08:
I'll eventually get around to pushing it to the WG repo.

$\endgroup$

Your Answer

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