diff --git a/lerobot/common/motors/dynamixel/dynamixel.py b/lerobot/common/motors/dynamixel/dynamixel.py index 5992ae56..3a3f5016 100644 --- a/lerobot/common/motors/dynamixel/dynamixel.py +++ b/lerobot/common/motors/dynamixel/dynamixel.py @@ -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 diff --git a/lerobot/common/motors/feetech/feetech.py b/lerobot/common/motors/feetech/feetech.py index 4c8dd4ed..74c114b3 100644 --- a/lerobot/common/motors/feetech/feetech.py +++ b/lerobot/common/motors/feetech/feetech.py @@ -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 diff --git a/lerobot/common/motors/motors_bus.py b/lerobot/common/motors/motors_bus.py index 4558d56c..249c66a8 100644 --- a/lerobot/common/motors/motors_bus.py +++ b/lerobot/common/motors/motors_bus.py @@ -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