# How to use python to control robotiq gripper?

**URL:** <https://forum.universal-robots.com/t/how-to-use-python-to-control-robotiq-gripper/36119>\
**Category:** Technical Questions\
**Created:** [September 19, 2024, 2:13pm UTC](https://forum.universal-robots.com/t/how-to-use-python-to-control-robotiq-gripper/36119 "2024-09-19T14:13:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samuel\_DN](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@Samuel\_DN](https://forum.universal-robots.com/u/Samuel_DN)\
**Post date:** [September 19, 2024, 2:13pm UTC](https://forum.universal-robots.com/t/how-to-use-python-to-control-robotiq-gripper/36119/1 "2024-09-19T14:13:22Z")

</div>

hi, I have a UR 10 and robotiq 2f-85 gripper.  
I followed the tutorial of ’ Send URScript to Controller with TCP/IP’ ([Use the Primary, Secondary, and Realtime Interface to send URScript commands — PolyScope 5 Tutorials documentation](https://docs.universal-robots.com/tutorials/urscript-tutorials/socket-communication.html)) to use python to control the robot.  
s.sendall(b"movej(p[0.3219, -0.13942, 0.62208, 2.22144, 2.22144, 0], a=3.1416, v=0.3)" + b"\n") # it works  
But in the meantime, I want to control the gripper by the method, it doesn’t work.  
s.sendall(b"rq\_close()" + b"\n") #it doesn’t work  
So I want to ask how to use python to control robotiq 2f-85 gripper?  
I have no more experience about the robot. I really appreciate it if you can give me some guidances or example files. Thank you very much.

---

<div class="post-metadata">

**Author:** ![juan.rubio](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@juan.rubio](https://forum.universal-robots.com/u/juan.rubio)\
**Post date:** [November 8, 2024, 1:10pm UTC](https://forum.universal-robots.com/t/how-to-use-python-to-control-robotiq-gripper/36119/2 "2024-11-08T13:10:29Z")

</div>

Hello

I control the robotiq 2F gripper with python through the USB port of the PC, which is where I connect the gripper.  
The library I use is the one in the following code:

#from pyRobotiqGripper import RobotiqGripper as gripper

import pyRobotiqGripper

import time

gripper = pyRobotiqGripper.RobotiqGripper()

gripper.activate()

time.sleep (0.2)

gripper.close()

time.sleep (0.25)

gripper.open()

time.sleep (0.22)

gripper.goTo(150)

time.sleep (0.2)

gripper.goTo(100)

time.sleep (0.2)

gripper.goTo(50)

position\_in\_bit = gripper.getPosition()

print(position\_in\_bit)

gripper.printInfo()
