mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-23 09:46:00 +00:00
fix(dynamixel): guard sync_read and broadcast_ping on Protocol 1
Protocol 1.0 has no Sync Read instruction and the SDK's broadcastPing returns COMM_NOT_AVAILABLE, so raise a clear NotImplementedError instead of silently returning garbage.
This commit is contained in:
@@ -137,7 +137,14 @@ class DynamixelMotorsBus(SerialMotorsBus):
|
||||
)
|
||||
|
||||
def _assert_protocol_is_compatible(self, instruction_name: str) -> None:
|
||||
pass
|
||||
if instruction_name == "sync_read" and self.protocol_version == 1:
|
||||
raise NotImplementedError(
|
||||
"'Sync Read' is not available with Dynamixel motors using Protocol 1. Use 'Read' sequentially instead."
|
||||
)
|
||||
if instruction_name == "broadcast_ping" and self.protocol_version == 1:
|
||||
raise NotImplementedError(
|
||||
"'Broadcast Ping' is not available with Dynamixel motors using Protocol 1. Use 'Ping' sequentially instead."
|
||||
)
|
||||
|
||||
def _handshake(self) -> None:
|
||||
self._assert_motors_exist()
|
||||
@@ -261,6 +268,7 @@ class DynamixelMotorsBus(SerialMotorsBus):
|
||||
return data
|
||||
|
||||
def broadcast_ping(self, num_retry: int = 0, raise_on_error: bool = False) -> dict[int, int] | None:
|
||||
self._assert_protocol_is_compatible("broadcast_ping")
|
||||
for n_try in range(1 + num_retry):
|
||||
data_list, comm = self.packet_handler.broadcastPing(self.port_handler)
|
||||
if self._is_comm_success(comm):
|
||||
|
||||
Reference in New Issue
Block a user