add test_all script, small cleanup

This commit is contained in:
Olivier R-D 2013-09-20 12:30:40 +02:00
parent dc01f2a4cb
commit 09e446ec70
3 changed files with 64 additions and 3 deletions

62
examples/test_all.py Normal file
View File

@ -0,0 +1,62 @@
"""
Testing script that runs many of the urx methods, while attempting to keep robot pose around its starting pose
"""
from math import pi
import time
import urx
import logging
if __name__ == "__main__":
rob = urx.Robot("192.168.1.6", logLevel=logging.WARNING)
rob.set_tcp((0, 0, 0, 0, 0, 0))
rob.set_payload(0.5, (0, 0, 0))
try:
l = 0.05
v = 0.05
a = 0.3
r = 0.01
print("Digital out 0 and 1 are: ", rob.get_digital_out(0), rob.get_digital_out(1) )
j = rob.getj()
print("Initial joint configuration is ", j)
t = rob.get_transform()
print("Transformation from base to tcp is: ", t)
print("Translating in x")
rob.translate((l, 0, 0), acc=a, vel=v)
pose = rob.getl()
print("robot tcp is at: ", pose)
print("moving in z")
pose[2] += l
rob.movel(pose, acc=a, vel=v, wait=False)
print("Waiting for end move")
rob.wait_for_move()
#FIXME add movep if controller version newer than XX
print("Moving through several points with a radius")
pose[0] -= l
p1 = pose[:]
pose[2] -= l
p2 = pose[:]
rob.movels([p1, p2], vel=v, acc=a, radius=r)
print("rotate tcp around around base z ")
t.orient.rotate_zb(pi / 8)
rob.apply_transform(t, vel=v, acc=a)
print("moving in tool z")
rob.translate_tool((0, 0, l), vel=v, acc=a)
print("moving in tool -z using speed command")
rob.speedl_tool((0, 0, -v, 0, 0, 0), acc=a, min_time=3)
print("Waiting 2 seconds2")
time.sleep(2)
print("stop robot")
rob.stopj()
print("Sending robot back to original position")
rob.movej(j, acc=0.8, vel=0.2)
finally:
rob.cleanup()

View File

@ -5,5 +5,5 @@ __version__ = "0.8"
from .urrobot import Robot, RobotException, URRobot from .robot import Robot, RobotException, URRobot

View File

@ -550,7 +550,6 @@ class Robot(URRobot):
pose = self.get_transform() pose = self.get_transform()
v = self.csys.orient * pose.orient * m3d.Vector(velocities[:3]) v = self.csys.orient * pose.orient * m3d.Vector(velocities[:3])
w = self.csys.orient * pose.orient * m3d.Vector(velocities[3:]) w = self.csys.orient * pose.orient * m3d.Vector(velocities[3:])
print(pose, v, w)
URRobot.speedl(self, np.concatenate((v.data, w.data)), acc, min_time) URRobot.speedl(self, np.concatenate((v.data, w.data)), acc, min_time)
def movel(self, pose, acc=None, vel=None, wait=True, relative=False, radius=0.01): def movel(self, pose, acc=None, vel=None, wait=True, relative=False, radius=0.01):
@ -578,7 +577,7 @@ class Robot(URRobot):
return current transformation from tcp to current csys return current transformation from tcp to current csys
""" """
t = self.get_transform(wait) t = self.get_transform(wait)
return t.pose_vector return t.pose_vector.tolist()
def movels(self, pose_list, acc=0.01, vel=0.01 , radius=0.01, wait=True): def movels(self, pose_list, acc=0.01, vel=0.01 , radius=0.01, wait=True):
""" """