Merge pull request #10 from alvcap/master

3.x firmware compatible, speedx, set_analog_out and new_csys_from_xpy
This commit is contained in:
ORD 2016-08-11 16:26:17 +02:00 committed by GitHub
commit e4578c6df1
3 changed files with 35 additions and 24 deletions

View File

@ -144,14 +144,20 @@ class Robot(URRobot):
trans = self.get_pose(wait) trans = self.get_pose(wait)
return trans.pos return trans.pos
def speedx(self, command, velocities, acc, min_time): def speedl(self, velocities, acc, min_time):
""" """
send command to robot formated like speedl or speedj
move at given velocities until minimum min_time seconds move at given velocities until minimum min_time seconds
""" """
v = self.csys.orient * m3d.Vector(velocities[:3]) v = self.csys.orient * m3d.Vector(velocities[:3])
w = self.csys.orient * m3d.Vector(velocities[3:]) w = self.csys.orient * m3d.Vector(velocities[3:])
URRobot.speedx(self, command, np.concatenate((v.array, w.array)), acc, min_time) vels = np.concatenate((v.array, w.array))
return self.speedx("speedl", vels, acc, min_time)
def speedj(self, velocities, acc, min_time):
"""
move at given joint velocities until minimum min_time seconds
"""
return self.speedx("speedj", velocities, acc, min_time)
def speedl_tool(self, velocities, acc, min_time): def speedl_tool(self, velocities, acc, min_time):
""" """
@ -211,23 +217,34 @@ class Robot(URRobot):
def new_csys_from_xpy(self): def new_csys_from_xpy(self):
""" """
Return new coordinate system from three points: X, Origin, Y Restores and returns new coordinate system calculated from three points: X, Origin, Y
based on math3d: Transform.new_from_xyp based on math3d: Transform.new_from_xyp
""" """
# Set coord. sys. to 0
self.csys = m3d.Transform()
print("A new coordinate system will be defined from the next three points") print("A new coordinate system will be defined from the next three points")
print("Firs point is X, second Origin, third Y") print("Firs point is X, second Origin, third Y")
print("Set it as a new reference by calling myrobot.set_csys(new_csys)") print("Set it as a new reference by calling myrobot.set_csys(new_csys)")
input("Move to first point and click Enter") input("Move to first point and click Enter")
# we do not use get_pose so we avoid rounding values # we do not use get_pose so we avoid rounding values
pose = URRobot.getl(self) pose = URRobot.getl(self)
print("Introduced point defining X: {}".format(pose[:3]))
px = m3d.Vector(pose[:3])
input("Move to second point and click Enter")
pose = URRobot.getl(self)
print("Introduced point defining Origo: {}".format(pose[:3]))
p0 = m3d.Vector(pose[:3]) p0 = m3d.Vector(pose[:3])
input("Move to second point and click Enter") input("Move to third point and click Enter")
pose = URRobot.getl(self) pose = URRobot.getl(self)
p1 = m3d.Vector(pose[:3]) print("Introduced point defining Y: {}".format(pose[:3]))
input("Move to second point and click Enter") py = m3d.Vector(pose[:3])
pose = URRobot.getl(self)
p2 = m3d.Vector(pose[:3]) new_csys = m3d.Transform.new_from_xyp(px - p0, py - p0, p0)
return m3d.Transform.new_from_xyp(p1 - p0, p2 - p0, p0) self.set_csys(new_csys)
return new_csys
@property @property
def x(self): def x(self):

View File

@ -181,7 +181,7 @@ class URRobot(object):
""" """
set analog output, val is a float set analog output, val is a float
""" """
prog = "set_analog_output(%s, %s)" % (output, val) prog = "set_analog_out(%s, %s)" % (output, val)
self.send_program(prog) self.send_program(prog)
def set_tool_voltage(self, val): def set_tool_voltage(self, val):
@ -258,18 +258,6 @@ class URRobot(object):
prog = "{}([{},{},{},{},{},{}], a={}, t_min={})".format(command, *vels) prog = "{}([{},{},{},{},{},{}], a={}, t_min={})".format(command, *vels)
self.send_program(prog) self.send_program(prog)
def speedl(self, velocities, acc, min_time):
"""
move at given velocities until minimum min_time seconds
"""
return self.speedx("speedl", velocities, acc, min_time)
def speedj(self, velocities, acc, min_time):
"""
move at given joint velocities until minimum min_time seconds
"""
return self.speedx("speedj", velocities, acc, min_time)
def movej(self, joints, acc=0.1, vel=0.05, wait=True, relative=False, threshold=None): def movej(self, joints, acc=0.1, vel=0.05, wait=True, relative=False, threshold=None):
""" """
move in joint space move in joint space

View File

@ -88,7 +88,13 @@ class ParserUtils(object):
elif ptype == 5: elif ptype == 5:
allData["LaserPointer(OBSOLETE)"] = self._get_data(pdata, "iBddd", ("size", "type")) allData["LaserPointer(OBSOLETE)"] = self._get_data(pdata, "iBddd", ("size", "type"))
elif ptype == 3: elif ptype == 3:
allData["MasterBoardData"] = self._get_data(pdata, "iBhhbbddbbddffffBBb", ("size", "type", "digitalInputBits", "digitalOutputBits", "analogInputRange0", "analogInputRange1", "analogInput0", "analogInput1", "analogInputDomain0", "analogInputDomain1", "analogOutput0", "analogOutput1", "masterBoardTemperature", "robotVoltage48V", "robotCurrent", "masterIOCurrent")) # , "masterSafetyState" ,"masterOnOffState", "euromap67InterfaceInstalled" ))
if self.version >= (3, 0):
fmt = "iBiibbddbbddffffBBb" # firmware >= 3.0
else:
fmt = "iBhhbbddbbddffffBBb" # firmware < 3.0
allData["MasterBoardData"] = self._get_data(pdata, fmt, ("size", "type", "digitalInputBits", "digitalOutputBits", "analogInputRange0", "analogInputRange1", "analogInput0", "analogInput1", "analogInputDomain0", "analogInputDomain1", "analogOutput0", "analogOutput1", "masterBoardTemperature", "robotVoltage48V", "robotCurrent", "masterIOCurrent")) # , "masterSafetyState" ,"masterOnOffState", "euromap67InterfaceInstalled" ))
elif ptype == 2: elif ptype == 2:
allData["ToolData"] = self._get_data(pdata, "iBbbddfBffB", ("size", "type", "analoginputRange2", "analoginputRange3", "analogInput2", "analogInput3", "toolVoltage48V", "toolOutputVoltage", "toolCurrent", "toolTemperature", "toolMode")) allData["ToolData"] = self._get_data(pdata, "iBbbddfBffB", ("size", "type", "analoginputRange2", "analoginputRange3", "analogInput2", "analogInput3", "toolVoltage48V", "toolOutputVoltage", "toolCurrent", "toolTemperature", "toolMode"))
elif ptype == 9: elif ptype == 9: