mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-23 12:40:08 +00:00
chore(processor): remove action prefixes (#1905)
This commit is contained in:
@@ -25,7 +25,6 @@ import torch
|
|||||||
import torchvision.transforms.functional as F # noqa: N812
|
import torchvision.transforms.functional as F # noqa: N812
|
||||||
|
|
||||||
from lerobot.configs.types import PipelineFeatureType, PolicyFeature
|
from lerobot.configs.types import PipelineFeatureType, PolicyFeature
|
||||||
from lerobot.constants import ACTION
|
|
||||||
from lerobot.teleoperators.teleoperator import Teleoperator
|
from lerobot.teleoperators.teleoperator import Teleoperator
|
||||||
from lerobot.teleoperators.utils import TeleopEvents
|
from lerobot.teleoperators.utils import TeleopEvents
|
||||||
|
|
||||||
@@ -345,7 +344,7 @@ class GripperPenaltyProcessorStep(ComplementaryDataProcessorStep):
|
|||||||
if current_gripper_pos is None:
|
if current_gripper_pos is None:
|
||||||
return complementary_data
|
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
|
gripper_action_normalized = gripper_action / self.max_gripper_pos
|
||||||
|
|
||||||
# Normalize gripper state and action
|
# Normalize gripper state and action
|
||||||
@@ -436,9 +435,9 @@ class InterventionActionProcessorStep(ProcessorStep):
|
|||||||
if isinstance(teleop_action, dict):
|
if isinstance(teleop_action, dict):
|
||||||
# Convert teleop_action dict to tensor format
|
# Convert teleop_action dict to tensor format
|
||||||
action_list = [
|
action_list = [
|
||||||
teleop_action.get(f"{ACTION}.delta_x", 0.0),
|
teleop_action.get("delta_x", 0.0),
|
||||||
teleop_action.get(f"{ACTION}.delta_y", 0.0),
|
teleop_action.get("delta_y", 0.0),
|
||||||
teleop_action.get(f"{ACTION}.delta_z", 0.0),
|
teleop_action.get("delta_z", 0.0),
|
||||||
]
|
]
|
||||||
if self.use_gripper:
|
if self.use_gripper:
|
||||||
action_list.append(teleop_action.get(GRIPPER_KEY, 1.0))
|
action_list.append(teleop_action.get(GRIPPER_KEY, 1.0))
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
from lerobot.configs.types import FeatureType, PipelineFeatureType, PolicyFeature
|
from lerobot.configs.types import FeatureType, PipelineFeatureType, PolicyFeature
|
||||||
from lerobot.constants import ACTION
|
|
||||||
from lerobot.processor import ActionProcessorStep, ProcessorStepRegistry
|
from lerobot.processor import ActionProcessorStep, ProcessorStepRegistry
|
||||||
from lerobot.teleoperators.phone.config_phone import PhoneOS
|
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.
|
ValueError: If 'pos' or 'rot' keys are missing from the input action.
|
||||||
"""
|
"""
|
||||||
# Pop them from the action
|
# Pop them from the action
|
||||||
enabled = bool(act.pop(f"{ACTION}.phone.enabled", 0))
|
enabled = bool(act.pop("phone.enabled", 0))
|
||||||
pos = act.pop(f"{ACTION}.phone.pos", None)
|
pos = act.pop("phone.pos", None)
|
||||||
rot = act.pop(f"{ACTION}.phone.rot", None)
|
rot = act.pop("phone.rot", None)
|
||||||
inputs = act.pop(f"{ACTION}.phone.raw_inputs", {})
|
inputs = act.pop("phone.raw_inputs", {})
|
||||||
|
|
||||||
if pos is None or rot is None:
|
if pos is None or rot is None:
|
||||||
raise ValueError("pos and rot must be present in action")
|
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
|
) # 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
|
# For some actions we need to invert the axis
|
||||||
act[f"{ACTION}.enabled"] = enabled
|
act["enabled"] = enabled
|
||||||
act[f"{ACTION}.target_x"] = -pos[1] if enabled else 0.0
|
act["target_x"] = -pos[1] if enabled else 0.0
|
||||||
act[f"{ACTION}.target_y"] = pos[0] if enabled else 0.0
|
act["target_y"] = pos[0] if enabled else 0.0
|
||||||
act[f"{ACTION}.target_z"] = pos[2] if enabled else 0.0
|
act["target_z"] = pos[2] if enabled else 0.0
|
||||||
act[f"{ACTION}.target_wx"] = rotvec[1] if enabled else 0.0
|
act["target_wx"] = rotvec[1] if enabled else 0.0
|
||||||
act[f"{ACTION}.target_wy"] = rotvec[0] if enabled else 0.0
|
act["target_wy"] = rotvec[0] if enabled else 0.0
|
||||||
act[f"{ACTION}.target_wz"] = -rotvec[2] if enabled else 0.0
|
act["target_wz"] = -rotvec[2] if enabled else 0.0
|
||||||
act[f"{ACTION}.gripper"] = gripper # Still send gripper action when disabled
|
act["gripper"] = gripper # Still send gripper action when disabled
|
||||||
return act
|
return act
|
||||||
|
|
||||||
def transform_features(
|
def transform_features(
|
||||||
|
|||||||
Reference in New Issue
Block a user