Skip to content

Commit ce1652e

Browse files
committed
Add torso retargetter and remove padding hack
1 parent b4587ce commit ce1652e

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

isaaclab_arena/assets/retargeter_library.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,47 @@
1717
# limitations under the License.
1818

1919
from abc import ABC, abstractmethod
20+
from dataclasses import dataclass
21+
from typing import Any
22+
23+
import torch
2024

2125
from isaaclab.devices.openxr.retargeters import (
2226
G1LowerBodyStandingMotionControllerRetargeterCfg,
2327
G1TriHandUpperBodyMotionControllerGripperRetargeterCfg,
2428
GR1T2RetargeterCfg,
2529
)
26-
from isaaclab.devices.retargeter_base import RetargeterCfg
30+
from isaaclab.devices.retargeter_base import RetargeterBase, RetargeterCfg
2731

2832
from isaaclab_arena.assets.register import register_retargeter
2933

3034

35+
class DummyTorsoRetargeter(RetargeterBase):
36+
"""Dummy retargeter that returns zero torso orientation commands.
37+
38+
This is used to pad the action space for G1 WBC Pink with motion controllers,
39+
which don't provide torso orientation commands.
40+
"""
41+
42+
def __init__(self, cfg: "DummyTorsoRetargeterCfg"):
43+
super().__init__(cfg)
44+
45+
def retarget(self, data: Any) -> torch.Tensor:
46+
"""Return zeros for torso orientation (roll, pitch, yaw)."""
47+
return torch.zeros(3, device=self._sim_device)
48+
49+
def get_requirements(self) -> list[RetargeterBase.Requirement]:
50+
"""This retargeter doesn't require any device data."""
51+
return []
52+
53+
54+
@dataclass
55+
class DummyTorsoRetargeterCfg(RetargeterCfg):
56+
"""Configuration for dummy torso retargeter."""
57+
58+
retargeter_type: type[RetargeterBase] = DummyTorsoRetargeter
59+
60+
3161
class RetargetterBase(ABC):
3262
device: str
3363
embodiment: str
@@ -125,9 +155,14 @@ def get_retargeter_cfg(
125155
) -> list[RetargeterCfg]:
126156
"""Get motion controller retargeter configuration for G1.
127157
128-
Returns a list of retargeters for upper body (with gripper) and lower body.
158+
Returns a list of retargeters:
159+
- Upper body (with gripper): outputs 16 dims [gripper(2), left_wrist(7), right_wrist(7)]
160+
- Lower body: outputs 4 dims [nav_cmd(3), hip_height(1)]
161+
- Dummy torso: outputs 3 dims [torso_orientation_rpy(3)] all zeros
162+
Total: 23 dims to match g1_wbc_pink action space
129163
"""
130164
return [
131165
G1TriHandUpperBodyMotionControllerGripperRetargeterCfg(sim_device=sim_device),
132166
G1LowerBodyStandingMotionControllerRetargeterCfg(sim_device=sim_device),
167+
DummyTorsoRetargeterCfg(sim_device=sim_device),
133168
]

isaaclab_arena/scripts/imitation_learning/teleop.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,6 @@ def stop_teleoperation() -> None:
238238

239239
# Only apply teleop commands when active
240240
if teleoperation_active:
241-
# Pad action if teleop device outputs fewer dims than environment expects
242-
# actions[:16] are EEF-related, actions[16:] are WBC-related (may need padding)
243-
expected_dim = env.action_space.shape[-1]
244-
if action.shape[0] < expected_dim:
245-
padding = torch.zeros(expected_dim - action.shape[0], device=action.device, dtype=action.dtype)
246-
action = torch.cat([action, padding])
247-
248241
# process actions
249242
actions = action.repeat(env.num_envs, 1)
250243
# apply actions

0 commit comments

Comments
 (0)