fix: Add complement zero of speed in send_angle function.

This commit is contained in:
Zachary Zhang 2020-12-30 18:55:26 +08:00
parent e6fcc676c5
commit cc9c7151b6
2 changed files with 6 additions and 4 deletions

View file

@ -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
return data

View file

@ -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
return data