From d3b4130dc60eeeb4e076b52717eb468223b503a5 Mon Sep 17 00:00:00 2001 From: Maximellerbach Date: Thu, 4 Jun 2026 16:23:05 +0200 Subject: [PATCH] adding reset to initial position --- src/lerobot/rollout/configs.py | 8 ++++++++ src/lerobot/rollout/strategies/legacy.py | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/lerobot/rollout/configs.py b/src/lerobot/rollout/configs.py index 7d131d4bb..a008165b4 100644 --- a/src/lerobot/rollout/configs.py +++ b/src/lerobot/rollout/configs.py @@ -133,8 +133,16 @@ class LegacyStrategyConfig(RolloutStrategyConfig): Right arrow — end episode early Left arrow — discard current episode and re-record Escape — stop recording session + + In between episodes: + - if there is no teleop leader, the robot is held at its initial joint positions captured at startup. + - else, the robot is moved smoothly to the position of the teleop leader. """ + # This only applies if there are no teleop leaders specified. + # When True (default), moves the robot back to the joint positions captured at startup. + # Otherwise, leave the robot in its current position. + reset_to_initial_position: bool = True pass diff --git a/src/lerobot/rollout/strategies/legacy.py b/src/lerobot/rollout/strategies/legacy.py index 69d719e00..20be321ed 100644 --- a/src/lerobot/rollout/strategies/legacy.py +++ b/src/lerobot/rollout/strategies/legacy.py @@ -57,7 +57,7 @@ class LegacyStrategy(RolloutStrategy): seconds, recording every frame. A reset phase of ``dataset.reset_time_s`` follows every episode (except the last) so the operator can manually reset the environment. During the reset phase, an optional teleoperator - drives the robot; if none is present the robot holds its position. + drives the robot; if none is present the robot returns to its initial joint positions captured at startup. The policy state (hidden state, RTC queue, interpolator) is reset at the start of each recording episode. @@ -133,6 +133,11 @@ class LegacyStrategy(RolloutStrategy): recorded_episodes < num_episodes - 1 or events["rerecord_episode"] ): log_say("Reset the environment", play_sounds) + + # returns to its initial joint positions captured at startup during the reset phase + if not teleop and self.config.reset_to_initial_position: + self._return_to_initial_position(hw=ctx.hardware) + self._reset_loop( ctx=ctx, robot=robot, @@ -149,6 +154,11 @@ class LegacyStrategy(RolloutStrategy): events["rerecord_episode"] = False events["exit_early"] = False dataset.clear_episode_buffer() + + # returns to its initial joint positions captured at startup + if not teleop and self.config.reset_to_initial_position: + self._return_to_initial_position(hw=ctx.hardware) + continue dataset.save_episode()