Moving the RG2 Onrobot gripper from ROS

Good morning,
I am controlling from ROS an UR3 robot with an RG2 Onrobot gripper mounted on it.
I can easily move the UR with the topics obtained from the ur_driver, but i can’t control the gripper.
My aim is just to close and open it, and i was thinking that i was able to do it with the topic ‘ur_hardware_interface/script_command’ but it does not work… even if i try to see with rostopic echo the topic ‘/ur_hardware_interfasce/io_states’ to get more informations, a warning message appears telling me that this topic does not appear to be published yet, so i am guessing that ths gripper is not seen from the ur_driver, but i don’t know if is this the reason.

Hello,

Search the forum. The subject has been discussed multiple times. :slight_smile:

It might help if you call it RG2, too. :slight_smile:

Good morning,
actually i saw the discussions in the forum but i didn’t understand what they have done to solve the problem, i donwloaded a libvrary from a guy in a discussion, but then i don’t know where do i write the following code:

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 :slight_smile:
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

And i am wondering if, after adding this library, i am able to control it also with the ROS topics.

Ah, right. :slight_smile: I haven’t done it before, so I’m afraid I can’t help you. Just seen the topic around a couple of times recently.

I hope someone helps you out soon!

Good morning,
if someone is interested, i solved the problem using the sosservice call /ur_hardware_interface/set_io. I did set a digital output to 1 and then i connected the digital and the tool output in the teach pendant, so when i set the output from ros with the rosservice call, tha pins, connected to the tool digital output will be set as that pin.