Gripper control on ros2

Hello,

I wanted to know how turn on the arm gripper and command it to open and close on ros2.

Thanks

Hello!

You can turn on the gripper by publishing a message to the /dynamic_joint_commands topic, using the torque interface value:

ros2 topic pub --once /dynamic_joint_commands control_msgs/msg/DynamicJointState \
"{joint_names: [l_hand], interface_values: [{interface_names: [torque], values: [1.0]}]}"

Set joint_names to:

  • l_hand for the left gripper
  • r_hand for the right gripper

Set the torque value to:

  • 1.0 to turn on
  • 0.0 to turn off

You can use a single command to turn them both on:

ros2 topic pub --once /dynamic_joint_commands control_msgs/msg/DynamicJointState \
"{joint_names: [l_hand, r_hand], interface_values: [{interface_names: [torque], values: [1.0]}, {interface_names: [torque], values: [1.0]}]}"

Opening and closing the gripper works similarly, but you must use the position interface instead of torque. Note that the joints names are slightly different in this case:

  • l_hand_finger
  • r_hand_finger

For example, to open the right gripper:

ros2 topic pub --once /dynamic_joint_commands control_msgs/msg/DynamicJointState \
"{joint_names: [r_hand_finger], interface_values: [{interface_names: [position], values: [1.0]}]}"

Set the value to:

  • 1.0 to open the gripper
  • 0.0 to close it

You can retrieve the ROS calls made by the Python SDK functions by inspecting the reachy2_sdk_server!