From 5a1527d8683fff22dc7fbf3bcb22cbc3fe148ac1 Mon Sep 17 00:00:00 2001 From: CarolinePascal Date: Sun, 5 Jul 2026 17:12:21 +0200 Subject: [PATCH] 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. --- src/lerobot/motors/dynamixel/dynamixel.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lerobot/motors/dynamixel/dynamixel.py b/src/lerobot/motors/dynamixel/dynamixel.py index 0365e42c3..197332144 100644 --- a/src/lerobot/motors/dynamixel/dynamixel.py +++ b/src/lerobot/motors/dynamixel/dynamixel.py @@ -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):