From d74494d92b74e951ce2e92bce55b0462c6d3324c Mon Sep 17 00:00:00 2001 From: Justin Huang Date: Fri, 5 Sep 2025 00:58:47 -0700 Subject: [PATCH] Allow max_relative_target to be a float (#1837) * Remove unused max_relative_target for stretch3 * Fix type annotation and allow integer max_relative_target values * Configure max_relative_target to be floats instead of ints * Update docs and types to reflect that max_relative_target can be a dict * Remove unnecessary isinstance check for ints * Fix typo in name --------- Co-authored-by: Justin Huang --- .../robots/bi_so100_follower/config_bi_so100_follower.py | 4 ++-- src/lerobot/robots/hope_jr/config_hope_jr.py | 6 +++--- src/lerobot/robots/koch_follower/config_koch_follower.py | 6 +++--- src/lerobot/robots/lekiwi/config_lekiwi.py | 6 +++--- src/lerobot/robots/so100_follower/config_so100_follower.py | 6 +++--- src/lerobot/robots/so101_follower/config_so101_follower.py | 6 +++--- src/lerobot/robots/stretch3/configuration_stretch3.py | 5 ----- src/lerobot/robots/utils.py | 2 +- src/lerobot/robots/viperx/config_viperx.py | 6 +++--- 9 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/lerobot/robots/bi_so100_follower/config_bi_so100_follower.py b/src/lerobot/robots/bi_so100_follower/config_bi_so100_follower.py index 00643b85..5806d741 100644 --- a/src/lerobot/robots/bi_so100_follower/config_bi_so100_follower.py +++ b/src/lerobot/robots/bi_so100_follower/config_bi_so100_follower.py @@ -29,10 +29,10 @@ class BiSO100FollowerConfig(RobotConfig): # Optional left_arm_disable_torque_on_disconnect: bool = True - left_arm_max_relative_target: int | None = None + left_arm_max_relative_target: float | dict[str, float] | None = None left_arm_use_degrees: bool = False right_arm_disable_torque_on_disconnect: bool = True - right_arm_max_relative_target: int | None = None + right_arm_max_relative_target: float | dict[str, float] | None = None right_arm_use_degrees: bool = False # cameras (shared between both arms) diff --git a/src/lerobot/robots/hope_jr/config_hope_jr.py b/src/lerobot/robots/hope_jr/config_hope_jr.py index 747e98e0..f2af5f47 100644 --- a/src/lerobot/robots/hope_jr/config_hope_jr.py +++ b/src/lerobot/robots/hope_jr/config_hope_jr.py @@ -44,8 +44,8 @@ class HopeJrArmConfig(RobotConfig): disable_torque_on_disconnect: bool = True # `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes. - # Set this to a positive scalar to have the same value for all motors, or a list that is the same length as - # the number of motors in your follower arms. - max_relative_target: int | None = None + # Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor + # names to the max_relative_target value for that motor. + max_relative_target: float | dict[str, float] | None = None cameras: dict[str, CameraConfig] = field(default_factory=dict) diff --git a/src/lerobot/robots/koch_follower/config_koch_follower.py b/src/lerobot/robots/koch_follower/config_koch_follower.py index a7c9249a..02a95ef4 100644 --- a/src/lerobot/robots/koch_follower/config_koch_follower.py +++ b/src/lerobot/robots/koch_follower/config_koch_follower.py @@ -28,9 +28,9 @@ class KochFollowerConfig(RobotConfig): disable_torque_on_disconnect: bool = True # `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes. - # Set this to a positive scalar to have the same value for all motors, or a list that is the same length as - # the number of motors in your follower arms. - max_relative_target: int | None = None + # Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor + # names to the max_relative_target value for that motor. + max_relative_target: float | dict[str, float] | None = None # cameras cameras: dict[str, CameraConfig] = field(default_factory=dict) diff --git a/src/lerobot/robots/lekiwi/config_lekiwi.py b/src/lerobot/robots/lekiwi/config_lekiwi.py index f0f8c24b..acaf5f0e 100644 --- a/src/lerobot/robots/lekiwi/config_lekiwi.py +++ b/src/lerobot/robots/lekiwi/config_lekiwi.py @@ -39,9 +39,9 @@ class LeKiwiConfig(RobotConfig): disable_torque_on_disconnect: bool = True # `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes. - # Set this to a positive scalar to have the same value for all motors, or a list that is the same length as - # the number of motors in your follower arms. - max_relative_target: int | None = None + # Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor + # names to the max_relative_target value for that motor. + max_relative_target: float | dict[str, float] | None = None cameras: dict[str, CameraConfig] = field(default_factory=lekiwi_cameras_config) diff --git a/src/lerobot/robots/so100_follower/config_so100_follower.py b/src/lerobot/robots/so100_follower/config_so100_follower.py index ea8b9f1c..561790e7 100644 --- a/src/lerobot/robots/so100_follower/config_so100_follower.py +++ b/src/lerobot/robots/so100_follower/config_so100_follower.py @@ -30,9 +30,9 @@ class SO100FollowerConfig(RobotConfig): disable_torque_on_disconnect: bool = True # `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes. - # Set this to a positive scalar to have the same value for all motors, or a list that is the same length as - # the number of motors in your follower arms. - max_relative_target: int | None = None + # Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor + # names to the max_relative_target value for that motor. + max_relative_target: float | dict[str, float] | None = None # cameras cameras: dict[str, CameraConfig] = field(default_factory=dict) diff --git a/src/lerobot/robots/so101_follower/config_so101_follower.py b/src/lerobot/robots/so101_follower/config_so101_follower.py index be630e6a..03c3530c 100644 --- a/src/lerobot/robots/so101_follower/config_so101_follower.py +++ b/src/lerobot/robots/so101_follower/config_so101_follower.py @@ -30,9 +30,9 @@ class SO101FollowerConfig(RobotConfig): disable_torque_on_disconnect: bool = True # `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes. - # Set this to a positive scalar to have the same value for all motors, or a list that is the same length as - # the number of motors in your follower arms. - max_relative_target: int | None = None + # Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor + # names to the max_relative_target value for that motor. + max_relative_target: float | dict[str, float] | None = None # cameras cameras: dict[str, CameraConfig] = field(default_factory=dict) diff --git a/src/lerobot/robots/stretch3/configuration_stretch3.py b/src/lerobot/robots/stretch3/configuration_stretch3.py index 9fcf8f74..d4e217ca 100644 --- a/src/lerobot/robots/stretch3/configuration_stretch3.py +++ b/src/lerobot/robots/stretch3/configuration_stretch3.py @@ -24,11 +24,6 @@ from ..config import RobotConfig @RobotConfig.register_subclass("stretch3") @dataclass class Stretch3RobotConfig(RobotConfig): - # `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes. - # Set this to a positive scalar to have the same value for all motors, or a list that is the same length as - # the number of motors in your follower arms. - max_relative_target: int | None = None - # cameras cameras: dict[str, CameraConfig] = field( default_factory=lambda: { diff --git a/src/lerobot/robots/utils.py b/src/lerobot/robots/utils.py index 7486ee49..befd9642 100644 --- a/src/lerobot/robots/utils.py +++ b/src/lerobot/robots/utils.py @@ -70,7 +70,7 @@ def make_robot_from_config(config: RobotConfig) -> Robot: def ensure_safe_goal_position( - goal_present_pos: dict[str, tuple[float, float]], max_relative_target: float | dict[float] + goal_present_pos: dict[str, tuple[float, float]], max_relative_target: float | dict[str, float] ) -> dict[str, float]: """Caps relative action target magnitude for safety.""" diff --git a/src/lerobot/robots/viperx/config_viperx.py b/src/lerobot/robots/viperx/config_viperx.py index 4922f1d1..ed3876a9 100644 --- a/src/lerobot/robots/viperx/config_viperx.py +++ b/src/lerobot/robots/viperx/config_viperx.py @@ -28,15 +28,15 @@ class ViperXConfig(RobotConfig): # /!\ FOR SAFETY, READ THIS /!\ # `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes. - # Set this to a positive scalar to have the same value for all motors, or a list that is the same length as - # the number of motors in your follower arms. + # Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor + # names to the max_relative_target value for that motor. # For Aloha, for every goal position request, motor rotations are capped at 5 degrees by default. # When you feel more confident with teleoperation or running the policy, you can extend # this safety limit and even removing it by setting it to `null`. # Also, everything is expected to work safely out-of-the-box, but we highly advise to # first try to teleoperate the grippers only (by commenting out the rest of the motors in this yaml), # then to gradually add more motors (by uncommenting), until you can teleoperate both arms fully - max_relative_target: int | None = 5 + max_relative_target: float | dict[str, float] = 5.0 # cameras cameras: dict[str, CameraConfig] = field(default_factory=dict)