Skip to content

Commit 4504125

Browse files
committed
Merge the rebuilt handover and camera manager base
# Conflicts: # source/isaaclab_tasks/isaaclab_tasks/core/reorient/config/allegro_hand/allegro_hand_manager_env_cfg.py # source/isaaclab_tasks/isaaclab_tasks/core/reorient/config/shadow_hand/shadow_hand_camera_manager_env_cfg.py # source/isaaclab_tasks/isaaclab_tasks/core/reorient/config/shadow_hand/shadow_hand_manager_env_cfg.py
2 parents 920be95 + 216eb96 commit 4504125

4 files changed

Lines changed: 141 additions & 195 deletions

File tree

source/isaaclab_tasks/isaaclab_tasks/core/reorient/config/allegro_hand/allegro_hand_manager_env_cfg.py

Lines changed: 17 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
from isaaclab.managers import EventTermCfg as EventTerm
1212
from isaaclab.managers import ObservationGroupCfg as ObsGroup
1313
from isaaclab.managers import ObservationTermCfg as ObsTerm
14-
from isaaclab.managers import RewardTermCfg as RewTerm
1514
from isaaclab.managers import SceneEntityCfg
16-
from isaaclab.managers import TerminationTermCfg as DoneTerm
1715
from isaaclab.scene import InteractiveSceneCfg
1816
from isaaclab.utils.configclass import configclass
1917

@@ -28,8 +26,11 @@
2826
from isaaclab_tasks.core.reorient.reorient_task_base import (
2927
ALLEGRO_ACTUATED_JOINT_NAMES,
3028
ALLEGRO_FINGERTIP_BODY_NAMES,
31-
GOAL_MARKER_POSITION,
32-
IN_HAND_POS_OFFSET,
29+
ReorientTerminationsCfg,
30+
reorient_goal_command,
31+
reorient_joint_action,
32+
reorient_reset_event,
33+
reorient_reward_term,
3334
)
3435
from isaaclab_tasks.utils import PresetCfg
3536

@@ -56,43 +57,27 @@ class SceneCfg(InteractiveSceneCfg):
5657

5758
physx = SceneCfg(clone_in_fabric=True)
5859
newton_mjwarp = SceneCfg(clone_in_fabric=False)
59-
ovphysx = SceneCfg(clone_in_fabric=True)
60+
ovphysx = physx
6061
default = physx
6162

6263
def set_num_envs(self, num_envs: int) -> None:
6364
"""Set the environment count on every backend alternative."""
64-
self.physx.num_envs = num_envs
65-
self.newton_mjwarp.num_envs = num_envs
66-
self.ovphysx.num_envs = num_envs
67-
self.default.num_envs = num_envs
65+
for scene in (self.physx, self.newton_mjwarp, self.ovphysx, self.default):
66+
scene.num_envs = num_envs
6867

6968

7069
@configclass
7170
class CommandsCfg:
72-
"""Object pose goal matching the Direct in-hand target."""
73-
74-
object_pose = mdp.ReorientEpisodeCommandCfg(
75-
asset_name="object",
76-
init_pos_offset=IN_HAND_POS_OFFSET,
77-
update_goal_on_success=True,
78-
orientation_success_threshold=0.2,
79-
make_quat_unique=False,
80-
fixed_marker_pos=GOAL_MARKER_POSITION,
81-
goal_pose_visualizer_cfg=GOAL_OBJECT_CFG,
82-
debug_vis=True,
83-
)
71+
"""The reorient goal command with the Allegro marker and tolerance."""
72+
73+
object_pose = reorient_goal_command(orientation_success_threshold=0.2, goal_pose_visualizer_cfg=GOAL_OBJECT_CFG)
8474

8575

8676
@configclass
8777
class ActionsCfg:
8878
"""Sixteen actuated Allegro Hand joints in Direct order."""
8979

90-
joint_pos = mdp.EMAJointPositionToLimitsActionCfg(
91-
asset_name="robot",
92-
joint_names=ALLEGRO_ACTUATED_JOINT_NAMES,
93-
alpha=1.0,
94-
rescale_to_limits=True,
95-
)
80+
joint_pos = reorient_joint_action(ALLEGRO_ACTUATED_JOINT_NAMES)
9681

9782

9883
@configclass
@@ -217,55 +202,14 @@ class EventCfg:
217202
},
218203
)
219204

220-
reset_state = EventTerm(
221-
func=mdp.reset_reorient_state,
222-
mode="reset",
223-
params={
224-
"position_noise": 0.01,
225-
"joint_position_noise": 0.2,
226-
"joint_velocity_noise": 0.0,
227-
"action_name": "joint_pos",
228-
},
229-
)
205+
reset_state = reorient_reset_event()
230206

231207

232208
@configclass
233209
class RewardsCfg:
234-
"""Direct-compatible reward and success accounting."""
235-
236-
reorient = RewTerm(
237-
func=mdp.ReorientReward,
238-
weight=1.0,
239-
params={
240-
"command_name": "object_pose",
241-
"distance_scale": -10.0,
242-
"rotation_scale": 1.0,
243-
"rotation_epsilon": 0.1,
244-
"action_penalty_scale": -0.0002,
245-
"success_tolerance": 0.2,
246-
"success_bonus": 250.0,
247-
"fall_distance": 0.24,
248-
"fall_penalty": 0.0,
249-
"averaging_factor": 0.1,
250-
"success_count_threshold": 1,
251-
"object_cfg": SceneEntityCfg("object"),
252-
},
253-
)
254-
255-
256-
@configclass
257-
class TerminationsCfg:
258-
"""Termination conditions matching the Direct task."""
210+
"""The reorient reward with the Allegro success tolerance."""
259211

260-
object_out_of_reach = DoneTerm(
261-
func=mdp.object_reorientation_out_of_reach,
262-
params={
263-
"threshold": 0.24,
264-
"command_name": "object_pose",
265-
"object_cfg": SceneEntityCfg("object"),
266-
},
267-
)
268-
time_out = DoneTerm(func=mdp.time_out, time_out=True)
212+
reorient = reorient_reward_term(success_tolerance=0.2)
269213

270214

271215
@configclass
@@ -277,7 +221,8 @@ class AllegroCubeEnvCfg(AllegroHandTaskCfgBase, ManagerBasedRLEnvCfg):
277221
actions: ActionsCfg = ActionsCfg()
278222
commands: CommandsCfg = CommandsCfg()
279223
rewards: RewardsCfg = RewardsCfg()
280-
terminations: TerminationsCfg = TerminationsCfg()
224+
# the shared termination section from isaaclab_tasks.core.reorient.reorient_task_base
225+
terminations: ReorientTerminationsCfg = ReorientTerminationsCfg()
281226
events: EventCfg = EventCfg()
282227

283228
enable_domain_randomization: bool = False

source/isaaclab_tasks/isaaclab_tasks/core/reorient/config/shadow_hand/shadow_hand_camera_manager_env_cfg.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@
1818
)
1919
from isaaclab_tasks.core.reorient.config.shadow_hand.shadow_hand_manager_env_cfg import (
2020
ActionsCfg,
21-
CommandsCfg,
2221
EventCfg,
2322
FullStateWithoutActionCfg,
24-
RewardsCfg,
2523
ShadowHandManagerEnvCfg,
26-
TerminationsCfg,
2724
_ShadowHandManagerSceneCfg,
2825
)
2926
from isaaclab_tasks.core.reorient.reorient_task_base import (
@@ -122,9 +119,8 @@ class ShadowHandCameraManagerEnvCfg(ShadowHandManagerEnvCfg):
122119
scene: ShadowHandCameraManagerSceneCfg = ShadowHandCameraManagerSceneCfg()
123120
observations: CameraObservationsCfg = CameraObservationsCfg()
124121
actions: ActionsCfg = ActionsCfg()
125-
commands: CommandsCfg = CommandsCfg()
126-
rewards: RewardsCfg = RewardsCfg()
127-
terminations: TerminationsCfg = TerminationsCfg()
122+
# commands/rewards/terminations are inherited from ShadowHandManagerEnvCfg (the
123+
# shared sections from isaaclab_tasks.core.reorient.reorient_task_base)
128124
events: EventCfg = EventCfg()
129125
feature_extractor: FeatureExtractorCfg = FeatureExtractorCfg()
130126

source/isaaclab_tasks/isaaclab_tasks/core/reorient/config/shadow_hand/shadow_hand_manager_env_cfg.py

Lines changed: 26 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
import isaaclab.sim as sim_utils
99
from isaaclab.assets import AssetBaseCfg
1010
from isaaclab.envs import ManagerBasedRLEnvCfg
11-
from isaaclab.managers import EventTermCfg as EventTerm
1211
from isaaclab.managers import ObservationGroupCfg as ObsGroup
1312
from isaaclab.managers import ObservationTermCfg as ObsTerm
14-
from isaaclab.managers import RewardTermCfg as RewTerm
1513
from isaaclab.managers import SceneEntityCfg
1614
from isaaclab.managers import TerminationTermCfg as DoneTerm
1715
from isaaclab.scene import InteractiveSceneCfg
@@ -32,10 +30,13 @@
3230
ShadowHandTaskCfgBase,
3331
)
3432
from isaaclab_tasks.core.reorient.reorient_task_base import (
35-
GOAL_MARKER_POSITION,
36-
IN_HAND_POS_OFFSET,
3733
SHADOW_ACTUATED_JOINT_NAMES,
3834
SHADOW_FINGERTIP_BODY_NAMES,
35+
ReorientTerminationsCfg,
36+
reorient_goal_command,
37+
reorient_joint_action,
38+
reorient_reset_event,
39+
reorient_reward_term,
3940
)
4041
from isaaclab_tasks.utils import PresetCfg
4142

@@ -68,32 +69,11 @@ class ShadowHandManagerSceneCfg(PresetCfg):
6869
default = physx
6970

7071

71-
@configclass
72-
class CommandsCfg:
73-
"""Object pose goal matching the Direct in-hand target."""
74-
75-
object_pose = mdp.ReorientEpisodeCommandCfg(
76-
asset_name="object",
77-
init_pos_offset=IN_HAND_POS_OFFSET,
78-
update_goal_on_success=True,
79-
orientation_success_threshold=0.1,
80-
make_quat_unique=False,
81-
fixed_marker_pos=GOAL_MARKER_POSITION,
82-
goal_pose_visualizer_cfg=GOAL_OBJECT_CFG,
83-
debug_vis=True,
84-
)
85-
86-
8772
@configclass
8873
class ActionsCfg:
8974
"""Twenty actuated Shadow Hand joints."""
9075

91-
joint_pos = mdp.EMAJointPositionToLimitsActionCfg(
92-
asset_name="robot",
93-
joint_names=SHADOW_ACTUATED_JOINT_NAMES,
94-
alpha=1.0,
95-
rescale_to_limits=True,
96-
)
76+
joint_pos = reorient_joint_action(SHADOW_ACTUATED_JOINT_NAMES)
9777

9878

9979
@configclass
@@ -158,55 +138,21 @@ class PolicyCfg(FullStateWithoutActionCfg):
158138
class EventCfg:
159139
"""Reset distributions matching the Direct task."""
160140

161-
reset_state = EventTerm(
162-
func=mdp.reset_reorient_state,
163-
mode="reset",
164-
params={
165-
"position_noise": 0.01,
166-
"joint_position_noise": 0.2,
167-
"joint_velocity_noise": 0.0,
168-
"action_name": "joint_pos",
169-
},
170-
)
141+
reset_state = reorient_reset_event()
171142

172143

173144
@configclass
174-
class RewardsCfg:
175-
"""Direct-compatible reward and success accounting."""
145+
class CommandsCfg:
146+
"""The reorient goal command with the Shadow Hand goal marker."""
176147

177-
reorient = RewTerm(
178-
func=mdp.ReorientReward,
179-
weight=1.0,
180-
params={
181-
"command_name": "object_pose",
182-
"distance_scale": -10.0,
183-
"rotation_scale": 1.0,
184-
"rotation_epsilon": 0.1,
185-
"action_penalty_scale": -0.0002,
186-
"success_tolerance": 0.1,
187-
"success_bonus": 250.0,
188-
"fall_distance": 0.24,
189-
"fall_penalty": 0.0,
190-
"averaging_factor": 0.1,
191-
"success_count_threshold": 1,
192-
"object_cfg": SceneEntityCfg("object"),
193-
},
194-
)
148+
object_pose = reorient_goal_command(goal_pose_visualizer_cfg=GOAL_OBJECT_CFG)
195149

196150

197151
@configclass
198-
class TerminationsCfg:
199-
"""Termination conditions matching the Direct task."""
152+
class RewardsCfg:
153+
"""Direct-compatible reward and success accounting (the factory defaults)."""
200154

201-
object_out_of_reach = DoneTerm(
202-
func=mdp.object_reorientation_out_of_reach,
203-
params={
204-
"threshold": 0.24,
205-
"command_name": "object_pose",
206-
"object_cfg": SceneEntityCfg("object"),
207-
},
208-
)
209-
time_out = DoneTerm(func=mdp.time_out, time_out=True)
155+
reorient = reorient_reward_term()
210156

211157

212158
@configclass
@@ -218,7 +164,8 @@ class ShadowHandManagerEnvCfg(ShadowHandTaskCfgBase, ManagerBasedRLEnvCfg):
218164
actions: ActionsCfg = ActionsCfg()
219165
commands: CommandsCfg = CommandsCfg()
220166
rewards: RewardsCfg = RewardsCfg()
221-
terminations: TerminationsCfg = TerminationsCfg()
167+
# the shared termination section from isaaclab_tasks.core.reorient.reorient_task_base
168+
terminations: ReorientTerminationsCfg = ReorientTerminationsCfg()
222169
events: EventCfg = EventCfg()
223170

224171
def __post_init__(self):
@@ -228,22 +175,6 @@ def __post_init__(self):
228175
self.viewer.eye = (2.0, 2.0, 2.0)
229176

230177

231-
@configclass
232-
class OpenAICommandsCfg:
233-
"""OpenAI goal command with its wider success tolerance."""
234-
235-
object_pose = mdp.ReorientEpisodeCommandCfg(
236-
asset_name="object",
237-
init_pos_offset=IN_HAND_POS_OFFSET,
238-
update_goal_on_success=True,
239-
orientation_success_threshold=0.4,
240-
make_quat_unique=False,
241-
fixed_marker_pos=GOAL_MARKER_POSITION,
242-
goal_pose_visualizer_cfg=GOAL_OBJECT_CFG,
243-
debug_vis=True,
244-
)
245-
246-
247178
@configclass
248179
class OpenAIActionsCfg:
249180
"""OpenAI actions with Direct-compatible EMA and stateful noise."""
@@ -312,26 +243,18 @@ class SceneCfg(_ShadowHandManagerSceneCfg):
312243
default = physx
313244

314245

315-
_OPENAI_RESET_PARAMS = {
316-
"position_noise": 0.01,
317-
"joint_position_noise": 0.2,
318-
"joint_velocity_noise": 0.0,
319-
"action_name": "joint_pos",
320-
}
321-
322-
323246
@configclass
324247
class OpenAIPhysxEventCfg(PhysxEventCfg):
325248
"""PhysX OpenAI randomization and state reset events."""
326249

327-
reset_state = EventTerm(func=mdp.reset_reorient_state, mode="reset", params=_OPENAI_RESET_PARAMS)
250+
reset_state = reorient_reset_event()
328251

329252

330253
@configclass
331254
class OpenAINewtonEventCfg(NewtonEventCfg):
332255
"""Newton OpenAI randomization and state reset events."""
333256

334-
reset_state = EventTerm(func=mdp.reset_reorient_state, mode="reset", params=_OPENAI_RESET_PARAMS)
257+
reset_state = reorient_reset_event()
335258

336259

337260
@configclass
@@ -345,29 +268,18 @@ class OpenAIEventCfg(PresetCfg):
345268
default = physx
346269

347270

271+
@configclass
272+
class OpenAICommandsCfg:
273+
"""OpenAI goal command with its wider success tolerance."""
274+
275+
object_pose = reorient_goal_command(orientation_success_threshold=0.4, goal_pose_visualizer_cfg=GOAL_OBJECT_CFG)
276+
277+
348278
@configclass
349279
class OpenAIRewardsCfg:
350-
"""Direct-compatible OpenAI reward and success accounting."""
280+
"""OpenAI reward: wider tolerance, fall penalty, and noisy-EMA action source."""
351281

352-
reorient = RewTerm(
353-
func=mdp.ReorientReward,
354-
weight=1.0,
355-
params={
356-
"command_name": "object_pose",
357-
"distance_scale": -10.0,
358-
"rotation_scale": 1.0,
359-
"rotation_epsilon": 0.1,
360-
"action_penalty_scale": -0.0002,
361-
"success_tolerance": 0.4,
362-
"success_bonus": 250.0,
363-
"fall_distance": 0.24,
364-
"fall_penalty": -50.0,
365-
"averaging_factor": 0.1,
366-
"success_count_threshold": 1,
367-
"action_name": "joint_pos",
368-
"object_cfg": SceneEntityCfg("object"),
369-
},
370-
)
282+
reorient = reorient_reward_term(success_tolerance=0.4, fall_penalty=-50.0, action_name="joint_pos")
371283

372284

373285
@configclass

0 commit comments

Comments
 (0)