From 9f90213e2269d49ad1d5daf50d4fddcffee87348 Mon Sep 17 00:00:00 2001 From: weiquan Date: Tue, 20 Dec 2022 19:18:11 +0800 Subject: [PATCH] release v3.0.2 --- CHANGELOG.md | 8 ++++++++ pymycobot/Interface.py | 31 +++++++++++++++++++------------ pymycobot/__init__.py | 2 +- pymycobot/common.py | 4 ++++ pymycobot/mybuddy.py | 8 +++++++- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ab7952..4db7d0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # ChangeLog for pymycobot +## v3.0.2 (2022-12-20) + +- release v3.0.2 +- Fix MyBuddy interface problems: + - Add get_fresh_mode() + - remove get_servo_current() + - get_servo_voltages()、get_servo_status()、get_servo_temps() + ## v3.0.1 (2022-12-9) - release v3.0.1 diff --git a/pymycobot/Interface.py b/pymycobot/Interface.py index 42496d3..a61bcc6 100644 --- a/pymycobot/Interface.py +++ b/pymycobot/Interface.py @@ -137,6 +137,14 @@ def set_fresh_mode(self, id, mode): 0 - Execute instructions sequentially in the form of a queue. """ return self._mesg(ProtocolCode.SET_FRESH_MODE, id, mode) + + def get_fresh_mode(self, id): + """Get instruction refresh mode status + + Args: + id: 1/2 (L/R). + """ + return self._mesg(ProtocolCode.GET_FRESH_MODE, id, has_reply=True) def set_free_mode(self, id, value): """set free mode @@ -939,27 +947,26 @@ def set_plan_acceleration(self, id, acceleration): ProtocolCode.SET_PLAN_ACCELERATION, id, acceleration ) - def get_servo_currents(self, id): - """Get joint current + # def get_servo_currents(self, id): + # """Get joint current - Args: - id: 1/2/3 (L/R/W) + # Args: + # id: 1/2/3 (L/R/W) - Return: - value mA - """ - return self._mesg(ProtocolCode.GET_SERVO_VOLTAGES, id, has_reply=True) + # Return: + # value mA + # """ + # return self._mesg(ProtocolCode.GET_SERVO_CURRENTS, id, has_reply=True) def get_servo_voltages(self, id): """Get joint voltages Args: id: 1/2/3 (L/R/W) - Return: volts < 24 V """ - return self._mesg(ProtocolCode.GET_SERVO_STATUS, id, has_reply=True) + return self._mesg(ProtocolCode.GET_SERVO_VOLTAGES, id, has_reply=True) def get_servo_status(self, id): """Get joint status @@ -970,7 +977,7 @@ def get_servo_status(self, id): Return: [voltage, sensor, temperature, current, angle, overload], a value of 0 means no error """ - return self._mesg(ProtocolCode.GET_SERVO_TEMPS, id, has_reply=True) + return self._mesg(ProtocolCode.GET_SERVO_STATUS, id, has_reply=True) def get_servo_temps(self, id): """Get joint temperature @@ -978,7 +985,7 @@ def get_servo_temps(self, id): Args: id: 1/2/3 (L/R/W) """ - return self._mesg(0xE6, id, has_reply=True) + return self._mesg(ProtocolCode.GET_SERVO_TEMPS, id, has_reply=True) def get_base_coords(self, *args): """Convert coordinates to base coordinates. Pass in parameters or no parameters diff --git a/pymycobot/__init__.py b/pymycobot/__init__.py index 66e3aa7..7192b48 100644 --- a/pymycobot/__init__.py +++ b/pymycobot/__init__.py @@ -43,7 +43,7 @@ from pymycobot.mybuddyemoticon import MyBuddyEmoticon __all__.append("MyBuddyEmoticon") -__version__ = "3.0.1" +__version__ = "3.0.2" __author__ = "Elephantrobotics" __email__ = "weiquan.xu@elephantrobotics.com" __git_url__ = "https://github.com/elephantrobotics/pymycobot" diff --git a/pymycobot/common.py b/pymycobot/common.py index 0877034..e6bc3e1 100644 --- a/pymycobot/common.py +++ b/pymycobot/common.py @@ -289,6 +289,10 @@ def _process_received(self, data, genre, arm=6): # process valid data res = [] + if genre in [ProtocolCode.GET_SERVO_VOLTAGES, ProtocolCode.GET_SERVO_STATUS, ProtocolCode.GET_SERVO_TEMPS]: + for i in valid_data: + res.append(i) + return res if data_len in [6, 8, 12, 14, 24, 60]: for header_i in range(0, len(valid_data), 2): one = valid_data[header_i : header_i + 2] diff --git a/pymycobot/mybuddy.py b/pymycobot/mybuddy.py index 3bd704f..d4d2812 100644 --- a/pymycobot/mybuddy.py +++ b/pymycobot/mybuddy.py @@ -106,9 +106,13 @@ def _read(self): datas = b'\xfe' pre = k except: + self.log.debug("_read: {}".format(datas)) + datas = None break else: + self.log.debug("_read: {}".format(datas)) + datas = None self.log.debug("_read: {}".format(datas)) return datas @@ -155,7 +159,9 @@ def _mesg(self, genre, *args, **kwargs): ProtocolCode.GET_MOVEMENT_TYPE, ProtocolCode.GET_REFERENCE_FRAME, ProtocolCode.GET_JOINT_MIN_ANGLE, - ProtocolCode.GET_JOINT_MAX_ANGLE + ProtocolCode.GET_JOINT_MAX_ANGLE, + ProtocolCode.GET_FRESH_MODE, + # ProtocolCode.GET_SERVO_CURRENTS ]: return self._process_single(res) elif genre in [ProtocolCode.GET_ANGLES]: