diff --git a/src/lerobot/robots/reachy2/configuration_reachy2.py b/src/lerobot/robots/reachy2/configuration_reachy2.py index 778390bc0..5beb79ffb 100644 --- a/src/lerobot/robots/reachy2/configuration_reachy2.py +++ b/src/lerobot/robots/reachy2/configuration_reachy2.py @@ -30,6 +30,7 @@ class Reachy2RobotConfig(RobotConfig): # the number of motors in your follower arms. max_relative_target: int | None = None ip_address: str | None = "localhost" + use_external_commands: bool = False # cameras cameras: dict[str, CameraConfig] = field( diff --git a/src/lerobot/robots/reachy2/data_acquisition_server.py b/src/lerobot/robots/reachy2/data_acquisition_server.py index bd9ad9133..8fc21214c 100644 --- a/src/lerobot/robots/reachy2/data_acquisition_server.py +++ b/src/lerobot/robots/reachy2/data_acquisition_server.py @@ -210,6 +210,7 @@ class DataAcquisitionServicer(): self.robot_config = Reachy2RobotConfig( ip_address=request.robot.ip_address, id=request.robot.robot_id, + use_external_commands=True, ) self.teleop_config = Reachy2FakeTeleoperatorConfig( ip_address=request.robot.ip_address, @@ -328,10 +329,10 @@ class DataAcquisitionServicer(): if not dataset_found: print(f"No dataset with name '{dataset.dataset_name}' found.") return - + with open(json_filename, "w") as f: json.dump(data, f, indent=2) - + print(f"Dataset '{dataset.dataset_name}' updated successfully.") def dict_to_dataset(self, d: Dict) -> Dataset: diff --git a/src/lerobot/robots/reachy2/robot_reachy2.py b/src/lerobot/robots/reachy2/robot_reachy2.py index a2d001696..115a0f1fc 100644 --- a/src/lerobot/robots/reachy2/robot_reachy2.py +++ b/src/lerobot/robots/reachy2/robot_reachy2.py @@ -74,6 +74,7 @@ class Reachy2Robot(Robot): self.config = config self.robot_type = self.config.type + self.use_external_commands = self.config.use_external_commands self.reachy: None | ReachySDK = None self.cameras = make_cameras_from_configs(config.cameras) @@ -166,9 +167,10 @@ class Reachy2Robot(Robot): self.reachy.joints[REACHY2_JOINTS[key]].goal_position = val self.reachy.mobile_base.set_goal_speed(vel["vx"], vel["vy"], vel["vtheta"]) - # # We don't want the teleoperator reachy2_specific to send the goal positions - # self.reachy.send_goal_positions() - # self.reachy.send_speed_command() + # We don't send the goal positions if we control Reachy 2 externally + if not self.use_external_commands: + self.reachy.send_goal_positions() + self.reachy.mobile_base.send_speed_command() self.logs["write_pos_dt_s"] = time.perf_counter() - before_write_t return action