From 8e0f5cd05221ad7fb87ed9793435f4481556fdf7 Mon Sep 17 00:00:00 2001 From: Pepijn Date: Fri, 12 Sep 2025 11:57:48 +0200 Subject: [PATCH] fixes for processors used in phone teleop --- .gitignore | 4 +++ .../robot_kinematic_processor.py | 28 +++++++++---------- src/lerobot/teleoperators/phone/__init__.py | 2 +- .../teleoperators/phone/phone_processor.py | 28 +++++++++---------- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index c4d1f769f..b47e22cbf 100644 --- a/.gitignore +++ b/.gitignore @@ -173,3 +173,7 @@ outputs/ # Dev folders .cache/* +*.stl +*.urdf +*.xml +*.part diff --git a/src/lerobot/robots/so100_follower/robot_kinematic_processor.py b/src/lerobot/robots/so100_follower/robot_kinematic_processor.py index 09796910c..67e9f9e1e 100644 --- a/src/lerobot/robots/so100_follower/robot_kinematic_processor.py +++ b/src/lerobot/robots/so100_follower/robot_kinematic_processor.py @@ -193,13 +193,13 @@ class EEBoundsAndSafety(RobotActionProcessorStep): _last_pos: np.ndarray | None = field(default=None, init=False, repr=False) _last_twist: np.ndarray | None = field(default=None, init=False, repr=False) - def action(self, act: RobotAction) -> RobotAction: - x = act.get("ee.x", None) - y = act.get("ee.y", None) - z = act.get("ee.z", None) - wx = act.get("ee.wx", None) - wy = act.get("ee.wy", None) - wz = act.get("ee.wz", None) + def action(self, action: RobotAction) -> RobotAction: + x = action.get("ee.x", None) + y = action.get("ee.y", None) + z = action.get("ee.z", None) + wx = action.get("ee.wx", None) + wy = action.get("ee.wy", None) + wz = action.get("ee.wz", None) if None in (x, y, z, wx, wy, wz): raise ValueError( @@ -223,13 +223,13 @@ class EEBoundsAndSafety(RobotActionProcessorStep): self._last_pos = pos self._last_twist = twist - act["ee.x"] = float(pos[0]) - act["ee.y"] = float(pos[1]) - act["ee.z"] = float(pos[2]) - act["ee.wx"] = float(twist[0]) - act["ee.wy"] = float(twist[1]) - act["ee.wz"] = float(twist[2]) - return act + action["ee.x"] = float(pos[0]) + action["ee.y"] = float(pos[1]) + action["ee.z"] = float(pos[2]) + action["ee.wx"] = float(twist[0]) + action["ee.wy"] = float(twist[1]) + action["ee.wz"] = float(twist[2]) + return action def reset(self): """Resets the last known position and orientation.""" diff --git a/src/lerobot/teleoperators/phone/__init__.py b/src/lerobot/teleoperators/phone/__init__.py index f82ab11e1..2b28c1f97 100644 --- a/src/lerobot/teleoperators/phone/__init__.py +++ b/src/lerobot/teleoperators/phone/__init__.py @@ -15,4 +15,4 @@ # limitations under the License. from .config_phone import PhoneConfig -from .phone import Phone +from .teleop_phone import Phone diff --git a/src/lerobot/teleoperators/phone/phone_processor.py b/src/lerobot/teleoperators/phone/phone_processor.py index 929fede85..2935cbc3a 100644 --- a/src/lerobot/teleoperators/phone/phone_processor.py +++ b/src/lerobot/teleoperators/phone/phone_processor.py @@ -41,7 +41,7 @@ class MapPhoneActionToRobotAction(RobotActionProcessorStep): platform: PhoneOS _enabled_prev: bool = field(default=False, init=False, repr=False) - def action(self, act: RobotAction) -> RobotAction: + def action(self, action: RobotAction) -> RobotAction: """ Processes the phone action dictionary to create a robot action dictionary. @@ -55,10 +55,10 @@ class MapPhoneActionToRobotAction(RobotActionProcessorStep): ValueError: If 'pos' or 'rot' keys are missing from the input action. """ # Pop them from the action - enabled = bool(act.pop("phone.enabled", 0)) - pos = act.pop("phone.pos", None) - rot = act.pop("phone.rot", None) - inputs = act.pop("phone.raw_inputs", {}) + enabled = bool(action.pop("phone.enabled", 0)) + pos = action.pop("phone.pos", None) + rot = action.pop("phone.rot", None) + inputs = action.pop("phone.raw_inputs", {}) if pos is None or rot is None: raise ValueError("pos and rot must be present in action") @@ -76,15 +76,15 @@ class MapPhoneActionToRobotAction(RobotActionProcessorStep): ) # Positive if a is pressed, negative if b is pressed, 0 if both or neither are pressed # For some actions we need to invert the axis - act["enabled"] = enabled - act["target_x"] = -pos[1] if enabled else 0.0 - act["target_y"] = pos[0] if enabled else 0.0 - act["target_z"] = pos[2] if enabled else 0.0 - act["target_wx"] = rotvec[1] if enabled else 0.0 - act["target_wy"] = rotvec[0] if enabled else 0.0 - act["target_wz"] = -rotvec[2] if enabled else 0.0 - act["gripper"] = gripper # Still send gripper action when disabled - return act + action["enabled"] = enabled + action["target_x"] = -pos[1] if enabled else 0.0 + action["target_y"] = pos[0] if enabled else 0.0 + action["target_z"] = pos[2] if enabled else 0.0 + action["target_wx"] = rotvec[1] if enabled else 0.0 + action["target_wy"] = rotvec[0] if enabled else 0.0 + action["target_wz"] = -rotvec[2] if enabled else 0.0 + action["gripper"] = gripper # Still send gripper action when disabled + return action def transform_features( self, features: dict[PipelineFeatureType, dict[str, PolicyFeature]]