Note: The procedure is similar for controlling a Robotiq 3-Finger Gripper using the "robotiq_3f_gripper_control" package.
(!) Please ask about problems and questions regarding this tutorial on Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Control of a 2-Finger Gripper using the Modbus RTU protocol (ros kinetic and newer releases)

Description: This tutorial explains how to use the "robotiq_2f_gripper_control" and "robotiq_modbus_tcp" packages to control an 2-Finger Gripper configured with the Modbus RTU protocol. Please visit this website for more information on the Robotiq Adaptive Robot Grippers.

Tutorial Level:


This tutorial assumes that you have connected a 2-Finger Gripper via the serial connection with a serial to USB converter to a USB port of your computer.

For connecting the gripper via the TCP protocol, see the tutorial on Control of a 3-Finger Gripper using the Modbus TCP Protocol.

To test your gripper and the serial interface you can try the windows driver as explained in the Robotiq software installation page.

It is assumed you have the robotiq_2f_gripper_control package and the robotiq_modbus_rtu package installed for your ROS distribution (see the [[ || robotiq packages on ROS-I github).

Finally, make sure that the external dependency for the package "robotiq_modbus_tcp" has been installed. The dependency is the python package pyModbus. On Ubuntu Precise, it is simply installed using "rosdep install robotiq_modbus_tcp". On other systems, it can be installed using "easy_install -U pymodbus".

Configuring the serial port

To control the gripper over a serial port, you may need to give proper privileges to the user:

$ usermod -a -G dialout YOURUSERNAME

To find out the port on which the controller is connected, use:

dmesg | grep tty

It's probably something like ttyUSB0.

ROS Nodes to Control the Gripper

Run the 2-Finger Gripper Driver Node

The gripper is driven by the node "" contained in the package "robotiq_2f_gripper_control". Note that "roscore" should be running prior to launching the driver node. The gripper device ID will also need to be provided as an argument. Thus, to know what is the device ID of your 2-finger gripper, one way is simply by typing "dmesg | grep ttyUSB" in a terminal right after the gripper was connected to the computer's USB port.

For example, the driver for controlling a 2-finger gripper having "ttyUSB0" as its device ID is launched using the following command:

rosrun robotiq_2f_gripper_control /dev/ttyUSB0

Run the 2-Finger Gripper Simple Controller Node

The driver listens for messages on "Robotiq2FGripperRobotOutput" using the "Robotiq2FGripper_robot_output" msg type. The messages are interpreted and commands are sent to the gripper accordingly. A simple controller node is provided which can be run (in another terminal) using "rosrun robotiq_2f_gripper_control"


The "Robotiq2FGripper_robot_output" msg type is simply composed of the robot output variables described in the Robotiq 2-Finger Gripper Instruction Manual. The simple controller node can therefore be modified to send custom commands to the Gripper.

Run the 2-Finger Gripper Status Listener Node

In the package "robotiq_2f_gripper_control", there is also a node for listening to and interpreting the status of the Gripper. The driver publishes the status of the Gripper on "Robotiq2FGripperRobotInput" using the "Robotiq2FGripper_robot_input" msg type. The msg type is composed of the robot input variables described in the Robotiq 2-Finger Gripper Instruction Manual. The status listener node can be run (in another terminal) using the following command: "rosrun robotiq_2f_gripper_control".


Wiki: robotiq/Tutorials/Control of a 2-Finger Gripper using the Modbus RTU protocol (ros kinetic and newer releases) (last edited 2018-11-04 01:10:05 by Jean-Philippe Roberge)