From 4499519dbf485eeab037220d8af486909754aca0 Mon Sep 17 00:00:00 2001 From: Steven Palma Date: Wed, 22 Apr 2026 16:37:19 +0200 Subject: [PATCH] chore(rollout): address coments + minor improvements --- docs/source/hil_data_collection.mdx | 4 ++-- docs/source/inference.mdx | 8 ++++---- src/lerobot/rollout/configs.py | 10 +++++----- src/lerobot/rollout/context.py | 5 +++-- src/lerobot/rollout/inference/factory.py | 8 ++++---- src/lerobot/rollout/strategies/base.py | 2 +- src/lerobot/rollout/strategies/dagger.py | 4 ++-- src/lerobot/rollout/strategies/highlight.py | 9 +++------ src/lerobot/rollout/strategies/sentry.py | 2 +- src/lerobot/scripts/lerobot_rollout.py | 10 +++++----- 10 files changed, 30 insertions(+), 32 deletions(-) diff --git a/docs/source/hil_data_collection.mdx b/docs/source/hil_data_collection.mdx index 465ef045d..ba68959d1 100644 --- a/docs/source/hil_data_collection.mdx +++ b/docs/source/hil_data_collection.mdx @@ -108,7 +108,7 @@ lerobot-rollout --strategy.type=dagger \ --teleop.port_left=/dev/ttyACM0 \ --teleop.port_right=/dev/ttyACM1 \ --policy.path=outputs/pretrain/checkpoints/last/pretrained_model \ - --dataset.repo_id=your-username/hil-dataset \ + --dataset.repo_id=your-username/rollout_hil_dataset \ --dataset.single_task="Fold the T-shirt properly" \ --dataset.fps=30 \ --strategy.num_episodes=50 \ @@ -135,7 +135,7 @@ lerobot-rollout --strategy.type=dagger \ --teleop.port_left=/dev/ttyACM0 \ --teleop.port_right=/dev/ttyACM1 \ --policy.path=outputs/pretrain/checkpoints/last/pretrained_model \ - --dataset.repo_id=your-username/hil-rtc-dataset \ + --dataset.repo_id=your-username/rollout_hil_rtc_dataset \ --dataset.single_task="Fold the T-shirt properly" \ --dataset.fps=30 \ --strategy.num_episodes=50 \ diff --git a/docs/source/inference.mdx b/docs/source/inference.mdx index c849f4c4e..b2874d823 100644 --- a/docs/source/inference.mdx +++ b/docs/source/inference.mdx @@ -59,7 +59,7 @@ lerobot-rollout \ --robot.type=so100_follower \ --robot.port=/dev/ttyACM0 \ --robot.cameras="{ front: {type: opencv, index_or_path: 0, width: 640, height: 480, fps: 30}}" \ - --dataset.repo_id=${HF_USER}/eval_data \ + --dataset.repo_id=${HF_USER}/rollout_eval_data \ --dataset.single_task="Put lego brick into the box" \ --duration=3600 ``` @@ -84,7 +84,7 @@ lerobot-rollout \ --policy.path=${HF_USER}/my_policy \ --robot.type=koch_follower \ --robot.port=/dev/ttyACM0 \ - --dataset.repo_id=${HF_USER}/highlight_data \ + --dataset.repo_id=${HF_USER}/rollout_highlight_data \ --dataset.single_task="Pick up the red cube" ``` @@ -118,7 +118,7 @@ lerobot-rollout \ --policy.path=outputs/pretrain/checkpoints/last/pretrained_model \ --robot.type=bi_openarm_follower \ --teleop.type=openarm_mini \ - --dataset.repo_id=${HF_USER}/hil_data \ + --dataset.repo_id=${HF_USER}/rollout_hil_data \ --dataset.single_task="Fold the T-shirt" ``` @@ -134,7 +134,7 @@ lerobot-rollout \ --robot.port=/dev/ttyACM0 \ --teleop.type=so101_leader \ --teleop.port=/dev/ttyACM1 \ - --dataset.repo_id=${HF_USER}/dagger_data \ + --dataset.repo_id=${HF_USER}/rollout_dagger_data \ --dataset.single_task="Grasp the block" ``` diff --git a/src/lerobot/rollout/configs.py b/src/lerobot/rollout/configs.py index f841cc040..14b0c1864 100644 --- a/src/lerobot/rollout/configs.py +++ b/src/lerobot/rollout/configs.py @@ -136,11 +136,11 @@ class DAggerStrategyConfig(RolloutStrategyConfig): 2. **correction** — toggle human correction recording. 3. **upload** — push dataset to hub on demand (corrections-only mode). - When ``record_autonomous=True`` (default) both autonomous and correction - frames are recorded with size-based episode rotation (same as Sentry) - and background uploading. ``push_to_hub`` is blocked while a correction - is in progress. Set to ``False`` to record only the human-correction - windows, where each correction becomes its own episode. + When ``record_autonomous=False`` (default) only human-correction windows + are recorded — each correction becomes its own episode. Set to ``True`` + to record both autonomous and correction frames with size-based episode + rotation (same as Sentry) and background uploading. ``push_to_hub`` is + blocked while a correction is in progress. """ # Number of correction episodes to collect (corrections-only mode). diff --git a/src/lerobot/rollout/context.py b/src/lerobot/rollout/context.py index a3bb0cb6f..d36429dae 100644 --- a/src/lerobot/rollout/context.py +++ b/src/lerobot/rollout/context.py @@ -346,10 +346,11 @@ def build_rollout_context( "names": None, } - if not cfg.dataset.repo_id.startswith("rollout_"): + repo_name = cfg.dataset.repo_id.split("/", 1)[-1] + if not repo_name.startswith("rollout_"): raise ValueError( "Dataset names for rollout must start with 'rollout_'. " - "Use --dataset.repo_id=rollout_ for policy deployment datasets." + "Use --dataset.repo_id=/rollout_ for policy deployment datasets." ) cfg.dataset.stamp_repo_id() dataset = LeRobotDataset.create( diff --git a/src/lerobot/rollout/inference/factory.py b/src/lerobot/rollout/inference/factory.py index 761310128..66aa411fa 100644 --- a/src/lerobot/rollout/inference/factory.py +++ b/src/lerobot/rollout/inference/factory.py @@ -68,10 +68,10 @@ class SyncInferenceConfig(InferenceEngineConfig): class RTCInferenceConfig(InferenceEngineConfig): """Real-Time Chunking: async policy inference in a background thread.""" - # ``RTCConfig`` is a small dataclass with default-only fields, so eagerly - # constructing one here costs nothing and keeps draccus' CLI surface flat - # (``--inference.rtc.execution_horizon=...`` etc.). No need to lazy-init. - rtc: RTCConfig = field(default_factory=RTCConfig) + # Selecting ``--inference.type=rtc`` means the user wants RTC, so + # ``enabled`` defaults to True here (unlike the policy-side RTCConfig + # which defaults to False for the ``rtc_config: RTCConfig | None`` path). + rtc: RTCConfig = field(default_factory=lambda: RTCConfig(enabled=True)) queue_threshold: int = 30 diff --git a/src/lerobot/rollout/strategies/base.py b/src/lerobot/rollout/strategies/base.py index 10871c424..77632b615 100644 --- a/src/lerobot/rollout/strategies/base.py +++ b/src/lerobot/rollout/strategies/base.py @@ -73,7 +73,7 @@ class BaseStrategy(RolloutStrategy): if (sleep_t := control_interval - dt) > 0: precise_sleep(sleep_t) else: - logging.warning( + logger.warning( f"Record loop is running slower ({1 / dt:.1f} Hz) than the target FPS ({cfg.fps} Hz). Dataset frames might be dropped and robot control might be unstable. Common causes are: 1) Camera FPS not keeping up 2) Policy inference taking too long 3) CPU starvation" ) diff --git a/src/lerobot/rollout/strategies/dagger.py b/src/lerobot/rollout/strategies/dagger.py index d9de631c5..b56478045 100644 --- a/src/lerobot/rollout/strategies/dagger.py +++ b/src/lerobot/rollout/strategies/dagger.py @@ -509,7 +509,7 @@ class DAggerStrategy(RolloutStrategy): if (sleep_t := control_interval - dt) > 0: precise_sleep(sleep_t) else: - logging.warning( + logger.warning( f"Record loop is running slower ({1 / dt:.1f} Hz) than the target FPS ({cfg.fps} Hz). Dataset frames might be dropped and robot control might be unstable. Common causes are: 1) Camera FPS not keeping up 2) Policy inference taking too long 3) CPU starvation" ) @@ -653,7 +653,7 @@ class DAggerStrategy(RolloutStrategy): if (sleep_t := control_interval - dt) > 0: precise_sleep(sleep_t) else: - logging.warning( + logger.warning( f"Record loop is running slower ({1 / dt:.1f} Hz) than the target FPS ({cfg.fps} Hz). Dataset frames might be dropped and robot control might be unstable. Common causes are: 1) Camera FPS not keeping up 2) Policy inference taking too long 3) CPU starvation" ) diff --git a/src/lerobot/rollout/strategies/highlight.py b/src/lerobot/rollout/strategies/highlight.py index 734f17005..a221de461 100644 --- a/src/lerobot/rollout/strategies/highlight.py +++ b/src/lerobot/rollout/strategies/highlight.py @@ -152,11 +152,7 @@ class HighlightStrategy(RolloutStrategy): # NOTE: ``is_set()`` then ``clear()`` is not atomic # against the keyboard thread setting the flag again # in between — but that is benign: we lose at most one - # toggle, processed on the next iteration. The - # ``_recording_live`` branch below is reached in the - # SAME iteration after ``clear()`` runs, so a frame - # finalised by ``save_episode()`` is never re-added to - # the next episode. + # toggle, processed on the next iteration. if self._save_requested.is_set(): self._save_requested.clear() if not self._recording_live.is_set(): @@ -177,6 +173,7 @@ class HighlightStrategy(RolloutStrategy): play_sounds, ) self._recording_live.clear() + continue # frame already consumed — skip ring.append if self._push_requested.is_set(): self._push_requested.clear() @@ -192,7 +189,7 @@ class HighlightStrategy(RolloutStrategy): if (sleep_t := control_interval - dt) > 0: precise_sleep(sleep_t) else: - logging.warning( + logger.warning( f"Record loop is running slower ({1 / dt:.1f} Hz) than the target FPS ({cfg.fps} Hz). Dataset frames might be dropped and robot control might be unstable. Common causes are: 1) Camera FPS not keeping up 2) Policy inference taking too long 3) CPU starvation" ) diff --git a/src/lerobot/rollout/strategies/sentry.py b/src/lerobot/rollout/strategies/sentry.py index 3a56e8163..4c0ec8af3 100644 --- a/src/lerobot/rollout/strategies/sentry.py +++ b/src/lerobot/rollout/strategies/sentry.py @@ -161,7 +161,7 @@ class SentryStrategy(RolloutStrategy): if (sleep_t := control_interval - dt) > 0: precise_sleep(sleep_t) else: - logging.warning( + logger.warning( f"Record loop is running slower ({1 / dt:.1f} Hz) than the target FPS ({cfg.fps} Hz). Dataset frames might be dropped and robot control might be unstable. Common causes are: 1) Camera FPS not keeping up 2) Policy inference taking too long 3) CPU starvation" ) diff --git a/src/lerobot/scripts/lerobot_rollout.py b/src/lerobot/scripts/lerobot_rollout.py index fe221047d..6a81563ee 100644 --- a/src/lerobot/scripts/lerobot_rollout.py +++ b/src/lerobot/scripts/lerobot_rollout.py @@ -63,7 +63,7 @@ Usage examples --inference.type=rtc \\ --robot.type=so100_follower \\ --robot.port=/dev/ttyACM0 \\ - --dataset.repo_id=user/sentry-data \\ + --dataset.repo_id=user/rollout_sentry_data \\ --dataset.single_task="patrol" --duration=3600 # Highlight mode — ring buffer, press 's' to save, 'h' to push @@ -73,7 +73,7 @@ Usage examples --policy.path=lerobot/act_koch_real \\ --robot.type=koch_follower \\ --robot.port=/dev/ttyACM0 \\ - --dataset.repo_id=user/highlight-data \\ + --dataset.repo_id=user/rollout_highlight_data \\ --dataset.single_task="pick up cube" # DAgger mode — human-in-the-loop corrections only @@ -83,7 +83,7 @@ Usage examples --policy.path=outputs/pretrain/checkpoints/last/pretrained_model \\ --robot.type=bi_openarm_follower \\ --teleop.type=openarm_mini \\ - --dataset.repo_id=user/hil-data \\ + --dataset.repo_id=user/rollout_hil_data \\ --dataset.single_task="Fold the T-shirt" # DAgger mode — continuous recording with RTC inference @@ -98,7 +98,7 @@ Usage examples --robot.port=/dev/ttyACM0 \\ --teleop.type=so101_leader \\ --teleop.port=/dev/ttyACM1 \\ - --dataset.repo_id=user/dagger-rtc-data \\ + --dataset.repo_id=user/rollout_dagger_rtc_data \\ --dataset.single_task="Grasp the block" # With Rerun visualization and torch.compile @@ -117,7 +117,7 @@ Usage examples --policy.path=user/my_policy \\ --robot.type=so100_follower \\ --robot.port=/dev/ttyACM0 \\ - --dataset.repo_id=user/sentry-data \\ + --dataset.repo_id=user/rollout_sentry_data \\ --dataset.single_task="patrol" \\ --resume=true """