mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-27 14:39:43 +00:00
wait for start button before teleop
This commit is contained in:
@@ -161,14 +161,13 @@ def init_rac_keyboard_listener():
|
|||||||
# During episode
|
# During episode
|
||||||
if key == keyboard.Key.space:
|
if key == keyboard.Key.space:
|
||||||
if not events["policy_paused"] and not events["correction_active"]:
|
if not events["policy_paused"] and not events["correction_active"]:
|
||||||
print("\n[RaC] ⏸ PAUSED - Policy stopped, teleop tracking robot")
|
print("\n[RaC] ⏸ PAUSED - Policy stopped, teleop moving to robot position")
|
||||||
print(" Press 'c' to take control and start correction")
|
print(" Press 'c' or START to take control")
|
||||||
events["policy_paused"] = True
|
events["policy_paused"] = True
|
||||||
elif hasattr(key, 'char') and key.char == 'c':
|
elif hasattr(key, 'char') and key.char == 'c':
|
||||||
if events["policy_paused"] and not events["correction_active"]:
|
if events["policy_paused"] and not events["correction_active"]:
|
||||||
print("\n[RaC] ▶ CORRECTION - You have control (recording)")
|
print("\n[RaC] ▶ START pressed - taking control")
|
||||||
print(" Teleoperate to correct, press → when done")
|
events["start_next_episode"] = True
|
||||||
events["correction_active"] = True
|
|
||||||
elif key == keyboard.Key.right:
|
elif key == keyboard.Key.right:
|
||||||
print("[RaC] → End episode")
|
print("[RaC] → End episode")
|
||||||
events["exit_early"] = True
|
events["exit_early"] = True
|
||||||
@@ -238,16 +237,15 @@ def start_pedal_listener(events: dict):
|
|||||||
print("\n[Pedal] → End episode")
|
print("\n[Pedal] → End episode")
|
||||||
events["exit_early"] = True
|
events["exit_early"] = True
|
||||||
elif not events["policy_paused"]:
|
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")
|
print(" Press left pedal to take control")
|
||||||
events["policy_paused"] = True
|
events["policy_paused"] = True
|
||||||
|
|
||||||
elif code == KEY_LEFT:
|
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"]:
|
if events["policy_paused"] and not events["correction_active"]:
|
||||||
print("\n[Pedal] ▶ CORRECTION - You have control (recording)")
|
print("\n[Pedal] ▶ START pressed - taking control")
|
||||||
print(" Press right pedal when done")
|
events["start_next_episode"] = True
|
||||||
events["correction_active"] = True
|
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logging.info(f"[Pedal] Device not found: {PEDAL_DEVICE}")
|
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")}
|
robot_pos = {k: v for k, v in obs.items() if k.endswith(".pos")}
|
||||||
print("[RaC] Moving teleop to robot position (2s smooth transition)...")
|
print("[RaC] Moving teleop to robot position (2s smooth transition)...")
|
||||||
teleop.smooth_move_to(robot_pos, duration_s=2.0, fps=50)
|
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
|
waiting_for_takeover = True
|
||||||
was_paused = True
|
was_paused = True
|
||||||
|
|
||||||
# Detect transition to correction mode
|
# Wait for start button before enabling correction mode
|
||||||
if events["correction_active"] and not was_correction_active:
|
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
|
waiting_for_takeover = False
|
||||||
was_correction_active = True
|
was_correction_active = True
|
||||||
|
|
||||||
|
|||||||
@@ -167,14 +167,13 @@ def init_rac_keyboard_listener():
|
|||||||
# During episode
|
# During episode
|
||||||
if key == keyboard.Key.space:
|
if key == keyboard.Key.space:
|
||||||
if not events["policy_paused"] and not events["correction_active"]:
|
if not events["policy_paused"] and not events["correction_active"]:
|
||||||
print("\n[RaC] ⏸ PAUSED - Policy stopped, teleop tracking robot")
|
print("\n[RaC] ⏸ PAUSED - Policy stopped, teleop moving to robot position")
|
||||||
print(" Press 'c' to take control and start correction")
|
print(" Press 'c' or START to take control")
|
||||||
events["policy_paused"] = True
|
events["policy_paused"] = True
|
||||||
elif hasattr(key, 'char') and key.char == 'c':
|
elif hasattr(key, 'char') and key.char == 'c':
|
||||||
if events["policy_paused"] and not events["correction_active"]:
|
if events["policy_paused"] and not events["correction_active"]:
|
||||||
print("\n[RaC] ▶ CORRECTION - You have control (recording)")
|
print("\n[RaC] ▶ START pressed - taking control")
|
||||||
print(" Teleoperate to correct, press → when done")
|
events["start_next_episode"] = True
|
||||||
events["correction_active"] = True
|
|
||||||
elif key == keyboard.Key.right:
|
elif key == keyboard.Key.right:
|
||||||
print("[RaC] → End episode")
|
print("[RaC] → End episode")
|
||||||
events["exit_early"] = True
|
events["exit_early"] = True
|
||||||
@@ -244,16 +243,15 @@ def start_pedal_listener(events: dict):
|
|||||||
print("\n[Pedal] → End episode")
|
print("\n[Pedal] → End episode")
|
||||||
events["exit_early"] = True
|
events["exit_early"] = True
|
||||||
elif not events["policy_paused"]:
|
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")
|
print(" Press left pedal to take control")
|
||||||
events["policy_paused"] = True
|
events["policy_paused"] = True
|
||||||
|
|
||||||
elif code == KEY_LEFT:
|
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"]:
|
if events["policy_paused"] and not events["correction_active"]:
|
||||||
print("\n[Pedal] ▶ CORRECTION - You have control (recording)")
|
print("\n[Pedal] ▶ START pressed - taking control")
|
||||||
print(" Press right pedal when done")
|
events["start_next_episode"] = True
|
||||||
events["correction_active"] = True
|
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logging.info(f"[Pedal] Device not found: {PEDAL_DEVICE}")
|
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")}
|
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)...")
|
print("[RaC] Moving teleop to robot position (2s smooth transition)...")
|
||||||
teleop.smooth_move_to(robot_pos, duration_s=2.0, fps=50)
|
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
|
waiting_for_takeover = True
|
||||||
was_paused = True
|
was_paused = True
|
||||||
|
|
||||||
# Detect transition to correction mode (disable torque for human control)
|
# Wait for start button before enabling correction mode
|
||||||
if events["correction_active"] and not was_correction_active:
|
if waiting_for_takeover and events["start_next_episode"]:
|
||||||
|
print("[RaC] Start pressed - enabling teleop control...")
|
||||||
teleop.disable_torque()
|
teleop.disable_torque()
|
||||||
|
events["start_next_episode"] = False
|
||||||
|
events["correction_active"] = True
|
||||||
waiting_for_takeover = False
|
waiting_for_takeover = False
|
||||||
was_correction_active = True
|
was_correction_active = True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user