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