From 5264feecef23cd0e617fd0acd25fc60435e9255f Mon Sep 17 00:00:00 2001 From: glannuzel Date: Thu, 28 Aug 2025 17:55:30 +0200 Subject: [PATCH] Use disable_torque_on_disconnect --- src/lerobot/robots/reachy2/configuration_reachy2.py | 2 +- src/lerobot/robots/reachy2/robot_reachy2.py | 3 ++- tests/robots/test_reachy2.py | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lerobot/robots/reachy2/configuration_reachy2.py b/src/lerobot/robots/reachy2/configuration_reachy2.py index f43fb203e..7c531bc75 100644 --- a/src/lerobot/robots/reachy2/configuration_reachy2.py +++ b/src/lerobot/robots/reachy2/configuration_reachy2.py @@ -33,7 +33,7 @@ class Reachy2RobotConfig(RobotConfig): ip_address: str | None = "localhost" # If True, turn_off_smoothly() will be sent to the robot before disconnecting. - disable_torque_on_disconnect: bool = True + disable_torque_on_disconnect: bool = False # Tag for external commands control # Set to True if you use an external commands system to control the robot, diff --git a/src/lerobot/robots/reachy2/robot_reachy2.py b/src/lerobot/robots/reachy2/robot_reachy2.py index 7d250692b..19ddcacdd 100644 --- a/src/lerobot/robots/reachy2/robot_reachy2.py +++ b/src/lerobot/robots/reachy2/robot_reachy2.py @@ -211,5 +211,6 @@ class Reachy2Robot(Robot): if self.reachy is not None: for cam in self.cameras.values(): cam.disconnect() - self.reachy.turn_off_smoothly() + if self.config.disable_torque_on_disconnect: + self.reachy.turn_off_smoothly() self.reachy.disconnect() diff --git a/tests/robots/test_reachy2.py b/tests/robots/test_reachy2.py index 121f7edcc..118b736f7 100644 --- a/tests/robots/test_reachy2.py +++ b/tests/robots/test_reachy2.py @@ -60,11 +60,12 @@ PARAMS = [ {"with_mobile_base": False}, {"with_mobile_base": False, "with_l_arm": False, "with_antennas": False}, {"with_r_arm": False, "with_neck": False, "with_antennas": False}, - {"use_external_commands": True}, + {"use_external_commands": True, "disable_torque_on_disconnect": True}, {"use_external_commands": True, "with_mobile_base": False, "with_neck": False}, {"with_right_teleop_camera": False}, {"with_left_teleop_camera": False, "with_right_teleop_camera": False}, {"with_left_teleop_camera": False, "with_torso_camera": True}, + {"disable_torque_on_disconnect": False}, ] @@ -191,7 +192,10 @@ def test_connect_disconnect(reachy2): reachy2.disconnect() assert not reachy2.is_connected - reachy2.reachy.turn_off_smoothly.assert_called_once() + if reachy2.config.disable_torque_on_disconnect: + reachy2.reachy.turn_off_smoothly.assert_called_once() + else: + reachy2.reachy.turn_off_smoothly.assert_not_called() reachy2.reachy.disconnect.assert_called_once()