# Controlling robot gripper Rg2 with Python

**URL:** <https://forum.universal-robots.com/t/controlling-robot-gripper-rg2-with-python/34450>\
**Category:** Technical Questions\
**Created:** [May 28, 2024, 10:03am UTC](https://forum.universal-robots.com/t/controlling-robot-gripper-rg2-with-python/34450 "2024-05-28T10:03:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hedieh.sigaroudi](https://avatars.discourse-cdn.com/v4/letter/h/f19dbf/32.png) [@hedieh.sigaroudi](https://forum.universal-robots.com/u/hedieh.sigaroudi)\
**Post date:** [May 28, 2024, 10:03am UTC](https://forum.universal-robots.com/t/controlling-robot-gripper-rg2-with-python/34450/1 "2024-05-28T10:03:41Z")

</div>

Hello everyone,

I am currently working on a project involving two Universal Robots (UR3 and UR5). I am faceing difficulties controlling the GR2 gripper (Onrobot) using Python. Despite attempting various libraries such as Robotiq and URX, I have not observed any response from the gripper.

I am using ethernet cable as connection between PC and robots.

My objective is to achieve basic functionality: simply opening and closing the gripper.

I would greatly appreciate any insights or advice on how to control the RG2 gripper with Python.

Thank you in advance for your assistance.  
Hedieh

---

<div class="post-metadata">

**Author:** ![robin\_gdwl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/robin_gdwl/32/2676_2.png) [@robin\_gdwl](https://forum.universal-robots.com/u/robin_gdwl)\
**Post date:** [May 28, 2024, 10:14pm UTC](https://forum.universal-robots.com/t/controlling-robot-gripper-rg2-with-python/34450/2 "2024-05-28T22:14:48Z")

</div>

> [@I want to work onrobot rg2 gripper in python](https://forum.universal-robots.com/t/i-want-to-work-onrobot-rg2-gripper-in-python/27332):
>
> I succeeded in moving the robot using the urx library, but the operation of the gripper failed. Currently, I am using an onrobot rg2 gripper, and I tried to operate it with the onrobot rg2 gripper api below, but it did not work. The operating system is Windows and I want to run the gripper with Python. I’ll be waiting for your help. Below is my code. ㅇ onrobot rg2 gripper API ([Support for OnRobot RG2 Gripper by Mofeywalker · Pull Request #45 · SintefManufacturing/python-urx · GitHub](https://github.com/SintefManufacturing/python-urx/pull/45/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5)) impo…

---

<div class="post-metadata">

**Author:** ![tyshkevichpavel](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@tyshkevichpavel](https://forum.universal-robots.com/u/tyshkevichpavel)\
**Post date:** [May 29, 2024, 4:01am UTC](https://forum.universal-robots.com/t/controlling-robot-gripper-rg2-with-python/34450/3 "2024-05-29T04:01:48Z")

</div>

Try to use URScript Commands ( see: 6.3.1)

[User\_Manual\_For\_UR\_Robots\_HEX-E\_H\_QC\_RG2\_v1.16.0\_EN.pdf](https://forum.universal-robots.com/uploads/short-url/tdesBNPSk6xD5hF37uGdWKyGbBg.pdf) (6.7 MB)

---

<div class="post-metadata">

**Author:** ![fvr510](https://avatars.discourse-cdn.com/v4/letter/f/6a8cbe/32.png) [@fvr510](https://forum.universal-robots.com/u/fvr510)\
**Post date:** [May 31, 2024, 9:01pm UTC](https://forum.universal-robots.com/t/controlling-robot-gripper-rg2-with-python/34450/4 "2024-05-31T21:01:24Z")

</div>

I made a simple library that you can use for this that does not require onRobot’s compute box which many sources fail to mention including the onrobot documentation.

I am regularly extending its functionality to cover more onRobot grippers, if you need support for a specific gripper submit an issue on github.

Here is the library: [GitHub - RyanPaulMcKenna/onRobot: A simple gripper library for UR robot with onRobot gripper, no onrobot compute box needed!](https://github.com/RyanPaulMcKenna/onRobot/)

No need to clone, you can simply pip install with:

pip install onRobot

---

<div class="post-metadata">

**Author:** ![yuhanghao1998](https://avatars.discourse-cdn.com/v4/letter/y/eb9ed0/32.png) [@yuhanghao1998](https://forum.universal-robots.com/u/yuhanghao1998)\
**Post date:** [June 1, 2024, 2:46pm UTC](https://forum.universal-robots.com/t/controlling-robot-gripper-rg2-with-python/34450/5 "2024-06-01T14:46:10Z")

</div>

unfortunately, it doesn’t work, I don’t know if I need install any other library.  
I successfully runned lots of urscript commands like move the robot and set the IO, but when I run the onrobot urscript commands there’s no any response.  
did I do sth worng? I’d appreciate it if someone could give me a guidance!  
Thanks
