From ce46ff55c346a1d500e38d93e882f034c4ed1bd4 Mon Sep 17 00:00:00 2001 From: Ben Richardson Date: Tue, 7 May 2024 16:26:58 +0200 Subject: [PATCH 1/2] Add support for polyscope 3.15 --- urx/ursecmon.py | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/urx/ursecmon.py b/urx/ursecmon.py index 8eade8d..b61aa7d 100644 --- a/urx/ursecmon.py +++ b/urx/ursecmon.py @@ -72,8 +72,8 @@ def parse(self, data): self.version = (3, 2) allData['RobotModeData'] = self._get_data(pdata, "!IBQ???????BBdd", ("size", "type", "timestamp", "isRobotConnected", "isRealRobotEnabled", "isPowerOnRobot", "isEmergencyStopped", "isSecurityStopped", "isProgramRunning", "isProgramPaused", "robotMode", "controlMode", "speedFraction", "speedScaling", "speedFractionLimit")) elif psize == 47: - self.version = (3, 5) - allData['RobotModeData'] = self._get_data(pdata, "!IBQ???????BBddc", ("size", "type", "timestamp", "isRobotConnected", "isRealRobotEnabled", "isPowerOnRobot", "isEmergencyStopped", "isSecurityStopped", "isProgramRunning", "isProgramPaused", "robotMode", "controlMode", "speedFraction", "speedScaling", "speedFractionLimit", "reservedByUR")) + self.version = max(self.version,(3, 5)) + allData['RobotModeData'] = self._get_data(pdata, "!IBQ???????BBdddc", ("size", "type", "timestamp", "isRobotConnected", "isRealRobotEnabled", "isPowerOnRobot", "isEmergencyStopped", "isSecurityStopped", "isProgramRunning", "isProgramPaused", "robotMode", "controlMode", "speedFraction", "speedScaling", "speedFractionLimit", "reservedByUR")) else: allData["RobotModeData"] = self._get_data(pdata, "!iBQ???????Bd", ("size", "type", "timestamp", "isRobotConnected", "isRealRobotEnabled", "isPowerOnRobot", "isEmergencyStopped", "isSecurityStopped", "isProgramRunning", "isProgramPaused", "robotMode", "speedFraction")) elif ptype == 1: @@ -89,7 +89,15 @@ def parse(self, data): else: allData["CartesianInfo"] = self._get_data(pdata, "iBdddddddddddd", ("size", "type", "X", "Y", "Z", "Rx", "Ry", "Rz", "tcpOffsetX", "tcpOffsetY", "tcpOffsetZ", "tcpOffsetRx", "tcpOffsetRy", "tcpOffsetRz")) elif ptype == 5: - allData["LaserPointer(OBSOLETE)"] = self._get_data(pdata, "iBddd", ("size", "type")) + if self.version >= (3,6): + tmpstr = ["size", "type"] + for name in ["cheksum", "DHtheta", "DHa", "Dhd", "Dhalpha"]: + for i in range(0,6): + tmpstr += ["%s%s" % (name,i)] + tmpstr += ["calibration_status"] + allData['KinematicsInfo'] = self._get_data(pdata,"!iB IIIIII dddddd dddddd dddddd dddddd I", tmpstr) + else: + allData["LaserPointer(OBSOLETE)"] = self._get_data(pdata, "iBddd", ("size", "type")) elif ptype == 3: if self.version >= (3, 0): @@ -110,11 +118,29 @@ def parse(self, data): # allData["varMessage"] = self._get_data(pdata, "!iBQbb iiBAcAc", ("size", "type", "timestamp", "source", "robotMessageType", "code", "argument", "titleSize", "messageTitle", "messageText")) # elif ptype == 7: # allData["keyMessage"] = self._get_data(pdata, "!iBQbb iiBAcAc", ("size", "type", "timestamp", "source", "robotMessageType", "code", "argument", "titleSize", "messageTitle", "messageText")) - + elif ptype == 6: + fmt = "iB dddddddddddd dddddddddddd ddddd dddddd dddddd dddddd dddddd IIII" + tmpstr = ["size", "type"] + for i in range(0,6): + tmpstr += ["jointMinLimit%s" % i, "jointMaxLimit%s" % i] + for i in range(0,6): + tmpstr += ["jointMaxSpeed%s" % i, "jointMaxAcceleration%s" % i] + tmpstr += ["vJointDefault","aJointDefault","vToolDefault","aToolDefault","eqRadius"] + for name in ["DHa","Dhd","DHalpha","DHtheta"]: + for i in range(0,6): + tmpstr += ["%s%s" % (name,i)] + tmpstr += ["masterboardVersion","controllerBoxType","robotType","robotSubType"] + allData["ConfigurationData"] = self._get_data(pdata, fmt, tmpstr) elif ptype == 20: tmp = self._get_data(pdata, "!iB Qbb", ("size", "type", "timestamp", "source", "robotMessageType")) if tmp["robotMessageType"] == 3: - allData["VersionMessage"] = self._get_data(pdata, "!iBQbb bAbBBiAb", ("size", "type", "timestamp", "source", "robotMessageType", "projectNameSize", "projectName", "majorVersion", "minorVersion", "svnRevision", "buildDate")) + tmpVersion = self._get_data(pdata, "!iBQbb bABB", ("size", "type", "timestamp", "source", "robotMessageType", "projectNameSize", "projectName", "majorVersion", "minorVersion")) + if (tmpVersion['majorVersion'],tmpVersion['minorVersion']) >= (3, 12): + fmt = "!iBQbb bABBiiA" + self.version = (tmpVersion['majorVersion'],tmpVersion['minorVersion']) + else: + fmt = "!iBQbb bAbBBiAb" + allData["VersionMessage"] = self._get_data(pdata, fmt, ("size", "type", "timestamp", "source", "robotMessageType", "projectNameSize", "projectName", "majorVersion", "minorVersion", "bugfixVersion", "buildNumber", "buildDate")) elif tmp["robotMessageType"] == 6: allData["robotCommMessage"] = self._get_data(pdata, "!iBQbb iiAc", ("size", "type", "timestamp", "source", "robotMessageType", "code", "argument", "messageText")) elif tmp["robotMessageType"] == 1: @@ -129,6 +155,8 @@ def parse(self, data): allData["keyMessage"] = self._get_data(pdata, "!iBQbb iiBAcAc", ("size", "type", "timestamp", "source", "robotMessageType", "code", "argument", "titleSize", "messageTitle", "messageText")) elif tmp["robotMessageType"] == 5: allData["keyMessage"] = self._get_data(pdata, "!iBQbb iiAc", ("size", "type", "timestamp", "source", "robotMessageType", "code", "argument", "messageText")) + elif tmp["robotMessageType"] == 12: + allData["unknownMessage"] = self._get_data(pdata, "!iBQbb iib", ("size", "type", "timestamp", "source", "robotMessageType", "something1", "something2", "messageEnd?")) else: self.logger.debug("Message type parser not implemented %s", tmp) else: @@ -154,8 +182,9 @@ def _get_data(self, data, fmt, names): j += 1 elif f == "A": # we got an array # first we need to find its size - if j == len(fmt) - 2: # we are last element, size is the rest of data in packet + if j >= len(fmt) - 2: #added to account for later versions which don't add extra arraysize = len(tmpdata) + j += 1 else: # size should be given in last element asn = names[i - 1] if not asn.endswith("Size"): @@ -165,7 +194,7 @@ def _get_data(self, data, fmt, names): d[names[i]] = tmpdata[0:arraysize] # print "Array is ", names[i], d[names[i]] tmpdata = tmpdata[arraysize:] - j += 2 + j += 1 i += 1 else: fmtsize = struct.calcsize(fmt[j]) @@ -206,7 +235,7 @@ def find_first_packet(self, data): while True: if len(data) >= 5: psize, ptype = self.get_header(data) - if psize < 5 or psize > 2000 or ptype != 16: + if psize < 5 or psize > 2000 or (ptype != 20 and ptype != 16): data = data[1:] counter += 1 if counter > limit: From 2d5ae71f42ab48999fcde6e545d7d56af10774a2 Mon Sep 17 00:00:00 2001 From: Ben Richardson Date: Fri, 10 May 2024 11:42:46 +0200 Subject: [PATCH 2/2] Update to handle non-iterable math3d.Vector.pose_vector --- urx.egg-info/PKG-INFO | 21 +++++++++++++++++++++ urx.egg-info/SOURCES.txt | 15 +++++++++++++++ urx.egg-info/dependency_links.txt | 1 + urx.egg-info/requires.txt | 2 ++ urx.egg-info/top_level.txt | 1 + urx/robot.py | 11 +++++++++-- 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 urx.egg-info/PKG-INFO create mode 100644 urx.egg-info/SOURCES.txt create mode 100644 urx.egg-info/dependency_links.txt create mode 100644 urx.egg-info/requires.txt create mode 100644 urx.egg-info/top_level.txt diff --git a/urx.egg-info/PKG-INFO b/urx.egg-info/PKG-INFO new file mode 100644 index 0000000..3b3ca5e --- /dev/null +++ b/urx.egg-info/PKG-INFO @@ -0,0 +1,21 @@ +Metadata-Version: 2.1 +Name: urx +Version: 0.11.0 +Summary: Python library to control an UR robot +Home-page: https://github.com/oroulet/python-urx +Author: Olivier Roulet-Dubonnet +Author-email: olivier.roulet@gmail.com +License: GNU Lesser General Public License v3 +Platform: UNKNOWN +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 3 +Classifier: Development Status :: 4 - Beta +Classifier: Intended Audience :: Developers +Classifier: Operating System :: OS Independent +Classifier: Topic :: System :: Hardware :: Hardware Drivers +Classifier: Topic :: Software Development :: Libraries :: Python Modules +Provides: urx +License-File: COPYING + +UNKNOWN + diff --git a/urx.egg-info/SOURCES.txt b/urx.egg-info/SOURCES.txt new file mode 100644 index 0000000..3b900b5 --- /dev/null +++ b/urx.egg-info/SOURCES.txt @@ -0,0 +1,15 @@ +COPYING +README.md +setup.py +urx/__init__.py +urx/robot.py +urx/robotiq_two_finger_gripper.py +urx/urrobot.py +urx/urrtmon.py +urx/urscript.py +urx/ursecmon.py +urx.egg-info/PKG-INFO +urx.egg-info/SOURCES.txt +urx.egg-info/dependency_links.txt +urx.egg-info/requires.txt +urx.egg-info/top_level.txt \ No newline at end of file diff --git a/urx.egg-info/dependency_links.txt b/urx.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/urx.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/urx.egg-info/requires.txt b/urx.egg-info/requires.txt new file mode 100644 index 0000000..432f29d --- /dev/null +++ b/urx.egg-info/requires.txt @@ -0,0 +1,2 @@ +math3d +numpy diff --git a/urx.egg-info/top_level.txt b/urx.egg-info/top_level.txt new file mode 100644 index 0000000..2ca88b6 --- /dev/null +++ b/urx.egg-info/top_level.txt @@ -0,0 +1 @@ +urx diff --git a/urx/robot.py b/urx/robot.py index 160c03a..a27b285 100644 --- a/urx/robot.py +++ b/urx/robot.py @@ -102,7 +102,11 @@ def set_pose(self, trans, acc=0.01, vel=0.01, wait=True, command="movel", thresh """ 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 hasattr(t.pose_vector,'__iter__'): + t = t.pose_vector + else: + t = t.pose_vector.array + pose = URRobot.movex(self, command, t, acc=acc, vel=vel, wait=wait, threshold=threshold) if pose is not None: return self.csys.inverse * m3d.Transform(pose) @@ -208,7 +212,10 @@ def getl(self, wait=False, _log=True): return current transformation from tcp to current csys """ t = self.get_pose(wait, _log) - return t.pose_vector.tolist() + if hasattr(t.pose_vector,'tolist'): + return t.pose_vector.tolist() + else: + return t.pose_vector.get_array().tolist() def set_gravity(self, vector): if isinstance(vector, m3d.Vector):