From 464b65cfb0c4f023560f629fbfd159400d43d9ca Mon Sep 17 00:00:00 2001 From: Pepijn Date: Fri, 2 Jan 2026 13:05:00 +0100 Subject: [PATCH] wait for start button before teleop --- examples/rac/rac_data_collection.py | 28 +++++++++++--------- examples/rac/rac_data_collection_openarms.py | 28 +++++++++++--------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/examples/rac/rac_data_collection.py b/examples/rac/rac_data_collection.py index 7b2c62e4a..17a9f7890 100644 --- a/examples/rac/rac_data_collection.py +++ b/examples/rac/rac_data_collection.py @@ -161,14 +161,13 @@ def init_rac_keyboard_listener(): # During episode if key == keyboard.Key.space: if not events["policy_paused"] and not events["correction_active"]: - print("\n[RaC] ⏸ PAUSED - Policy stopped, teleop tracking robot") - print(" Press 'c' to take control and start correction") + print("\n[RaC] ⏸ PAUSED - Policy stopped, teleop moving to robot position") + print(" Press 'c' or START to take control") events["policy_paused"] = True elif hasattr(key, 'char') and key.char == 'c': if events["policy_paused"] and not events["correction_active"]: - print("\n[RaC] ▶ CORRECTION - You have control (recording)") - print(" Teleoperate to correct, press → when done") - events["correction_active"] = True + print("\n[RaC] ▶ START pressed - taking control") + events["start_next_episode"] = True elif key == keyboard.Key.right: print("[RaC] → End episode") events["exit_early"] = True @@ -238,16 +237,15 @@ def start_pedal_listener(events: dict): print("\n[Pedal] → End episode") events["exit_early"] = True elif not events["policy_paused"]: - print("\n[Pedal] ⏸ PAUSED - Policy stopped, teleop tracking robot") + print("\n[Pedal] ⏸ PAUSED - Policy stopped, teleop moving to robot") print(" Press left pedal to take control") events["policy_paused"] = True elif code == KEY_LEFT: - # Left pedal: 'c' (take control) when paused + # Left pedal: START (take control) when paused if events["policy_paused"] and not events["correction_active"]: - print("\n[Pedal] ▶ CORRECTION - You have control (recording)") - print(" Press right pedal when done") - events["correction_active"] = True + print("\n[Pedal] ▶ START pressed - taking control") + events["start_next_episode"] = True except FileNotFoundError: logging.info(f"[Pedal] Device not found: {PEDAL_DEVICE}") @@ -353,12 +351,16 @@ def rac_rollout_loop( robot_pos = {k: v for k, v in obs.items() if k.endswith(".pos")} print("[RaC] Moving teleop to robot position (2s smooth transition)...") teleop.smooth_move_to(robot_pos, duration_s=2.0, fps=50) - print("[RaC] Teleop aligned. Press 'c' to take control.") + print("[RaC] Teleop aligned. Press START to take control.") + events["start_next_episode"] = False waiting_for_takeover = True was_paused = True - # Detect transition to correction mode - if events["correction_active"] and not was_correction_active: + # Wait for start button before enabling correction mode + if waiting_for_takeover and events["start_next_episode"]: + print("[RaC] Start pressed - enabling teleop control...") + events["start_next_episode"] = False + events["correction_active"] = True waiting_for_takeover = False was_correction_active = True diff --git a/examples/rac/rac_data_collection_openarms.py b/examples/rac/rac_data_collection_openarms.py index f9c1c17f7..bda118c26 100644 --- a/examples/rac/rac_data_collection_openarms.py +++ b/examples/rac/rac_data_collection_openarms.py @@ -167,14 +167,13 @@ def init_rac_keyboard_listener(): # During episode if key == keyboard.Key.space: if not events["policy_paused"] and not events["correction_active"]: - print("\n[RaC] ⏸ PAUSED - Policy stopped, teleop tracking robot") - print(" Press 'c' to take control and start correction") + print("\n[RaC] ⏸ PAUSED - Policy stopped, teleop moving to robot position") + print(" Press 'c' or START to take control") events["policy_paused"] = True elif hasattr(key, 'char') and key.char == 'c': if events["policy_paused"] and not events["correction_active"]: - print("\n[RaC] ▶ CORRECTION - You have control (recording)") - print(" Teleoperate to correct, press → when done") - events["correction_active"] = True + print("\n[RaC] ▶ START pressed - taking control") + events["start_next_episode"] = True elif key == keyboard.Key.right: print("[RaC] → End episode") events["exit_early"] = True @@ -244,16 +243,15 @@ def start_pedal_listener(events: dict): print("\n[Pedal] → End episode") events["exit_early"] = True elif not events["policy_paused"]: - print("\n[Pedal] ⏸ PAUSED - Policy stopped, teleop tracking robot") + print("\n[Pedal] ⏸ PAUSED - Policy stopped, teleop moving to robot") print(" Press left pedal to take control") events["policy_paused"] = True elif code == KEY_LEFT: - # Left pedal: 'c' (take control) when paused + # Left pedal: START (take control) when paused if events["policy_paused"] and not events["correction_active"]: - print("\n[Pedal] ▶ CORRECTION - You have control (recording)") - print(" Press right pedal when done") - events["correction_active"] = True + print("\n[Pedal] ▶ START pressed - taking control") + events["start_next_episode"] = True except FileNotFoundError: logging.info(f"[Pedal] Device not found: {PEDAL_DEVICE}") @@ -365,13 +363,17 @@ def rac_rollout_loop( robot_pos = {k: v for k, v in obs_filtered.items() if k.endswith(".pos")} print("[RaC] Moving teleop to robot position (2s smooth transition)...") teleop.smooth_move_to(robot_pos, duration_s=2.0, fps=50) - print("[RaC] Teleop aligned. Press 'c' to take control.") + print("[RaC] Teleop aligned. Press START to take control.") + events["start_next_episode"] = False waiting_for_takeover = True was_paused = True - # Detect transition to correction mode (disable torque for human control) - if events["correction_active"] and not was_correction_active: + # Wait for start button before enabling correction mode + if waiting_for_takeover and events["start_next_episode"]: + print("[RaC] Start pressed - enabling teleop control...") teleop.disable_torque() + events["start_next_episode"] = False + events["correction_active"] = True waiting_for_takeover = False was_correction_active = True