From bbeacfe57d0db2dc08a009d3e474a741c65adc00 Mon Sep 17 00:00:00 2001 From: Steven Palma Date: Mon, 27 Jul 2026 14:09:58 +0200 Subject: [PATCH] fix(record): connect teleoperator before robot to avoid watchdog jump (#4166) * fix(record): connect teleoperator before robot to avoid watchdog jump lerobot-record connected the robot before the teleoperator. A robot's connect()/reset() can leave it holding a default pose under a firmware watchdog (e.g. Unitree G1); if teleop.connect() (model loading, IK init, network setup) then takes longer than that watchdog, the joints drop to damping and the first send_action() makes the robot jump. Swap the order so the teleoperator connects first, matching the ordering already used in lerobot_teleoperate.py. Pure ordering fix, no API change. Fixes #3684 * fix(record): trim comment and add connect-order regression test Address review feedback on #3684: - Trim the verbose ordering comment down to two lines. - Add test_record_connects_teleop_before_robot to tests/test_control_robot.py, asserting teleop.connect() runs before robot.connect() in record(). * chore(test): remove test --------- Co-authored-by: Jaimin Patel Co-authored-by: Martino Russi <77496684+nepyope@users.noreply.github.com> --- src/lerobot/scripts/lerobot_record.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lerobot/scripts/lerobot_record.py b/src/lerobot/scripts/lerobot_record.py index 4233f0bc2..532a8c602 100644 --- a/src/lerobot/scripts/lerobot_record.py +++ b/src/lerobot/scripts/lerobot_record.py @@ -453,9 +453,11 @@ def record( encoder_queue_maxsize=cfg.dataset.encoder_queue_maxsize, ) - robot.connect() + # Connect the teleoperator before the robot so the robot isn't left idle (and possibly + # tripping a firmware watchdog) during teleop init. Matches lerobot_teleoperate.py. if teleop is not None: teleop.connect() + robot.connect() listener, events = init_keyboard_listener()