Simplify _is_comm_success & _is_error
This commit is contained in:
parent
a38bb15e79
commit
57c97762e1
|
@ -57,7 +57,8 @@ class DynamixelMotorsBus(MotorsBus):
|
|||
self.packet_handler = dxl.PacketHandler(PROTOCOL_VERSION)
|
||||
self.sync_reader = dxl.GroupSyncRead(self.port_handler, self.packet_handler, 0, 0)
|
||||
self.sync_writer = dxl.GroupSyncWrite(self.port_handler, self.packet_handler, 0, 0)
|
||||
self.__comm_success = dxl.COMM_SUCCESS
|
||||
self._comm_success = dxl.COMM_SUCCESS
|
||||
self._error = 0x00
|
||||
|
||||
def broadcast_ping(
|
||||
self, num_retry: int = 0, raise_on_error: bool = False
|
||||
|
@ -78,12 +79,6 @@ class DynamixelMotorsBus(MotorsBus):
|
|||
# TODO
|
||||
return ids_values
|
||||
|
||||
def _is_comm_success(self, comm: int) -> bool:
|
||||
return comm == self.__comm_success
|
||||
|
||||
def _is_error(self, error: int) -> bool:
|
||||
return error != 0x00
|
||||
|
||||
@staticmethod
|
||||
def split_int_bytes(value: int, n_bytes: int) -> list[int]:
|
||||
# Validate input
|
||||
|
|
|
@ -53,7 +53,8 @@ class FeetechMotorsBus(MotorsBus):
|
|||
self.packet_handler = scs.PacketHandler(PROTOCOL_VERSION)
|
||||
self.sync_reader = scs.GroupSyncRead(self.port_handler, self.packet_handler, 0, 0)
|
||||
self.sync_writer = scs.GroupSyncWrite(self.port_handler, self.packet_handler, 0, 0)
|
||||
self.__comm_success = scs.COMM_SUCCESS
|
||||
self._comm_success = scs.COMM_SUCCESS
|
||||
self._error = 0x00
|
||||
|
||||
def broadcast_ping(self, num_retry: int | None = None):
|
||||
raise NotImplementedError # TODO
|
||||
|
@ -66,12 +67,6 @@ class FeetechMotorsBus(MotorsBus):
|
|||
# TODO
|
||||
return ids_values
|
||||
|
||||
def _is_comm_success(self, comm: int) -> bool:
|
||||
return comm == self.__comm_success
|
||||
|
||||
def _is_error(self, error: int) -> bool:
|
||||
return error != 0x00
|
||||
|
||||
@staticmethod
|
||||
def split_int_bytes(value: int, n_bytes: int) -> list[int]:
|
||||
# Validate input
|
||||
|
|
|
@ -258,6 +258,8 @@ class MotorsBus(abc.ABC):
|
|||
self.packet_handler: PacketHandler
|
||||
self.sync_reader: GroupSyncRead
|
||||
self.sync_writer: GroupSyncWrite
|
||||
self._comm_success: int
|
||||
self._error: int
|
||||
|
||||
self.calibration = None
|
||||
|
||||
|
@ -391,13 +393,11 @@ class MotorsBus(abc.ABC):
|
|||
def uncalibrate_values(self, ids_values: dict[int, float]) -> dict[int, int]:
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def _is_comm_success(self, comm: int) -> bool:
|
||||
pass
|
||||
return comm == self._comm_success
|
||||
|
||||
@abc.abstractmethod
|
||||
def _is_error(self, error: int) -> bool:
|
||||
pass
|
||||
return error != self._error
|
||||
|
||||
@staticmethod
|
||||
@abc.abstractmethod
|
||||
|
|
Loading…
Reference in New Issue