Ask Your Question

Using ROS Rviz to control the UR5 with OnRobot RG2 Gripper

asked 2018-05-04 02:49:07 -0500

Fruitspunchsamurai gravatar image

updated 2018-05-04 04:42:11 -0500

Hello there!

My objective is to control the UR5 robotic arm with the RG2 Gripper from OnRobot (link here) using Rviz for both the simulated robot in Gazebo and the Real robot itself. My current setup is Ubuntu 16.04 >> ROS Kinetic >> Gazebo V7.0.0 Using the Universal Robot and ur_modern_driver packages in my catkin workspace.

As of now, i have managed to edit the .urdf files to attach the RG2 gripper model onto the UR5 in Gazebo. However, i am unsure on how to proceed further from this point in order to control the real and simulated gripper from Rviz. The only other example that i could find, is from Sharathrjtr (link here) but his RG2 gripper model is one big static mesh which i assume means that it cannot grip objects in Gazebo since his gripper hands will never close. By using his example, i am able to control the RG2 Gripper by sending,

$ rosservice call /rg2_gripper/control_width ur_control/RG2 110


$ rosservice call /rg2_gripper/control_width ur_control/RG2 0

to open and close the RG2 Gripper respectively. However, on further inspection, i find that his code just uses ROS as a means of communication with the UR5's controller (Lines 395 onwards of ur_driver.cpp)(Found here)

The parts of code are found below. Basically, all of the code assigned to cmd_str is in URScript.

std::string cmd_str;

char buf[5000],buf_socket[5000];
sprintf(buf, "\ttarget_width=%f\n",target_width);
std::cout << "Reached service to control RG2 gripper" << std::endl;

cmd_str = "def rg2ProgOpen():\n";
cmd_str += "\ttextmsg(\"inside RG2 function called\")\n";

cmd_str += buf;
cmd_str += "\ttarget_force=40\n";
cmd_str += "\tpayload=1.0\n";
cmd_str += "\tset_payload1=False\n";
cmd_str += "\tdepth_compensation=False\n";
cmd_str += "\tslave=False\n";

cmd_str += "\ttimeout = 0\n";
cmd_str += "\twhile get_digital_in(9) == False:\n";
cmd_str += "\t\ttextmsg(\"inside while\")\n";
cmd_str += "\t\tif timeout > 400:\n";
cmd_str += "\t\t\tbreak\n";
cmd_str += "\t\tend\n";
cmd_str += "\t\ttimeout = timeout+1\n";
cmd_str += "\t\tsync()\n";
cmd_str += "\tend\n";
cmd_str += "\ttextmsg(\"outside while\")\n";

cmd_str += "\tdef bit(input):\n";
cmd_str += "\t\tmsb=65536\n";
cmd_str += "\t\tlocal i=0\n";
cmd_str += "\t\tlocal output=0\n";
cmd_str += "\t\twhile i<17:\n";
cmd_str += "\t\t\tset_digital_out(8,True)\n";
cmd_str += "\t\t\tif input>=msb:\n";
cmd_str += "\t\t\t\tinput=input-msb\n";
cmd_str += "\t\t\t\tset_digital_out(9,False)\n";
cmd_str += "\t\t\telse:\n";
cmd_str += "\t\t\t\tset_digital_out(9,True)\n";
cmd_str += "\t\t\tend\n";
cmd_str += "\t\t\tif get_digital_in(8):\n";
cmd_str += "\t\t\t\tout=1\n";
cmd_str += "\t\t\tend\n";
cmd_str += "\t\t\tsync()\n";
cmd_str += "\t\t\tset_digital_out(8,False)\n";
cmd_str += "\t\t\tsync()\n";
cmd_str += "\t\t\tinput=input*2\n";
cmd_str += "\t\t\toutput=output*2\n";
cmd_str += "\t\t\ti=i+1\n";
cmd_str += "\t\tend\n";
cmd_str += "\t\treturn output\n";
cmd_str += "\tend\n";
cmd_str += "\ttextmsg(\"outside bit definition\")\n";

cmd_str += "\ttarget_width=target_width+0.0\n";
cmd_str += "\tif target_force>40:\n";
cmd_str += "\t\ttarget_force=40 ...
edit retag flag offensive close merge delete


i find that his code just uses ROS as a means of communication with the UR5's teach pendant

Can you clarify what you mean by this? The UR controller doesn't 'run ROS', so I'm unsure how you feel things should work.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-04 03:08:58 -0500 )edit

Thanks for the quick reply!!

I believe that he's using the URScript programming language as the foundation to control the robot. The rosservice calls that he makes through the terminal are just on the surface level, if my understanding is correct.

Fruitspunchsamurai gravatar imageFruitspunchsamurai ( 2018-05-04 03:48:10 -0500 )edit

Can you please add some more direct links to the parts you are referring to? Your only link right now points to an entire .cpp file.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-04 03:49:53 -0500 )edit

Edited the question.~ The comments field has a limited character count.

Fruitspunchsamurai gravatar imageFruitspunchsamurai ( 2018-05-04 04:14:52 -0500 )edit

Edited the question.~ The comments field has a limited character count.

Great. Editing your question is always preferable over using comments.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-04 04:20:12 -0500 )edit

If your gripper is connected to the controller, then I don't see a way around using URScript. Whether embedding it like this is the best approach, I don't know (the ur_modern_driver exposes a urscript topic that could potentially be used).

gvdhoorn gravatar imagegvdhoorn ( 2018-05-04 04:21:48 -0500 )edit

i find that his code just uses ROS as a means of communication with the UR5's teach pendant

note btw: this code does not 'communicate with the teach pendant', but with the controller. Those are two different things.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-04 04:22:14 -0500 )edit

I see.~ My bad, yeah it's with the controller!

I understand where you're coming from. I'll look into the topic you mentioned. Thanks!!

Fruitspunchsamurai gravatar imageFruitspunchsamurai ( 2018-05-04 04:41:21 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-05-24 05:44:53 -0500

sharath gravatar image

updated 2018-09-27 03:33:58 -0500

Controlling the RG2 gripper solely using the ROS (without URScript) might not be possible since the UR controller doesn't run on ROS which is provided in answer. As far as i know the driver from the UR controller only accepts commands using URScript.

I have come across some posts saying you can communicate with universal robot with C-api, but in the end it just points to the ROS's universal_robot and ur_modern_driver package.

"RG2 gripper model is one big static mesh". I had contacted the makers of RG2 gripper for providing the STEP/mesh file for the gripper body and its fingers. But they had provided me with just a single STEP file for the entire gripper. I can understand you will not able to simulate the finger motion without separate mesh for the fingers. If it's really needed then would suggest you to contact OnRobot requesting them to provide the gripper body and its fingers STEP/mesh files separately.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-05-04 02:49:07 -0500

Seen: 943 times

Last updated: Sep 27 '18