chore(processor): remove action prefixes (#1905)

This commit is contained in:
Steven Palma
2025-09-10 18:32:08 +02:00
committed by GitHub
parent 7e30090e97
commit df4292f6ed
2 changed files with 16 additions and 18 deletions
+4 -5
View File
@@ -25,7 +25,6 @@ import torch
import torchvision.transforms.functional as F # noqa: N812
from lerobot.configs.types import PipelineFeatureType, PolicyFeature
from lerobot.constants import ACTION
from lerobot.teleoperators.teleoperator import Teleoperator
from lerobot.teleoperators.utils import TeleopEvents
@@ -345,7 +344,7 @@ class GripperPenaltyProcessorStep(ComplementaryDataProcessorStep):
if current_gripper_pos is None:
return complementary_data
gripper_action = action[f"{ACTION}.{GRIPPER_KEY}.pos"]
gripper_action = action[f"{GRIPPER_KEY}.pos"]
gripper_action_normalized = gripper_action / self.max_gripper_pos
# Normalize gripper state and action
@@ -436,9 +435,9 @@ class InterventionActionProcessorStep(ProcessorStep):
if isinstance(teleop_action, dict):
# Convert teleop_action dict to tensor format
action_list = [
teleop_action.get(f"{ACTION}.delta_x", 0.0),
teleop_action.get(f"{ACTION}.delta_y", 0.0),
teleop_action.get(f"{ACTION}.delta_z", 0.0),
teleop_action.get("delta_x", 0.0),
teleop_action.get("delta_y", 0.0),
teleop_action.get("delta_z", 0.0),
]
if self.use_gripper:
action_list.append(teleop_action.get(GRIPPER_KEY, 1.0))
@@ -17,7 +17,6 @@
from dataclasses import dataclass, field
from lerobot.configs.types import FeatureType, PipelineFeatureType, PolicyFeature
from lerobot.constants import ACTION
from lerobot.processor import ActionProcessorStep, ProcessorStepRegistry
from lerobot.teleoperators.phone.config_phone import PhoneOS
@@ -56,10 +55,10 @@ class MapPhoneActionToRobotAction(ActionProcessorStep):
ValueError: If 'pos' or 'rot' keys are missing from the input action.
"""
# Pop them from the action
enabled = bool(act.pop(f"{ACTION}.phone.enabled", 0))
pos = act.pop(f"{ACTION}.phone.pos", None)
rot = act.pop(f"{ACTION}.phone.rot", None)
inputs = act.pop(f"{ACTION}.phone.raw_inputs", {})
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", {})
if pos is None or rot is None:
raise ValueError("pos and rot must be present in action")
@@ -77,14 +76,14 @@ class MapPhoneActionToRobotAction(ActionProcessorStep):
) # 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[f"{ACTION}.enabled"] = enabled
act[f"{ACTION}.target_x"] = -pos[1] if enabled else 0.0
act[f"{ACTION}.target_y"] = pos[0] if enabled else 0.0
act[f"{ACTION}.target_z"] = pos[2] if enabled else 0.0
act[f"{ACTION}.target_wx"] = rotvec[1] if enabled else 0.0
act[f"{ACTION}.target_wy"] = rotvec[0] if enabled else 0.0
act[f"{ACTION}.target_wz"] = -rotvec[2] if enabled else 0.0
act[f"{ACTION}.gripper"] = gripper # Still send gripper action when disabled
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
def transform_features(