Skip to content

Commit

Permalink
Remove display cameras and control sounds options. This will be contr…
Browse files Browse the repository at this point in the history
…olled from the browser ui
  • Loading branch information
jackvial committed Dec 27, 2024
1 parent d614611 commit b636718
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 46 deletions.
25 changes: 4 additions & 21 deletions lerobot/common/robot_devices/control_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from lerobot.common.robot_devices.robots.utils import Robot
from lerobot.common.robot_devices.utils import busy_wait
from lerobot.common.robot_devices.control_utils import log_control_info
from lerobot.common.utils.utils import log_say


class ControlPhase:
Expand All @@ -25,8 +24,6 @@ class ControlPhase:

@dataclass
class ControlContextConfig:
display_cameras: bool = False
play_sounds: bool = True
assign_rewards: bool = False
control_phase: str = ControlPhase.TELEOPERATE
num_episodes: int = 0
Expand Down Expand Up @@ -115,16 +112,8 @@ def _handle_browser_events(self):

def update_config(self, config: ControlContextConfig):
"""Update configuration and reinitialize UI components as needed"""
old_display_setting = self.config.display_cameras
self.config = config

# If display setting changed, reinitialize display
if old_display_setting != self.config.display_cameras:
self._initialize_display()

# Force screen recreation on next render
self.screen = None

# Update ZMQ message with new config
self._publish_config_update()

Expand All @@ -133,11 +122,9 @@ def update_config(self, config: ControlContextConfig):
def _publish_config_update(self):
"""Publish configuration update to ZMQ subscribers"""
config_data = {
"display_cameras": self.config.display_cameras,
"play_sounds": self.config.play_sounds,
"assign_rewards": self.config.assign_rewards,
"control_phase": self.config.control_phase,
"num_episodes": self.config.num_episodes - 1,
"num_episodes": self.config.num_episodes,
"current_episode": self.current_episode_index,
}

Expand Down Expand Up @@ -189,11 +176,9 @@ def _publish_observations(self, observation: Dict[str, np.ndarray], log_items: l

# Include current configuration in observation update
config_data = {
"display_cameras": self.config.display_cameras,
"play_sounds": self.config.play_sounds,
"assign_rewards": self.config.assign_rewards,
"control_phase": self.config.control_phase,
"num_episodes": self.config.num_episodes - 1,
"num_episodes": self.config.num_episodes,
"current_episode": self.current_episode_index,
}

Expand Down Expand Up @@ -228,10 +213,8 @@ def log_control_info(self, start_loop_t):

return log_items

def log_say(self, message, blocking=False):
if self.config.play_sounds:
self._publish_log_say(message)
log_say(message, blocking)
def log_say(self, message):
self._publish_log_say(message)

def _publish_log_say(self, message):
message = {
Expand Down
27 changes: 2 additions & 25 deletions lerobot/scripts/control_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,10 @@ def calibrate(robot: Robot, arms: list[str] | None):

@safe_disconnect
def teleoperate(
robot: Robot, fps: int | None = None, teleop_time_s: float | None = None, display_cameras: bool = False
robot: Robot, fps: int | None = None, teleop_time_s: float | None = None
):
control_context = ControlContext(
config=ControlContextConfig(
display_cameras=display_cameras,
control_phase=ControlPhase.TELEOPERATE,
robot=robot,
fps=fps,
Expand Down Expand Up @@ -222,8 +221,6 @@ def record(
local_files_only: bool = False,
) -> LeRobotDataset:
# TODO(rcadene): Add option to record logs
listener = None
events = None
policy = None
device = None
use_amp = None
Expand Down Expand Up @@ -282,8 +279,6 @@ def record(
config=ControlContextConfig(
robot=robot,
control_phase=ControlPhase.WARMUP,
display_cameras=display_cameras,
play_sounds=play_sounds,
assign_rewards=False,
fps=fps,
)
Expand All @@ -309,15 +304,13 @@ def record(
ControlContextConfig(
robot=robot,
control_phase=ControlPhase.RECORD,
play_sounds=play_sounds,
assign_rewards=False,
num_episodes=num_episodes,
display_cameras=display_cameras,
fps=fps,
)
)

control_context.log_say(f"Recording episode {dataset.num_episodes}")
control_context.log_say(f"Recording episode {dataset.num_episodes + 1}")
record_episode(
dataset=dataset,
robot=robot,
Expand All @@ -343,10 +336,8 @@ def record(
ControlContextConfig(
robot=robot,
control_phase=ControlPhase.RESET,
play_sounds=play_sounds,
assign_rewards=False,
num_episodes=num_episodes,
display_cameras=display_cameras,
fps=fps,
)
)
Expand All @@ -364,10 +355,8 @@ def record(
ControlContextConfig(
robot=robot,
control_phase=ControlPhase.SAVING,
play_sounds=play_sounds,
assign_rewards=False,
num_episodes=num_episodes,
display_cameras=display_cameras,
fps=fps,
)
)
Expand All @@ -385,10 +374,8 @@ def record(
ControlContextConfig(
robot=robot,
control_phase=ControlPhase.PROCESSING_DATASET,
play_sounds=play_sounds,
assign_rewards=False,
num_episodes=num_episodes,
display_cameras=display_cameras,
fps=fps,
)
)
Expand All @@ -403,10 +390,8 @@ def record(
ControlContextConfig(
robot=robot,
control_phase=ControlPhase.UPLOADING_DATASET_TO_HUB,
play_sounds=play_sounds,
assign_rewards=False,
num_episodes=num_episodes,
display_cameras=display_cameras,
fps=fps,
)
)
Expand All @@ -417,10 +402,8 @@ def record(
ControlContextConfig(
robot=robot,
control_phase=ControlPhase.RECORDING_COMPLETE,
play_sounds=play_sounds,
assign_rewards=False,
num_episodes=num_episodes,
display_cameras=display_cameras,
fps=fps,
)
)
Expand Down Expand Up @@ -491,12 +474,6 @@ def replay(
parser_teleop.add_argument(
"--fps", type=none_or_int, default=None, help="Frames per second (set to None to disable)"
)
parser_teleop.add_argument(
"--display-cameras",
type=int,
default=1,
help="Display all cameras on screen (set to 1 to display or 0).",
)

parser_record = subparsers.add_parser("record", parents=[base_parser])
task_args = parser_record.add_mutually_exclusive_group(required=True)
Expand Down

0 comments on commit b636718

Please sign in to comment.