Make Your Own Pick and Place AI Robot with UR5 robot and RG2 Gripper:

Agam Srivastava
5 min readJan 18, 2024

Part 1 — Setting up the environment and doing a test run

Welcome to the first part of our exciting series on creating a pick-and-place AI robot using the UR5 robotic arm!

In this series, we’ll guide you through the entire process, from designing the AI model to integrating it with the robot hardware.

The robot in question is the ur5 robot designed by Universal robots https://www.universal-robots.com/.

The robot has 6 Degrees of freedom and a payload capacity of upto 5kg.

Which is paired with a RG2 gripper designed specifically to play nice with the ur5 robot.

Today, we’ll focus on the first crucial step: Setting up the robot in a local network and ensuring its interactivity within the network to a local python server.

Prerequisites for the following:

  1. Basic networking knowledge
  2. Access to a bash shell
  3. Intermediate knowledge of python

Outline :-

• Setup the robot and gripper on the same network

• Install the external control urcap on the ur5 robot

• Install the onrobot urcap on the ur5 robot.

• Setup an External TCP Server on your remote host and

put the robot on external control mode.

• Write your urscript and send it to the robot

Step 1) Setup the robot and gripper on the same network

Connect the robot to router through ethernet and ensure that it has

an ip assigned to it in the setup robot submenu.

You will be able to see it in the network section within which you

should be able to see a green arrow with the text “ network is

connected”.

Ideally you should setup a static ip reserved only for the robot

through this the router will not assign the robot a new ip incase

there is a router reset. This will also ensure you don’t have to

regularly change the server ip in your config.

For the gripper the process is similar just plug in the default config

for the gripper and connect it through ethernet to your router.

Step 2) Install the external control urcap on the ur5 robot

Visit https://github.com/UniversalRobots/Universal_Robots_ROS2_Dri

ver/blob/foxy/ur_robot_driver/resources/externalcontrol-

1.0.5.urcap

To install the external control urcap file:-

Now comes how to install it on the robot

If you have followed step 1 correctly your robot should be on the

local network and will be able to be pinged.

NOTE:- Ensure you are on the same local network either through

ethernet or ip in the router.

For example if the robot ip is 192.168.0.100 the command

ping 192.168.0.100

should return a positive match.

If the robot is able to be pinged it will also have ssh enabled

so to access your robot through ssh you need to figure out the id

and the password for the robot , don’t worry if you have not set

something like that up till now because by default there are set

credentials for the robot.

your id: root@[Robot’s IP]

your password: easybot

so for example if your robot’s ip is 192.168.0.100 we will be able

to access it through the command

ssh root@192.168.0.100

Then enter your password which is easybot.

If you are experiencing any kind of issue ensure that the robot is

pingable on the ip and you are on the same network.

Now that you have ensured that you are able to access the robot

through ssh exit out of it.

Time for copying the external control urcap to the robot

Navigate to the directory where the external control urcap is saved

now execute the following scp command

scp [external_control_version].urcap root@[robot’s ip]:/[your

desired dir]/

which will then prompt you for the robot’s password and enter .

To enable the urcap go to the robot’s setup page and enter the

setup menu .

Navigate to the urcaps section and press the “+” icon to add the

external control urcap , navigate to the directory where you scped

the urcap and select it.

Now it should be installed on your robot and will probably require

a restart.

Now to install the onrobot urcap for the gripper a similar

procedure is to be followed.

Go to https://onrobot.com/en/downloads select your product and get the onrobot urcap installed.

Copying to the robot is the same procedure as you installed the

external control urcap.

Step 3) Setup an External TCP Server on your remote host

Put the robot on external control mode by navigating into the settings

of the robot

Now to setup your external tcp server you can either write your

own server which will handle the robot’s incoming request and

return a urscript to the robot.

For now just to test everything is working we can go with a pre

written repo from github

https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap/tree/master/examples/simple_external_control_server

Here you can download the simple_external_control_server.py

and the hello_world.script

You will see that inside the hello_world.script

there is only a textmsg function and the robot is not actually

moving, let fix that.

Modify the urscript inside hello_world.script to the following

def test_func():

textmsg(“test function”)p = [0,-3.14159/2,0,-3.14159/2,0,0]

movej(p,a=1.0, v=0.5)

end

# NODE_CONTROL_LOOP_BEGINS

test_func()

# NODE_CONTROL_LOOP_ENDS

Now in the robot go to start a new empty program.

In the installation tab scroll down and go to the external control

section and set the ip of the robot to the local ip of your computer

and the port as the port on which you are gonna be running the

server on

Now we have add a new external control node in the program.

Go to structure subtab, go to advanced and select external control.

Now run the program.

CAUTION: This will move the robot from its current position to

the specified joint positions. Ensure that you have emergency stop

available on hand and are a safe distance away from the robot.

Now to move the gripper we can use the onrobot urcap.Go to installation tab and scroll down to the onrobot section. Enter

it and search for your gripper arm. Don’t panic if it doesn’t show

up recheck your gripper connections and press the refresh button

in the menu it will eventually show up.

Now to manipulate the gripper there are two commands rg_grip

and rg_payload_set which can be called to set the gripper width

and the gripper payload independently.

So now to modify the urscript further to also move the gripper

simultaneously the script would become

def test_func():

textmsg(“test function”)

p = [0,-3.14159/2,0,-3.14159/2,0,0]

movej(p,a=1.0, v=0.5)

on_return = rg_grip(60.0, 40.0, tool_index = 0, blocking = True,

depth_comp = False, popupmsg = True)

rg_payload_set(mass = 0.0, tool_index = 0, use_guard = True)

end

# NODE_CONTROL_LOOP_BEGINS

test_func()

# NODE_CONTROL_LOOP_ENDS

this will set the gripper width to 60mm and payload to 0kg

Again press play in the pendant and the robot should move to the

specified joint position and set the gripper width to 60mm.

Now we can move the ur5 robot on our wish through a local tcp server that we have written.

In the next part we will move on to actually building the AI model and training it on a simple shape like a square to be picked and placed on a board.

--

--