Skip to main content

Python library to control an UR robot

Project description


urx is a python library to control a robot from 'Universal robot'.
It is published under the GPL license and comes with absolutely no
guarantee, althoug it has been used in many application with several
version of UR5 and UR10 robots.

It is meaned as an easy to use module for pick and place operations,
although it has been used for welding and other sensor based applications
that do not require high update rate.

Both the 'secondary port' interface and the real-time/matlab interface of the
UR controller are used. urx can optionally use the python-math3d
https://launchpad.net/pymath3d library to receive and send transformation
matrices to the robot urx is known to work with all release robots from Universal Robot.

urx was primarily developed by Olivier Roulet-Dubonnet for Sintef Raufoss Manufacturing
and : http://www.sintef.no/manufacturing/

Example use:

import urx

rob = urx.robot("192.168.0.100")
rob.set_tcp((0, 0, 0.1, 0, 0, 0))
rob.set_payload(2, (0, 0, 0.1))
rob.movej((1, 2, 3, 4, 5, 6), a, v)
rob.movel((x, y, z, rx, ry, rz), a, v)
print "Current tool pose is: ", rob.getl()
rob.movel((0.1, 0, 0, 0, 0, 0), a, v, relative=true)# move relative to current pose
rob.translate((0.1, 0, 0), a, v) #move tool and keep orientation
rob.stopj(a)

robot.movel(x, y, z, rx, ry, rz), wait=False)
while True :
sleep(0.1) #sleep first since the robot may not have processed the command yet
if robot.is_program_running():
break

robot.movel(x, y, z, rx, ry, rz), wait=False)
while.robot.getForce() < 50:
sleep(0.01)
if not robot.is_program_running():
break
robot.stopl()

try:
robot.movel((0,0,0.1,0,0,0), relative=True)
except RobotError, ex:
print "Robot could not execute move (emergency stop for example), do something", ex

Development using Transform objects from math3d library:

robot = Robot("192.168.1.1")
robot.set_tcp((0,0,0.23,0,0,0)
robot.csys.orient.rotate_zb(pi/4) #just an example
trans = robot.get_pose() # get current transformation matrix (tool to base)
trans.orient.rotate_yt(pi/2)
robot.set_pose(trans)
trans.pos += math3d.Vector(0,0,0.3)
robot.set_pose(trans)


#or only work with orientation part
o = robot.get_orientation()
o.rotate_yb(pi)
robot.set_orientation(o)


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

urx-0.9.5.tar.gz (13.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page