Skip to content

Commit d428bb5

Browse files
AdilZouitineimstevenpmwork
authored andcommitted
refactor(processor): update action keys from target to displacement format across multiple files (#1816)
1 parent 80987ce commit d428bb5

File tree

3 files changed

+49
-48
lines changed

3 files changed

+49
-48
lines changed

src/lerobot/processor/delta_action_processor.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ class MapDeltaActionToRobotAction(ActionProcessorStep):
6464
Output ACTION keys:
6565
{
6666
"action.enabled": bool,
67-
"action.target_x": float,
68-
"action.target_y": float,
69-
"action.target_z": float,
70-
"action.target_wx": float,
71-
"action.target_wy": float,
72-
"action.target_wz": float,
67+
"action.displacement_x": float,
68+
"action.displacement_y": float,
69+
"action.displacement_z": float,
70+
"action.displacement_wx": float,
71+
"action.displacement_wy": float,
72+
"action.displacement_wz": float,
7373
"action.gripper": float,
7474
}
7575
"""
@@ -99,19 +99,19 @@ def action(self, action: dict) -> dict:
9999

100100
# For gamepad/keyboard, we don't have rotation input, so set to 0
101101
# These could be extended in the future for more sophisticated teleoperators
102-
target_wx = 0.0
103-
target_wy = 0.0
104-
target_wz = 0.0
102+
displacement_wx = 0.0
103+
displacement_wy = 0.0
104+
displacement_wz = 0.0
105105

106-
# Update action with robot target format
106+
# Update action with robot displacement format
107107
action = {
108108
"action.enabled": enabled,
109-
"action.target_x": scaled_delta_x,
110-
"action.target_y": scaled_delta_y,
111-
"action.target_z": scaled_delta_z,
112-
"action.target_wx": target_wx,
113-
"action.target_wy": target_wy,
114-
"action.target_wz": target_wz,
109+
"action.displacement_x": scaled_delta_x,
110+
"action.displacement_y": scaled_delta_y,
111+
"action.displacement_z": scaled_delta_z,
112+
"action.displacement_wx": displacement_wx,
113+
"action.displacement_wy": displacement_wy,
114+
"action.displacement_wz": displacement_wz,
115115
"action.gripper": float(gripper),
116116
}
117117

@@ -123,12 +123,12 @@ def transform_features(self, features: dict[str, PolicyFeature]) -> dict[str, Po
123123
features.update(
124124
{
125125
"action.enabled": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
126-
"action.target_x": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
127-
"action.target_y": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
128-
"action.target_z": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
129-
"action.target_wx": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
130-
"action.target_wy": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
131-
"action.target_wz": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
126+
"action.displacement_x": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
127+
"action.displacement_y": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
128+
"action.displacement_z": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
129+
"action.displacement_wx": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
130+
"action.displacement_wy": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
131+
"action.displacement_wz": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
132132
"action.gripper": PolicyFeature(type=FeatureType.ACTION, shape=(1,)),
133133
}
134134
)

src/lerobot/robots/so100_follower/robot_kinematic_processor.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class EEReferenceAndDelta(ActionProcessorStep):
4141
4242
Input ACTION keys:
4343
{
44-
"action.ee.{x,y,z,wx,wy,wz}" : float
44+
"action.enabled": bool,
45+
"action.displacement_{x,y,z,wx,wy,wz}" : float
4546
"complementary_data.raw_joint_positions": dict,
4647
}
4748
@@ -82,12 +83,12 @@ def action(self, action):
8283
t_curr = self.kinematics.forward_kinematics(q)
8384

8485
enabled = bool(new_action.pop("action.enabled", 0))
85-
tx = float(new_action.pop("action.target_x", 0.0))
86-
ty = float(new_action.pop("action.target_y", 0.0))
87-
tz = float(new_action.pop("action.target_z", 0.0))
88-
wx = float(new_action.pop("action.target_wx", 0.0))
89-
wy = float(new_action.pop("action.target_wy", 0.0))
90-
wz = float(new_action.pop("action.target_wz", 0.0))
86+
tx = float(new_action.pop("action.displacement_x", 0.0))
87+
ty = float(new_action.pop("action.displacement_y", 0.0))
88+
tz = float(new_action.pop("action.displacement_z", 0.0))
89+
wx = float(new_action.pop("action.displacement_wx", 0.0))
90+
wy = float(new_action.pop("action.displacement_wy", 0.0))
91+
wz = float(new_action.pop("action.displacement_wz", 0.0))
9192

9293
desired = None
9394

@@ -140,12 +141,12 @@ def reset(self):
140141

141142
def transform_features(self, features: dict[str, PolicyFeature]) -> dict[str, PolicyFeature]:
142143
features.pop("action.enabled", None)
143-
features.pop("action.target_x", None)
144-
features.pop("action.target_y", None)
145-
features.pop("action.target_z", None)
146-
features.pop("action.target_wx", None)
147-
features.pop("action.target_wy", None)
148-
features.pop("action.target_wz", None)
144+
features.pop("action.displacement_x", None)
145+
features.pop("action.displacement_y", None)
146+
features.pop("action.displacement_z", None)
147+
features.pop("action.displacement_wx", None)
148+
features.pop("action.displacement_wy", None)
149+
features.pop("action.displacement_wz", None)
149150

150151
features["action.ee.x"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
151152
features["action.ee.y"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)

src/lerobot/teleoperators/phone/phone_processor.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MapPhoneActionToRobotAction(ActionProcessorStep):
3838
Output ACTION keys:
3939
{
4040
"action.enabled": bool,
41-
"action.ee.{x,y,z,wx,wy,wz}" : float
41+
"action.displacement_{x,y,z,wx,wy,wz}" : float
4242
"action.gripper": float,
4343
}
4444
"""
@@ -70,12 +70,12 @@ def action(self, act: dict) -> dict:
7070

7171
# For some actions we need to invert the axis
7272
act["action.enabled"] = enabled
73-
act["action.target_x"] = -pos[1] if enabled else 0.0
74-
act["action.target_y"] = pos[0] if enabled else 0.0
75-
act["action.target_z"] = pos[2] if enabled else 0.0
76-
act["action.target_wx"] = rotvec[1] if enabled else 0.0
77-
act["action.target_wy"] = rotvec[0] if enabled else 0.0
78-
act["action.target_wz"] = -rotvec[2] if enabled else 0.0
73+
act["action.displacement_x"] = -pos[1] if enabled else 0.0
74+
act["action.displacement_y"] = pos[0] if enabled else 0.0
75+
act["action.displacement_z"] = pos[2] if enabled else 0.0
76+
act["action.displacement_wx"] = rotvec[1] if enabled else 0.0
77+
act["action.displacement_wy"] = rotvec[0] if enabled else 0.0
78+
act["action.displacement_wz"] = -rotvec[2] if enabled else 0.0
7979
act["action.gripper"] = gripper # Still send gripper action when disabled
8080
return act
8181

@@ -86,11 +86,11 @@ def transform_features(self, features: dict[str, PolicyFeature]) -> dict[str, Po
8686
features.pop("action.phone.raw_inputs", None)
8787

8888
features["action.enabled"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
89-
features["action.target_x"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
90-
features["action.target_y"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
91-
features["action.target_z"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
92-
features["action.target_wx"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
93-
features["action.target_wy"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
94-
features["action.target_wz"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
89+
features["action.displacement_x"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
90+
features["action.displacement_y"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
91+
features["action.displacement_z"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
92+
features["action.displacement_wx"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
93+
features["action.displacement_wy"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
94+
features["action.displacement_wz"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
9595
features["action.gripper"] = (PolicyFeature(type=FeatureType.ACTION, shape=(1,)),)
9696
return features

0 commit comments

Comments
 (0)