Populating the SetJointVelocity Message


The SetJointVelocity message supports controlling both revolute and prismatic joints in the same message using the JSIDL variant type. The example below shows how to populate the SetJointVelocity message.


Example:  Populating the SetJointVelocity message with 2 revolute joints and 2 prismatic joints

manipulator_v2_0::SetJointVelocity* setJointVelocity = new manipulator_v2_0::SetJointVelocity();
manipulator_v2_0::JointVelocityList& jointVelocityList = setJointVelocity->getJointVelocityList();

// Joint 1 = Revolute Joint 1
manipulator_v2_0::JointVelocityRecord joint1Record;
manipulator_v2_0::JointVelocityVariant& joint1 = joint1Record.getJointVelocity();

joint1.setType(manipulator_v2_0::JointVelocityVariant::JOINTVELOCITYOPTION0);
joint1.setJointVelocityOption0_rps(0.1);

jointVelocityList.add(joint1Record);

// Joint 2 = Prismatic Joint 1
manipulator_v2_0::JointVelocityRecord joint2Record;
manipulator_v2_0::JointVelocityVariant& joint2 = joint2Record.getJointVelocity();

joint2.setType(manipulator_v2_0::JointVelocityVariant::JOINTVELOCITYOPTION1);
joint2.setJointVelocityOption1_mps(0.0);

jointVelocityList.add(joint2Record);

// Joint 3 = Revolute Joint 2
manipulator_v2_0::JointVelocityRecord joint3Record;
manipulator_v2_0::JointVelocityVariant joint3 = joint3Record.getJointVelocity();

joint3.setType(manipulator_v2_0::JointVelocityVariant::JOINTVELOCITYOPTION0);
joint3.setJointVelocityOption0_rps(0.0);

jointVelocityList.add(joint3Record);

// Joint 4 = Prismatic Joint 2
manipulator_v2_0::JointVelocityRecord joint4Record;
manipulator_v2_0::JointVelocityVariant& joint4 = joint4Record.getJointVelocity();

joint4.setType(manipulator_v2_0::JointVelocityVariant::JOINTVELOCITYOPTION1);
joint4.setJointVelocityOption1_mps(0.0);

jointVelocityList.add(joint4Record);


Additional Notes:

  • The number joints in the JointVelocityList must match the number of joints of the manipulator.
  • The joints must be added such that the first joint in the list corresponds to the joint closest the manipulator base, and the last joint in the list corresponds to the joint furthest from the manipulator base.