From 4ca92a28e9df839b3c13bb2d1670791c20bc9737 Mon Sep 17 00:00:00 2001 From: Simon Alibert Date: Fri, 11 Apr 2025 11:02:54 +0200 Subject: [PATCH] Make feetech broadcast ping faster in protocol 1 --- lerobot/common/motors/feetech/feetech.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lerobot/common/motors/feetech/feetech.py b/lerobot/common/motors/feetech/feetech.py index a0796f9c6..a89f7fb91 100644 --- a/lerobot/common/motors/feetech/feetech.py +++ b/lerobot/common/motors/feetech/feetech.py @@ -186,7 +186,9 @@ class FeetechMotorsBus(MotorsBus): ] return data - def _broadcast_ping_p1(self, known_motors_only: bool = True, num_retry: int = 0) -> dict[int, int]: + def _broadcast_ping_p1( + self, known_motors_only: bool = True, n_motors: int | None = None, num_retry: int = 0 + ) -> dict[int, int]: if known_motors_only: ids = self.ids else: @@ -195,10 +197,14 @@ class FeetechMotorsBus(MotorsBus): ids = range(scs.MAX_ID + 1) ids_models = {} + motors_found = 0 for id_ in ids: model_number = self.ping(id_, num_retry) if model_number is not None: ids_models[id_] = model_number + motors_found += 1 + if motors_found >= n_motors: + break return ids_models