How to control the Gripper via socket communication?

How to Control the Robotiq Gripper Remotely Using Python

To control the Robotiq Gripper remotely through port 30002 on a Universal Robots (UR) controller, you can send native UR commands like moveL or servoJ directly. However, commands implemented by a URCap, such as the Robotiq Gripper functions, are not natively recognized by the controller—even if the URCap is installed.

Why URCap Commands Are Not Recognized Remotely

When you write a program on the teach pendant, all URCap functions are defined and included in the program during compilation. These definitions are executed by the UR controller at runtime. However, when sending commands like rq_move_and_wait(58) directly from an external source (e.g., port 30003), the controller will not recognize them unless the corresponding function definitions are also provided.

Solution: Sending Function Definitions Along with Commands

To use gripper functions remotely, you need to send the definitions of those functions along with the commands. This ensures the controller can interpret and execute the commands.

For example:

  • A Python script can send a file containing the required function definitions (gripper.script) to the UR controller.
  • The gripper.script file includes approximately 650 lines of definitions that enable basic gripper actions such as activation and movement.
  • At the end of the gripper.script file, the desired gripper commands (e.g., activate or move commands) are included and executed.

Python Example and Script File

We’ve provided a Python example program and the gripper.script file to help you get started. These files include:

  • A Python script to send the gripper.script file to the controller.
  • The gripper.script file containing all necessary function definitions for the Robotiq Gripper.

You can download the files here: Python

Example and Script File

If you encounter any issues or have additional questions, feel free to contact our support team for assistance.