88import isaaclab .sim as sim_utils
99from isaaclab .assets import AssetBaseCfg
1010from isaaclab .envs import ManagerBasedRLEnvCfg
11- from isaaclab .managers import EventTermCfg as EventTerm
1211from isaaclab .managers import ObservationGroupCfg as ObsGroup
1312from isaaclab .managers import ObservationTermCfg as ObsTerm
14- from isaaclab .managers import RewardTermCfg as RewTerm
1513from isaaclab .managers import SceneEntityCfg
1614from isaaclab .managers import TerminationTermCfg as DoneTerm
1715from isaaclab .scene import InteractiveSceneCfg
3230 ShadowHandTaskCfgBase ,
3331)
3432from 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)
4041from 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
8873class 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):
158138class 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
248179class 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
324247class 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
331254class 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
349279class 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