mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-30 18:31:25 +00:00
fix(rl): clarify discrete gripper action mapping in GripperVelocityToJoint for SO100
This commit is contained in:
@@ -353,7 +353,8 @@ class GripperVelocityToJoint(RobotActionProcessorStep):
|
|||||||
speed_factor: A scaling factor to convert the normalized velocity command to a position change.
|
speed_factor: A scaling factor to convert the normalized velocity command to a position change.
|
||||||
clip_min: The minimum allowed gripper joint position.
|
clip_min: The minimum allowed gripper joint position.
|
||||||
clip_max: The maximum allowed gripper joint position.
|
clip_max: The maximum allowed gripper joint position.
|
||||||
discrete_gripper: If True, treat the input action as discrete (0: open, 1: close, 2: stay).
|
discrete_gripper: If True, interpret the input as a discrete class index
|
||||||
|
{0 = close, 1 = stay, 2 = open}, matching `GamepadTeleop.GripperAction`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
speed_factor: float = 20.0
|
speed_factor: float = 20.0
|
||||||
@@ -377,10 +378,10 @@ class GripperVelocityToJoint(RobotActionProcessorStep):
|
|||||||
raise ValueError("Joints observation is require for computing robot kinematics")
|
raise ValueError("Joints observation is require for computing robot kinematics")
|
||||||
|
|
||||||
if self.discrete_gripper:
|
if self.discrete_gripper:
|
||||||
# Discrete gripper actions are in [0, 1, 2]
|
# Map discrete command {0=close, 1=stay, 2=open} -> signed velocity.
|
||||||
# 0: open, 1: close, 2: stay
|
# Negation accounts for SO100 sign (joint position increases on close).
|
||||||
# We need to shift them to [-1, 0, 1] and then scale them to clip_max
|
# 0 -> +clip_max (close), 1 -> 0 (stay), 2 -> -clip_max (open)
|
||||||
gripper_vel = (gripper_vel - 1) * self.clip_max
|
gripper_vel = -(gripper_vel - 1) * self.clip_max
|
||||||
|
|
||||||
# Compute desired gripper position
|
# Compute desired gripper position
|
||||||
delta = gripper_vel * float(self.speed_factor)
|
delta = gripper_vel * float(self.speed_factor)
|
||||||
|
|||||||
Reference in New Issue
Block a user