# joint_states topic name field sorted alphabetically

I'm using joint_state_controller to publish the joint_states topics. My robot is composed by a crane and an arm. The origin of the chain is the crane_bridge_joint and joint_states topic is:

name: [ 'arm_1_joint', 'arm_2_joint', 'arm_3_joint', 'arm_4_joint', 'arm_5_joint', 'arm_6_joint', 'crane_bridge_joint', 'crane_arm_joint']
position: [0.03484964823276627, 3.1446214877979326, 0.11884834747659312, 0.056190650599306835, -0.9346745113914041, 3.128057174527214, 3.290371433787131, -0.0005012796984654981]


However if I change the names of the joints the topic look like this:

name: ['crane_bridge_joint', 'crane_hercules_joint', 'hercules_1_joint', 'hercules_2_joint', 'hercules_3_joint', 'hercules_4_joint', 'hercules_5_joint', 'hercules_6_joint']
position: [3.290371433787131, -0.0005012796984654981, 0.03484964823276627, 3.1446214877979326, 0.11884834747659312, 0.056190650599306835, -0.9346745113914041, 3.128057174527214]


I thought that the the publication of the joint_state was based on the robot joints chain (the first joint the base_link and the last one, the tip_link) but I have realized that the joints are sorted alphabetically. Is there any way to avoid this order?

Ane

edit retag close merge delete

Afaict there is no code in the joint_state_controller that sorts joint names that way (or in any way, really). It should just use whatever order it receives. Can you verify and possibly post some example JointState messages?
Also, the order should be irrelevant as long as name[0] corresponds to position[0] and so forth. May I ask what you are trying to achieve and why this matters?