why does joint state publisher publish joints in a messed order?
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.