diff --git a/urx/robot.py b/urx/robot.py index 3e07d1e..51ad313 100644 --- a/urx/robot.py +++ b/urx/robot.py @@ -144,14 +144,20 @@ class Robot(URRobot): trans = self.get_pose(wait) 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 """ v = 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): """ @@ -211,23 +217,34 @@ class Robot(URRobot): 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 """ + # Set coord. sys. to 0 + self.csys = m3d.Transform() + print("A new coordinate system will be defined from the next three points") print("Firs point is X, second Origin, third Y") print("Set it as a new reference by calling myrobot.set_csys(new_csys)") input("Move to first point and click Enter") # we do not use get_pose so we avoid rounding values 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]) - input("Move to second point and click Enter") + input("Move to third point and click Enter") pose = URRobot.getl(self) - p1 = m3d.Vector(pose[:3]) - input("Move to second point and click Enter") - pose = URRobot.getl(self) - p2 = m3d.Vector(pose[:3]) - return m3d.Transform.new_from_xyp(p1 - p0, p2 - p0, p0) + print("Introduced point defining Y: {}".format(pose[:3])) + py = m3d.Vector(pose[:3]) + + new_csys = m3d.Transform.new_from_xyp(px - p0, py - p0, p0) + self.set_csys(new_csys) + + return new_csys @property def x(self): diff --git a/urx/urrobot.py b/urx/urrobot.py index e909437..5b389c3 100644 --- a/urx/urrobot.py +++ b/urx/urrobot.py @@ -181,7 +181,7 @@ class URRobot(object): """ 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) def set_tool_voltage(self, val): @@ -258,18 +258,6 @@ class URRobot(object): prog = "{}([{},{},{},{},{},{}], a={}, t_min={})".format(command, *vels) 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): """ move in joint space diff --git a/urx/ursecmon.py b/urx/ursecmon.py index 70c017a..197ea74 100644 --- a/urx/ursecmon.py +++ b/urx/ursecmon.py @@ -88,7 +88,13 @@ class ParserUtils(object): elif ptype == 5: allData["LaserPointer(OBSOLETE)"] = self._get_data(pdata, "iBddd", ("size", "type")) 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: allData["ToolData"] = self._get_data(pdata, "iBbbddfBffB", ("size", "type", "analoginputRange2", "analoginputRange3", "analogInput2", "analogInput3", "toolVoltage48V", "toolOutputVoltage", "toolCurrent", "toolTemperature", "toolMode")) elif ptype == 9: