1. Home
  2. Knowledge Base
  3. Pick and place using Robotiq electrical gripper

Pick and place using Robotiq electrical gripper


Application Description:

This article is an example of controlling Robotiq grippers on a Universal-Robots.

This example uses preinstalled Robotiq script files that makes it much easier to control the gripper position and gripper closing and opening force.

The Robotiq Script files can be downloaded from here.


Function description:

The electrical gripper is connected to the USB port on the Universal-Robots and is using a Widget provieded by Robotiq with predefined routines.

The USB data signal is converted to RS-485 by an external USD-RS-485 converter.

When the Robotiq files are installed the Robotiq widget show up as “Gripper” and when pressed the gripper control menu appear.


Press “On” symbol to on the gripper.


When the gripper is on it can be tested and manipulated with the controls.


I/O table Inputs:

I/O table Outputs:

When using the Robotiq UR kit then there prepared subroutines to open and close and set parameters.

Variable Table:

rq_move(0)       (Fully open gripper).
rq_move(255)  (Fully close gripper).

rq_force≔255   (Set force at Maximum).
rq_speed≔255 (Set speed at maximum).

Program description:

In the “BeforeStart” routine the predefined Robotiq routine is loaded.

Variables are initiated to set values, which are gripper force and gripper speed are set to 255 which is maximum setting.

In the Robot program the robot is moved into a start position and the routine to set the gripper speed is called following a command to fully open the gripper (position 0).

The the robot moves down to waypoint 2 which is a likely position for a object to pick up. When the robot have reached waypoint 2 the command to close the gripper with position 255 which is fully closed, but if there is an object the gripper will stop when an object has been detected.

If the gripper detect an object the the robot will move to waypoint 3. If the gripper does not detect an object then the gripper will move back to waypoint 1 and open the gripper and again try to go to waypoint 2.

If there is an object in the gripper the robot moves to waypoint 3 which is above the picking position and then the robot moves to waypoint 4 which is above the place position and move down to waypoint 5 which is the place position. At the place position the command to open the gripper is called and the gripper opens. Notice the wait commands which serves the function to allow the gripper to fully open and also close in order to have a good release and a good grip on the object.

When the object is released the robot moves back the path to pickup an new item and the cycle resumes,

Program code:



Contribute moderator

Disclaimer: While the Zacobria Pte. Ltd. believes that information and guidance provided is correct, parties must rely upon their skill and judgement when making use of them. Zacobria Pte. Ltd. assumes no liability for loss or damage caused by error or omission, whether such an error or omission is the result of negligence or any other cause. Where reference is made to legislation it is not to be considered as legal advice. Any and all such liability is disclaimed.

If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.

By Zacobria Lars Skovsgaard
Accredited 2015-2018 Universal Robots support Centre and Forum.

Also check out the CB3 forum

Was this article helpful?


  1. Hi Zacobria,

    I would like to ask you if you have any experience controlling RG2 gripper with python?
    I am using UR3 robot arm.
    I already tried to send RG2 gripper script given on the User manual from python with following code:

    import socket
    import time
    HOST = “” # I used my UR3 IP
    PORT = 30002 # The same port as used by the server
    #I tried also with 30003 port
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((HOST, PORT))
    s.send(“RG2(target_width=10, target_force=40, payload=0.0, set_payload=False, depth_compensation=False,slave=False)” + “\n”)

    s.send(“RG2(0,40,0.0,True,False,False)” + “\n”)

    I receive some numbers when I send this script to UR3 but gripper itself doesn’t open and close.

    If I send RG2(0,40,0.0,True,False,False) script from teach pendant it works but with python code I am not able to control the gripper.

    I would really appreciate if you have any suggestions or ideas to control RG2 gripper with python.

    Best regards,


    1. Hi Khurshid

      Thanks for the question.

      I have not tried to use the RG2 OnRobot gripper.

      By Zacobria Lars Skovsgaard
      Accredited Universal Robots support Centre and Forum.

      Also check out the CB3 forum

    2. Hi Khurshid,

      I have the same problem with you. I cannot control the open and close actions by sending the scripts. So have you solved this problem now?

      Best regards,

    1. Hi alib

      Thanks for the question.

      I have seen that before and then it was because the old format of programming template was used on a robot where the newer URCaps method of programming the gripper.

      At that time I made a backup of the program – and then consider to surpress the entries in the old program method that causes the double defined messages – such as get serial number etc. Once they were surpressed the program could run.

      Otherwise it can be considered to create a new program from scratch.

      By Zacobria Lars Skovsgaard
      Accredited Universal Robots support Centre and Forum.

      Also check out the CB3 forum

  2. Hi

    i working on a solution that will pre work before manual assembly, it all about place screws in the rightplace on both side of an object.

    i use the palett wizards and an electric gripper.

    how shall i structre the code so it will place all the screws on one side of the object first before it starts with the second side.

    as it is now it take every two side, and it create a lot of unnecessery movments. please advice

  3. Hello,
    Yes, it should be possible in this way but in our setup they are placed far away from each other. If there is no other option, we will do that. But is it not possible to do it the way I asked in my previous comment? Also, do you have an example of MODBUS RTU implementation in C++? Python is good for making initial tests but in the end, I have to implement everything in C++.

    1. Hello Shivesh

      I went back to look at your questions – is it this question you mean

      “Is there a way to send some string based commands(using C/C++ or Python) to the UR10 controller box from my control PC which will control the gripper?”

      Is it the PC and robot (with gripper) that is far away from each other ?

      Are you sending commands from the PC to the robot via Ethernet ?

      As you mentioned earlier that you are not using Polyscope to send commands from the robot – so I am not aware on how you can send commands to the gripper from the robot then.

      There is a separate control box for the Robotiq grippers called “UNI-CTR-001-MTCP External Controller for 2F Grippers – Modbus TCP” so the gripper can have an IP address. Then it is possible to control the gripper with MODBUS TCP commands over the Ethernet. Notice that MODBUS TCP commands are different compared to MODBUS RTU !

      Some information on the MODBUS TCP commands for Robotiq 2F at this link


      I have not used C++ programming so I dont have any examples using C/C++.

      By Zacobria Lars Skovsgaard
      Accredited Universal Robots support Centre and Forum.

      Also check out the CB3 forum

      1. Hello,
        Sorry if I was not clear. I will try to explain our present setup. We communicate with UR10 robot via Ethernet from our Industrial PC using UR C driver(https://github.com/ThomasTimm/ur_modern_driver). I have modified the driver to make it work independently of ROS. So basically you can send servoj commands from C driver to the UR10 robot and it works very well. We bought the Robotiq gripper and connected it to the UR10 controller box and installed the robotiq drivers provided on their blog on the Polyscope. So, I am able to control the gripper with the Polyscope interface. But in our application, we would like to control it from C++ library on the Industrial PC. I tried sending string based commands like “rq_open()” from our Industrial PC to the UR10 controller over Ethernet thinking something like this might work because UR10 controller now understands these commands because of the gripper installation. But it does not work because if you look at the basic templates which have been provided with gripper installation, they start another communication between the UR10 controller box and the gripper on a different IP address and PORT. So, my question is: Is it possible to send commands like “rq_open()” from Industrial PC over Ethernet to the UR10 controller box which is further connected with the gripper to make the gripper work?
        If it is not possible, then the solution should be to connect the gripper to our Industrial PC taking power supply either from UR10 controller box or externally and then use serial communication from C++ (like you do with Python). Maybe buying an extra Modbus TCP control box is unnecessary.

        1. Hello Shivesh

          The “rq_open()” command is using routines which are part of the Robotiq drivers used from Polyscope and therefore need to be used from Polyscope.

          When you mention “…………the UR10 controller box and the gripper on a different IP address and PORT”.

          Does the 2F gripper have an IP address ? or is it connected to the USB port on the Robot ? or Do you have the UNI-Controller-MTCP allready ?

          You only need one UNI-Controller-MTCP to control the 2F gripper over the Ethernet.

          Yes you can also consider to have a very small and basic controller or PC near the gripper with a serial port or USB port that connects to the gripper – and then send commands to this controller/PC from the Industrial PC which are far away.

          By Zacobria Lars Skovsgaard
          Accredited Universal Robots support Centre and Forum.

          Also check out the CB3 forum

  4. Hello,
    I am interested in controlling the 2 finger robotiq gripper mounted on UR10 robot using C++ or Python. I am able to control the gripper using the basic and advanced templates which come with the gripper installation but in our application, we must be able to control it without using the Polyscope. I see that there is some ROS support on their website but we also don’t want to depend on it. Is there a way to control the gripper using C/C++ or Python?
    Any help would be greatly appreciated.
    Best Regards,

      1. Hello Zacobria,
        Thanks for the link. As I understand, in this case, the gripper must be connected to the control PC. Presently, my gripper is connected to the UR10 controller box because it is easy to get the 24V power supply. Is there a way to send some string based commands(using C/C++ or Python) to the UR10 controller box from my control PC which will control the gripper?

Leave a Reply

Your email address will not be published. Required fields are marked *