Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, host, use_rt=False):
URRobot.__init__(self, host, use_rt)
self.csys = m3d.Transform()
def rz_t(self, val):
t = m3d.Transform()
t.orient.rotate_zb(val)
self.add_pose_tool(t)
def translate_tool(self, vect, acc=0.01, vel=0.01, wait=True, threshold=None):
"""
move tool in tool coordinate, keeping orientation
"""
t = m3d.Transform()
if not isinstance(vect, m3d.Vector):
vect = m3d.Vector(vect)
t.pos += vect
return self.add_pose_tool(t, acc, vel, wait=wait, threshold=threshold)
def get_pose(self, wait=False, _log=True):
"""
get current transform from base to to tcp
"""
pose = URRobot.getl(self, wait, _log)
trans = self.csys.inverse * m3d.Transform(pose)
if _log:
self.logger.debug("Returning pose to user: %s", trans.pose_vector)
return trans
self.robot.speedl_tool(speeds, acc=0.10, min_time=2)
else:
self.robot.speedl(speeds, acc=0.10, min_time=2)
btn_event = None
speeds = cmd.get_speeds()
#if speeds != [0 for _ in speeds]:
print(event)
print("Sending", speeds)
if __name__ == '__main__':
spnav.spnav_open()
robot = urx.Robot("192.168.0.90")
#robot = urx.Robot("localhost")
robot.set_tcp((0, 0, 0.27, 0, 0, 0))
trx = m3d.Transform()
trx.orient.rotate_zb(pi/4)
robot.set_csys("mycsys", trx)
service = Service(robot)
try:
service.loop()
finally:
robot.close()
spnav.spnav_close()
def set_pos(self, vect, acc=0.01, vel=0.01, wait=True, threshold=None):
"""
set tool to given pos, keeping constant orientation
"""
if not isinstance(vect, m3d.Vector):
vect = m3d.Vector(vect)
trans = m3d.Transform(self.get_orientation(), m3d.Vector(vect))
return self.set_pose(trans, acc, vel, wait=wait, threshold=threshold)
def _save_data(self):
result = np.zeros(len(self._data), dtype=[ ('timestamp', 'float64') , ('pose', '6float64'), ('joints', '6float64') ])
for idx, data in enumerate(self._data):
if MATH3D:
trf = self.inverse * math3d.Transform(data[1])
else:
trf = data[1]
result[idx] = (data[0], trf.pose_vector, data[2] )
self._queue.put(result)
def set_pose(self, trans, acc=0.01, vel=0.01, wait=True, command="movel", threshold=None):
"""
move tcp to point and orientation defined by a transformation
UR robots have several move commands, by default movel is used but it can be changed
using the command argument
"""
self.logger.debug("Setting pose to %s", trans.pose_vector)
t = self.csys * trans
pose = URRobot.movex(self, command, t.pose_vector, acc=acc, vel=vel, wait=wait, threshold=threshold)
if pose is not None:
return self.csys.inverse * m3d.Transform(pose)