Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Order of published joints from joint_state_controller

Hello all. I am wondering if it is possible to control the order in which the joint_state_controller publishes the robot joints and their respective values?

I am simulating a UR5 manipulator in Gazebo, and if we look at a sample message taken from the published /joint_states topic, they seem to be ordered in alphabetical (?) order (FYI the elbow_joint and shoulder_pan_joints should be switched):

  seq: 685
    secs: 13
    nsecs: 722000000
  frame_id: ''
name: [elbow_joint, shoulder_lift_joint, shoulder_pan_joint, wrist_1_joint, wrist_2_joint, wrist_3_joint]
position: [-9.935968448004928e-07, -1.5675146858950169, -0.0005566812821147238, -1.567509637814898, -1.5170622604365747e-05, -1.739371527698097e-06]
velocity: [3.6741224523988668e-06, -5.112008493828534e-05, 0.001605313567856731, 3.934066966728182e-05, 5.4372582579940575e-05, 6.217080293624165e-06]
effort: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

Is there a simple solution to publishing these messages in the order in which they appear in the kinematic chain (i.e base_link --> .. --> tip_link).

I am currently manually sorting this data to the correct order when I read it into a node, but this is fairly inelegant (especially if i were to switch to a different robot which is for some reason publishing in the correct order).

I have used the controller_joint_names parameter in the past to do this in the industrial_robot_client, is there something similar method I can use for the joint_state_controller? (



First I load the relevant parameter .yaml files

 <!-- Load controller parameters -->
<rosparam file="$(find environment_config)/controller/controller_setup.yaml" command="load"/>

and then spawn my arm and joint_state_controllers from there

<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen"
args="arm_controller joint_state_controller"/>

contents of controller_setup.yaml

    type: joint_state_controller/JointStateController
    publish_rate: 50
# -------------------------------------------------------
  type: position_controllers/JointTrajectoryController
     - shoulder_pan_joint
     - shoulder_lift_joint
     - elbow_joint
     - wrist_1_joint
     - wrist_2_joint
     - wrist_3_joint
      goal_time: 0.6
      stopped_velocity_tolerance: 0.05
      shoulder_pan_joint: {trajectory: 0.1, goal: 0.1}
      shoulder_lift_joint: {trajectory: 0.1, goal: 0.1}
      elbow_joint: {trajectory: 0.1, goal: 0.1}
      wrist_1_joint: {trajectory: 0.1, goal: 0.1}
      wrist_2_joint: {trajectory: 0.1, goal: 0.1}
      wrist_3_joint: {trajectory: 0.1, goal: 0.1}
  stop_trajectory_duration: 0.5
  state_publish_rate:  25
  action_monitor_rate: 10