Universal Robots Forum

Remote control of Robotiq Gripper connected to the UR5 via USB

Hello everyone,

Currently, we are trying to control the Robotiq Gripper which is connected via USB to a UR5 remotely using the Universal_Robots_ROS2_Driver but couldn’t manage to do so. Regarding this topic, we would appreciate some instructions.

Setup

PC OS: Ubuntu 20.4
ROS Distribution: Foxy
UR model: UR5

What we tried

Apart from using the ROS2 driver, we tried using the URX library. The approach of this library is to connect via a TCP socket on port 30002 and send a URScript that controls the gripper. This was successful. But if we run the ROS2 driver and send a trajectory to the UR5n and start controlling the gripper using the URX library, the driver loses connection. This gets printed in the consol where the driver runs:

[ros2_control_node-1] [INFO] [1638961383.669717614] [UR_Client_Library]: Connection to reverse interface dropped.

In order to make sure, there is nothing else happening in the URX library that distracts the ROS2 driver, we extracted a minimal example in python on how the gripper is controlled:

gripper_control.py

import socket
from time import sleep

HOST = “192.168.1.102”
SEC_PORT = 50002

i_sec = socket.create_connection((HOST, SEC_PORT), timeout=0.5)

with open(‘gripper_close.txt’) as f:
close_program = f.read()

i_sec.send(str.encode(close_program))

And this is the URScript that is loaded from ‘gripper_close.txt’ (the code between myProg and end should be indented):

gripper_close.txt

def myProg():
socket_close(“gripper_socket”)
socket_open(“127.0.0.1”,63352,“gripper_socket”)
set_analog_inputrange(0,0)
set_analog_inputrange(1,0)
set_analog_inputrange(2,0)
set_analog_inputrange(3,0)
set_analog_outputdomain(0,0)
set_analog_outputdomain(1,0)
set_tool_voltage(0)
set_runstate_outputs()
set_payload(0.85)
socket_set_var(“SPE”,255,“gripper_socket”)
sync()
socket_set_var(“FOR”,50,“gripper_socket”)
sync()
socket_set_var(“ACT”,1,“gripper_socket”)
sync()
socket_set_var(“GTO”,1,“gripper_socket”)
sync()
sleep(0.1)
socket_set_var(“POS”,255,“gripper_socket”)
sync()
sleep(2.0)
end

Still with this minimal version, the ROS2 driver loses connection, when we run this example when sending a trajectory through the ros interface.

We haven’t tried that yet but we are also thinking about forwarding the port of the grippe (63352), so we can access it remotely.

What we understand so far

There are different ports used for communicating with the UR:

50002 : primary interface, remote computer sends URScript to the UR that is interpreted by the URCap, 125Hz
50001 : UR requests the the remote computer to send URScript
30003 : UR sends the current status of the robot in real-time
30002 : secondary interface, remote computer sends URScript that contains commands that are not interfering with commands from the primary interface, 10Hz
54321 : port of the tool communication interface for a remote computer to use tools connected to the UR?, not available for the UR5 but for UR5e?

Is this interpretation correct? Is there anything else happening on these ports that is important for our problem?

We searched in the ROS2 driver repository for more clues on why using port 30002 from another program interferes with the ROS2 driver but we couldn’t find a clue. Maybe we missed something.

Ideally, we would like to use a controller with a topic where we can publish control messages for the Robotiq gripper.
Is this possible or are there any other workarounds to achieve remote control of the gripper?

We would much appreciate some tips and explanations.