From 7845ee6f80141a7fb74bfade361da5362aeb524d Mon Sep 17 00:00:00 2001 From: Maxime Ellerbach Date: Tue, 21 Jul 2026 08:36:09 +0000 Subject: [PATCH] trying to avoid slam on startup --- src/lerobot/policies/rtc/action_queue.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lerobot/policies/rtc/action_queue.py b/src/lerobot/policies/rtc/action_queue.py index 199257b12..4c6c58297 100644 --- a/src/lerobot/policies/rtc/action_queue.py +++ b/src/lerobot/policies/rtc/action_queue.py @@ -236,11 +236,21 @@ class ActionQueue: if action_index_before_inference is not None: indexes_diff = max(0, self.last_index - action_index_before_inference) if indexes_diff != real_delay: + # The latency estimate (`real_delay`) and the number of actions the robot + # actually consumed during inference (`indexes_diff`) disagree. This happens + # when the queue starved (robot idle) or on the first chunk (nothing consumed + # yet). Discarding `real_delay` here would drop actions the arm never executed + # and splice the queue `real_delay` steps ahead of the physical pose — a hard + # jump/slam, worst on slow policies where `real_delay` is large. Never discard + # more than was actually consumed. + resolved = min(real_delay, indexes_diff) logger.warning( - "Indexes diff is not equal to real delay. indexes_diff=%d, real_delay=%d", + "Indexes diff != real delay (indexes_diff=%d, real_delay=%d); " + "clamping discard to %d to avoid a queue-splice jump.", indexes_diff, real_delay, + resolved, ) - return real_delay + return resolved return effective_delay