This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. urx is a python library to control a robot from 'Universal robot'. It has currently been used with several versions of UR5. 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 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.orient((0.1, 0, 0), a, v) #orient tool and keep tool tip position rob.stopj(a) robot.movel(x, y, z, rx, ry, rz), wait=False) while True : sleep(0.1) #sleep first since the information may be outdated 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 Using matrices: robot = Robot("192.168.1.1") robot.set_tcp((0,0,0.23,0,0,0) calib = mathd3d.Transform() calib.orient.rotate_zb(pi/4) #just an example robot.add_csys("mycsys", calib) #set robot corrdinate system robot.set_default_csys("mycsys") trans = robot.get_transform() # get current transformation matrix (tool to base) trans.orient.rotate_yt(pi/2) robot.apply_transform(trans) trans.pos += math3d.Vector(0,0,0.3) robot.apply_transform(trans) #or only work with orientation part o = robot.get_orientation() o.rotate_yb(pi) robot.orient(o)
Description
Python library to control a robot from 'Universal Robots' http://www.universal-robots.com/ with added getl_rt() call for faster positional updates.
Languages
Python
100%