I am using a UR3 Robot with OnRobot RG2 Gripper. I have successfully connected the robot to my computer via Ethernet and i am able to send move commands and receive data successfully with Python. But the commands for RG2 Gripper provided in the manual are not working. I can send commands to the gripper via teaching pendant (by command RG2) but not through my computer via Ethernet. Has anyone had a solution to this problem ? Thanks in advance.


2 Answers 2


I had the discussion with Robotiq about the same thing for their grippers when I started working with them, and as I understand it, the UR Caps commands are not installed as commands in the robot, but they are instead defined in each new program. If you read the .script files for a program created with a UR Caps command, the commands used will be defined before the robot program itself. I have yet to try it myself, but possibly you could define these functions yourself first and then send it?

But, for Robotiq there are more options available. For OnRobot I don't know.

Addition: I did some tests on the VM simulator, I just started a .script file from a program I previously did. Works like a charm. So for open and close scripts of the OnRobot, I guess it is fine.

    import socket
    import time
    HOST = ""    # The remote host
    PORT = 30002              # The same port as used by the server
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((HOST, PORT))
    print("Starting Program")
    f=open("/home/ur/Desktop/TestScript.script", "r")
    s.send (f.read() + "/n")
    data = s.recv(1024)
    print ("Closed connection and received data")

Also got interested in how to send a value without having to open the script, like a width. I'm quite new to Python, but an example, adding all this instead of the f.open above:

    width = 11 # 11 just and example, user input or something works as well..
    with open("/home/ur/Desktop/TestScript.script", "r") as in_file:
        buf = in_file.readlines()
    with open("/home/ur/Desktop/TestScriptOut.script", "w+") as out_file:
        for line in buf:
            if i == 0: # Notice that this will add var_1 in the second line
                line = line + "  global var_1 = %s\n" % width
    f = open("/home/ur/Desktop/TestScriptOut.script", "r")

Here use this library I developed to communicate with onRobot grippers with the Universal Robots (robots) through the standard m8 tool connector.

[email protected]:RyanPaulMcKenna/onRobot.git


Can pip install like so:

pip install onRobot

and use like so:

import onRobot.gripper as gripper

# Default id is zero, if you have multiple grippers, 
# see logs in UR Teach Pendant to know which is which :)
rg_id = 0
rg_gripper = gripper.RG2(rg_id)

rg_width = rg_gripper.get_rg_width()
pregrasp_width = 100

# force and width units described in onRobot RG2 Manual
target_width = 15.66
target_force = 40.00

if (rg_wdith == pregrasp_width):
    rg_gripper.rg_grip(target_width, target_force)

epsilon = 0.05 # Just an example of reasonable error may not be realistic. 
grip_success = abs(rg_gripper.get_rg_width() - target_width) < epsilon


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.