|
17 | 17 | # limitations under the License. |
18 | 18 |
|
19 | 19 | from abc import ABC, abstractmethod |
| 20 | +from dataclasses import dataclass |
| 21 | +from typing import Any |
| 22 | + |
| 23 | +import torch |
20 | 24 |
|
21 | 25 | from isaaclab.devices.openxr.retargeters import ( |
22 | 26 | G1LowerBodyStandingMotionControllerRetargeterCfg, |
23 | 27 | G1TriHandUpperBodyMotionControllerGripperRetargeterCfg, |
24 | 28 | GR1T2RetargeterCfg, |
25 | 29 | ) |
26 | | -from isaaclab.devices.retargeter_base import RetargeterCfg |
| 30 | +from isaaclab.devices.retargeter_base import RetargeterBase, RetargeterCfg |
27 | 31 |
|
28 | 32 | from isaaclab_arena.assets.register import register_retargeter |
29 | 33 |
|
30 | 34 |
|
| 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 | + |
31 | 61 | class RetargetterBase(ABC): |
32 | 62 | device: str |
33 | 63 | embodiment: str |
@@ -125,9 +155,14 @@ def get_retargeter_cfg( |
125 | 155 | ) -> list[RetargeterCfg]: |
126 | 156 | """Get motion controller retargeter configuration for G1. |
127 | 157 | |
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 |
129 | 163 | """ |
130 | 164 | return [ |
131 | 165 | G1TriHandUpperBodyMotionControllerGripperRetargeterCfg(sim_device=sim_device), |
132 | 166 | G1LowerBodyStandingMotionControllerRetargeterCfg(sim_device=sim_device), |
| 167 | + DummyTorsoRetargeterCfg(sim_device=sim_device), |
133 | 168 | ] |
0 commit comments