Skip to content

Commit d74494d

Browse files
jstnhuangJustin Huang
andauthored
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 <[email protected]>
1 parent 882c80d commit d74494d

File tree

9 files changed

+21
-26
lines changed

9 files changed

+21
-26
lines changed

src/lerobot/robots/bi_so100_follower/config_bi_so100_follower.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class BiSO100FollowerConfig(RobotConfig):
2929

3030
# Optional
3131
left_arm_disable_torque_on_disconnect: bool = True
32-
left_arm_max_relative_target: int | None = None
32+
left_arm_max_relative_target: float | dict[str, float] | None = None
3333
left_arm_use_degrees: bool = False
3434
right_arm_disable_torque_on_disconnect: bool = True
35-
right_arm_max_relative_target: int | None = None
35+
right_arm_max_relative_target: float | dict[str, float] | None = None
3636
right_arm_use_degrees: bool = False
3737

3838
# cameras (shared between both arms)

src/lerobot/robots/hope_jr/config_hope_jr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class HopeJrArmConfig(RobotConfig):
4444
disable_torque_on_disconnect: bool = True
4545

4646
# `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes.
47-
# Set this to a positive scalar to have the same value for all motors, or a list that is the same length as
48-
# the number of motors in your follower arms.
49-
max_relative_target: int | None = None
47+
# Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor
48+
# names to the max_relative_target value for that motor.
49+
max_relative_target: float | dict[str, float] | None = None
5050

5151
cameras: dict[str, CameraConfig] = field(default_factory=dict)

src/lerobot/robots/koch_follower/config_koch_follower.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class KochFollowerConfig(RobotConfig):
2828
disable_torque_on_disconnect: bool = True
2929

3030
# `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes.
31-
# Set this to a positive scalar to have the same value for all motors, or a list that is the same length as
32-
# the number of motors in your follower arms.
33-
max_relative_target: int | None = None
31+
# Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor
32+
# names to the max_relative_target value for that motor.
33+
max_relative_target: float | dict[str, float] | None = None
3434

3535
# cameras
3636
cameras: dict[str, CameraConfig] = field(default_factory=dict)

src/lerobot/robots/lekiwi/config_lekiwi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class LeKiwiConfig(RobotConfig):
3939
disable_torque_on_disconnect: bool = True
4040

4141
# `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes.
42-
# Set this to a positive scalar to have the same value for all motors, or a list that is the same length as
43-
# the number of motors in your follower arms.
44-
max_relative_target: int | None = None
42+
# Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor
43+
# names to the max_relative_target value for that motor.
44+
max_relative_target: float | dict[str, float] | None = None
4545

4646
cameras: dict[str, CameraConfig] = field(default_factory=lekiwi_cameras_config)
4747

src/lerobot/robots/so100_follower/config_so100_follower.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class SO100FollowerConfig(RobotConfig):
3030
disable_torque_on_disconnect: bool = True
3131

3232
# `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes.
33-
# Set this to a positive scalar to have the same value for all motors, or a list that is the same length as
34-
# the number of motors in your follower arms.
35-
max_relative_target: int | None = None
33+
# Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor
34+
# names to the max_relative_target value for that motor.
35+
max_relative_target: float | dict[str, float] | None = None
3636

3737
# cameras
3838
cameras: dict[str, CameraConfig] = field(default_factory=dict)

src/lerobot/robots/so101_follower/config_so101_follower.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class SO101FollowerConfig(RobotConfig):
3030
disable_torque_on_disconnect: bool = True
3131

3232
# `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes.
33-
# Set this to a positive scalar to have the same value for all motors, or a list that is the same length as
34-
# the number of motors in your follower arms.
35-
max_relative_target: int | None = None
33+
# Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor
34+
# names to the max_relative_target value for that motor.
35+
max_relative_target: float | dict[str, float] | None = None
3636

3737
# cameras
3838
cameras: dict[str, CameraConfig] = field(default_factory=dict)

src/lerobot/robots/stretch3/configuration_stretch3.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
@RobotConfig.register_subclass("stretch3")
2525
@dataclass
2626
class Stretch3RobotConfig(RobotConfig):
27-
# `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes.
28-
# Set this to a positive scalar to have the same value for all motors, or a list that is the same length as
29-
# the number of motors in your follower arms.
30-
max_relative_target: int | None = None
31-
3227
# cameras
3328
cameras: dict[str, CameraConfig] = field(
3429
default_factory=lambda: {

src/lerobot/robots/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def make_robot_from_config(config: RobotConfig) -> Robot:
7070

7171

7272
def ensure_safe_goal_position(
73-
goal_present_pos: dict[str, tuple[float, float]], max_relative_target: float | dict[float]
73+
goal_present_pos: dict[str, tuple[float, float]], max_relative_target: float | dict[str, float]
7474
) -> dict[str, float]:
7575
"""Caps relative action target magnitude for safety."""
7676

src/lerobot/robots/viperx/config_viperx.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ class ViperXConfig(RobotConfig):
2828

2929
# /!\ FOR SAFETY, READ THIS /!\
3030
# `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes.
31-
# Set this to a positive scalar to have the same value for all motors, or a list that is the same length as
32-
# the number of motors in your follower arms.
31+
# Set this to a positive scalar to have the same value for all motors, or a dictionary that maps motor
32+
# names to the max_relative_target value for that motor.
3333
# For Aloha, for every goal position request, motor rotations are capped at 5 degrees by default.
3434
# When you feel more confident with teleoperation or running the policy, you can extend
3535
# this safety limit and even removing it by setting it to `null`.
3636
# Also, everything is expected to work safely out-of-the-box, but we highly advise to
3737
# first try to teleoperate the grippers only (by commenting out the rest of the motors in this yaml),
3838
# then to gradually add more motors (by uncommenting), until you can teleoperate both arms fully
39-
max_relative_target: int | None = 5
39+
max_relative_target: float | dict[str, float] = 5.0
4040

4141
# cameras
4242
cameras: dict[str, CameraConfig] = field(default_factory=dict)

0 commit comments

Comments
 (0)