From a283eef1727755ccca0230e91049ba4ad81d8fc0 Mon Sep 17 00:00:00 2001 From: olivier R-D Date: Wed, 27 Apr 2016 15:15:01 +0200 Subject: [PATCH] update README --- README.md | 53 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e657fe8..b629029 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ -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, although it has been used in many application with several version of UR5 and UR10 robots. +urx is a python library to control the robots from 'Universal robot'. It is published under the GPL license and comes with absolutely no guarantee. -It is meant 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. +It is meant 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 control frequency. -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. + +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. Python-math3d is a very good library and is advised to anybody programming robots using python! urx was primarily developed by [Olivier Roulet-Dubonnet](https://github.com/oroulet) for [Sintef Raufoss Manufacturing](http://www.sintef.no/manufacturing/). @@ -15,16 +16,17 @@ 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)) +sleep(0.2) #leave some time to robot to process the setup commands 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.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 + sleep(0.1) #sleep first since the robot may not have processed the command yet if robot.is_program_running(): break @@ -38,20 +40,27 @@ 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 + print("Robot could not execute move (emergency stop for example), do something", ex) ``` #Development using Transform objects from math3d library: ```python +from urx import Robot +import math3d as m3d + 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) +mytcp = m3d.Transform() # create a matrix for our tool tcp +mytcp.pos.z = 0.18 +mytcp.orient.rotate_zb(pi/3) +robot.set_tcp(mytcp) +time.sleep(0.2) + +# get current pose, transform it and move robot to new pose +trans = robot.get_pose() # get current transformation matrix (tool to base) +trans.pos.z += 0.3 +trans.orient.rotate_yb(pi/2) +robot.set_pose(trans, acc=0.5, vel=0.2) # apply the new pose #or only work with orientation part @@ -60,6 +69,22 @@ o.rotate_yb(pi) robot.set_orientation(o) ``` +#Other interactive methods/properties + +```python + +from urx import Robot +rob = Robot("192.168.1.1") +rob.x # returns current x +rob.rx # returns 0 (could return x component of axis vector, but it is not very usefull +rob.rx -= 0.1 # rotate tool around X axis +rob.z_t += 0.01 # move robot in tool z axis for +1cm + +csys = rob.new_csys_from_xpy() # generate a new csys from 3 points: X, origin, Y +rob.set_csys(csys) +``` + + #Robotiq Gripper urx can also control a Robotiq gripper attached to the UR robot. The robotiq class was primarily developed by [Mark Silliman](https://github.com/markwsilliman).