人在回路(HIL)数据采集让你可以通过在真实机器人上部署已训练的 policy 来改进它,同时由人类操作员进行监控并在需要时进行干预。干预数据(恢复 action 和纠错)会与自主运行片段一起被记录,从而生成更丰富的训练 dataset,教会 policy 如何处理失败。
标准的行为克隆只基于成功的 demonstration 训练 policy。在部署过程中,小错误可能会累积,将机器人推入训练时从未见过的 state(分布偏移)。HIL 数据采集通过以下方式解决这一问题:
这会产生一个不仅知道如何执行任务,还知道出错时如何恢复的 policy。
在 HIL 会话期间,人类操作员在每个 episode 内遵循以下循环:
自主运行和人工控制的片段都会被记录。在单个 episode 内,policy 和人类可以多次交替控制,每次交接后 episode 都会从当前 state 继续(不会因为发生过干预而需要重置)。这样可以在一条连续的轨迹中同时捕获自主执行、恢复和纠错。采集完成后,合并的 dataset(原始 demonstration + HIL 数据)将用于 fine-tune policy。
这一过程可以迭代重复:部署、采集、fine-tune、重复。每一轮都针对当前 policy 的失效模式。
┌─────────────────────────────────────────────────────────────────────────┐
│ Policy v0 (trained on demos) │
│ ↓ │
│ HIL Collection (target current failure modes) → Fine-tune → Policy v1 │
│ ↓ │
│ HIL Collection (target new failure modes) → Fine-tune → Policy v2 │
│ ↓ │
│ ... (repeat until satisfactory performance) │
└─────────────────────────────────────────────────────────────────────────┘lerobot-rollout --strategy.type=dagger 模式需要带有主动电机的 teleoperator,其必须能够:
兼容的 teleoperator:
bi_openarm_mini - 双臂 OpenArm Miniso_leader - SO100 / SO101 leader armbi_so_leader - 双臂 SO100 / SO101 leader arm提供的命令默认使用
bi_openarm_follower+bi_openarm_mini。so_follower+so_leader配置也已注册,可通过 CLI 标志使用。
使用 lerobot-rollout 搭配 --strategy.type=dagger 进行 HIL 数据采集。通过 --inference.type=sync|rtc 选择 inference backend:
| 模式 | 标志 | 模型 |
|---|---|---|
| 标准(默认) | (无需标志) | ACT, Diffusion Policy |
| 实时分块(RTC) | --inference.type=rtc | Pi0, Pi0.5, SmolVLA |
首先,在 demonstration dataset 上训练一个 policy:
python src/lerobot/scripts/lerobot_train.py \
--dataset.repo_id=your-username/demo-dataset \
--policy.type=pi0 \
--output_dir=outputs/pretrain \
--batch_size=32 \
--steps=50000标准 inference(ACT、Diffusion Policy):
lerobot-rollout --strategy.type=dagger \
--robot.type=bi_openarm_follower \
--robot.left_arm_config.port=can1 \
--robot.left_arm_config.side=left \
--robot.right_arm_config.port=can0 \
--robot.right_arm_config.side=right \
--robot.cameras='{left_wrist: {type: opencv, index_or_path: "/dev/video0", width: 1280, height: 720, fps: 30}, right_wrist: {type: opencv, index_or_path: "/dev/video4", width: 1280, height: 720, fps: 30}, base: {type: opencv, index_or_path: "/dev/video2", width: 640, height: 480, fps: 30}}' \
--teleop.type=bi_openarm_mini \
--teleop.left_arm_config.port=/dev/ttyACM0 \
--teleop.right_arm_config.port=/dev/ttyACM1 \
--policy.path=outputs/pretrain/checkpoints/last/pretrained_model \
--dataset.repo_id=your-username/rollout_hil_dataset \
--dataset.single_task="Fold the T-shirt properly" \
--dataset.fps=30 \
--strategy.num_episodes=50 \
--interpolation_multiplier=2使用 --interpolation_multiplier=N 时,机器人对每个 policy action 接收 N 个插值命令(控制以 fps × N Hz 运行),而 policy inference 和 dataset 录制保持在 --fps,因此录制的 dataset 与其声明的 FPS 相符。
对大型模型使用 RTC(Pi0、Pi0.5、SmolVLA):
对于 inference latency 较高的模型,启用 RTC 以获得流畅执行:
lerobot-rollout --strategy.type=dagger \
--inference.type=rtc \
--inference.rtc.execution_horizon=20 \
--inference.rtc.max_guidance_weight=5.0 \
--inference.rtc.prefix_attention_schedule=LINEAR \
--robot.type=bi_openarm_follower \
--robot.left_arm_config.port=can1 \
--robot.left_arm_config.side=left \
--robot.right_arm_config.port=can0 \
--robot.right_arm_config.side=right \
--robot.cameras='{left_wrist: {type: opencv, index_or_path: "/dev/video0", width: 1280, height: 720, fps: 30}, right_wrist: {type: opencv, index_or_path: "/dev/video4", width: 1280, height: 720, fps: 30}, base: {type: opencv, index_or_path: "/dev/video2", width: 640, height: 480, fps: 30}}' \
--teleop.type=bi_openarm_mini \
--teleop.left_arm_config.port=/dev/ttyACM0 \
--teleop.right_arm_config.port=/dev/ttyACM1 \
--policy.path=outputs/pretrain/checkpoints/last/pretrained_model \
--dataset.repo_id=your-username/rollout_hil_rtc_dataset \
--dataset.single_task="Fold the T-shirt properly" \
--dataset.fps=30 \
--strategy.num_episodes=50 \
--interpolation_multiplier=3控制方式(概念性描述):
交互模型如下:
不同的脚本和硬件集成中,具体的按键/踏板绑定可能有所不同。请以各个脚本打印出来的控制说明为准,来确定你的环境中的具体映射。
HIL 协议:
脚踏板设置(Linux):
如果使用 USB 脚踏板(PCsensor FootSwitch),请确保其访问权限:
sudo setfacl -m u:$USER:rw /dev/input/by-id/usb-PCsensor_FootSwitch-event-kbd在合并的 dataset 上 fine-tune(将 demo-dataset 和 hil-dataset 合并在一起):
python src/lerobot/scripts/lerobot_train.py \
--dataset.repo_id=your-username/hil-dataset \
--policy.type=pi0 \
--policy.pretrained_path=outputs/pretrain/checkpoints/last/pretrained_model \
--output_dir=outputs/hil_finetune \
--steps=20000然后部署 fine-tune 后的 policy,并从第 2 步开始重复,以针对其剩余的失效模式。
在出现以下情况时进行干预:
在恢复期间,将机器人 teleoperation 回满足以下条件的 state:
在纠错过程中:
这种 HIL 数据采集方法建立在交互式模仿学习的思想之上:
DAgger(Ross 等人,2011)引入了核心思想:不仅仅在专家 demonstration 上训练,还在学习者访问过的 state 上向专家请求纠错。通过迭代采集在 policy 数据,打破了标准行为克隆的误差累积循环。
HG-DAgger(Kelly 等人,2019)将其应用于机器人领域:由人类专家监控机器人,仅在需要时干预,而不是对每个 state 进行标注。自主控制与人工控制之间的切换,正是这里脚本所使用的暂停 → 接管 → 交还 policy 的循环。
RaC(Hu 等人,2025)通过将干预明确分解为恢复(teleoperation 回到良好 state)和纠错(从中 demonstration 正确的行为),将此循环扩展到长时程任务。这种分解正是 lerobot-rollout 中 DAgger policy 遵循的协议。
π0.6/RECAP(Physical Intelligence,2025)使用 VLA 模型大规模应用同样的迭代采集-fine-tune 循环,表明即使是大型预训练 policy,也能从针对其自身失效模式的人工纠错中显著受益。π0.6 就是使用 RECAP 训练的。
@article{ross2011dagger,
title={A Reduction of Imitation Learning and Structured Prediction to No-Regret Online Learning},
author={Ross, Stéphane and Gordon, Geoffrey and Bagnell, Drew},
journal={Proceedings of the Fourteenth International Conference on Artificial Intelligence and Statistics},
year={2011}
}
@article{kelly2019hgdagger,
title={HG-DAgger: Interactive Imitation Learning with Human Experts},
author={Kelly, Michael and Sidrane, Chelsea and Driggs-Campbell, Katherine and Kochenderfer, Mykel J},
journal={arXiv preprint arXiv:1810.02890},
year={2019}
}
@article{hu2025rac,
title={RaC: Robot Learning for Long-Horizon Tasks by Scaling Recovery and Correction},
author={Hu, Zheyuan and Wu, Robyn and Enock, Naveen and Li, Jasmine and Kadakia, Riya and Erickson, Zackory and Kumar, Aviral},
journal={arXiv preprint arXiv:2509.07953},
year={2025}
}
@article{pi2025recap,
title={π0.6: a VLA That Learns From Experience},
author={Physical Intelligence},
year={2025}
}