From cc9c7151b60709c445e1d2bdf500b9fbad91f841 Mon Sep 17 00:00:00 2001 From: Zachary Zhang Date: Wed, 30 Dec 2020 18:55:26 +0800 Subject: [PATCH] fix: Add complement zero of speed in send_angle function. --- scripts/pythonAPI/mycobot.py | 5 +++-- scripts/pythonAPI/mycobot3.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/pythonAPI/mycobot.py b/scripts/pythonAPI/mycobot.py index 7360dda..06fba8d 100644 --- a/scripts/pythonAPI/mycobot.py +++ b/scripts/pythonAPI/mycobot.py @@ -94,7 +94,8 @@ class MyCobot(): ''' _hex = self._angle_to_hex(degree) - command = 'fefe0621{}{}{}fa'.format(id, _hex, hex(speed)[2:]) + speed = self._complement_zero(hex(speed)[2:], digit=2) + command = 'fefe0621{}{}{}fa'.format(id, _hex, speed) # print(command) self._write(command) @@ -353,4 +354,4 @@ class MyCobot(): def _read(self, size=1024): data = self.serial_port.read(size) - return data \ No newline at end of file + return data diff --git a/scripts/pythonAPI/mycobot3.py b/scripts/pythonAPI/mycobot3.py index f6f8009..263386d 100644 --- a/scripts/pythonAPI/mycobot3.py +++ b/scripts/pythonAPI/mycobot3.py @@ -95,7 +95,8 @@ class MyCobot(): ''' _hex = self._angle_to_hex(degree) - command = 'fefe0621{}{}{}fa'.format(id, _hex, hex(speed)[2:]) + speed = self._complement_zero(hex(speed)[2:], digit=2) + command = 'fefe0621{}{}{}fa'.format(id, _hex, speed) # print(command) self._write(command) @@ -354,4 +355,4 @@ class MyCobot(): def _read(self, size: int=1024): data = self.serial_port.read(size) - return data \ No newline at end of file + return data