Robot Arm: Completed Reference to Scaffold

Compare the pinned completed reference (left, removals in red) with the learning-path scaffold (right, additions in green).

10 files changed, 202 insertions(+), 415 deletions(-). All changed files are included; unchanged regions are omitted.

Source: isaac-sim/IsaacLabTutorial ยท pinned commits
reference: 917689a8876cfc154ab0216d5f378622ab9d1322
scaffold: eabf60b88bfaa57d13c4a246b89cd3d77bba3b39

Files changed (10) hide show
  1. README.md +17 -19
  2. src/isaaclab_tutorial/tasks/place_vial/config/so101/__init__.py +10 -17
  3. src/isaaclab_tutorial/tasks/place_vial/config/so101/agents/rsl_rl_distillation_cfg.py +3 -37
  4. src/isaaclab_tutorial/tasks/place_vial/config/so101/agents/rsl_rl_ppo_cfg.py +3 -32
  5. src/isaaclab_tutorial/tasks/place_vial/config/so101/camera_env_cfg.py +15 -90
  6. src/isaaclab_tutorial/tasks/place_vial/config/so101/env_cfg.py +50 -217
  7. src/isaaclab_tutorial/tasks/place_vial/config/so101/inspection_env_cfg.py +34 -0
  8. src/isaaclab_tutorial/tasks/place_vial/config/so101/lesson_scaffold.py +61 -0
  9. tests/test_config.py +8 -2
  10. tests/test_startup.py +1 -1
README.md CHANGED
@@ -34,26 +34,12 @@ For Windows or other Linux distributions, follow the
34
  [Git LFS installation instructions](https://git-lfs.com/).
35
  Confirm that `git lfs version` prints a version before cloning.
36
 
37
- Clone the repository, initialize Git LFS for this checkout, and download the
38
- assets before installing Python dependencies. If you're following the course,
39
- use its pinned checkout commands, then run the Git LFS initialization and
40
- asset-download steps for that lesson.
41
 
42
- Every command below is a single line, so it runs unchanged in bash, PowerShell and Command Prompt.
43
-
44
- ```bash
45
- git clone https://github.com/isaac-sim/IsaacLabTutorial.git
46
- cd IsaacLabTutorial
47
- git lfs install --local
48
- git lfs pull
49
- uv sync --locked
50
- uv run pytest -q
51
- ```
52
-
53
- If you already cloned the repository without Git LFS, install it, then run
54
- `git lfs install --local` and `git lfs pull` from the repository root. This
55
- replaces LFS pointer files with the actual assets. Course checkouts that
56
- intentionally skip assets should follow their lesson's download instructions.
57
 
58
  ### Optional Recording and Experiment Tracking
59
 
@@ -74,6 +60,18 @@ combined as `uv run --extra video --extra wandb` when recording and tracking a r
74
 
75
  ## SO-101 Vial Placement
76
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  <p align="center"><img src="media/demo.gif" alt="SO-101 workshop demonstration" width="100%"></p>
78
 
79
  The SO-101 picks up a vial lying on the desk and places it upright in any of
 
34
  [Git LFS installation instructions](https://git-lfs.com/).
35
  Confirm that `git lfs version` prints a version before cloning.
36
 
 
37
+ Follow [Project Setup](https://docs.nvidia.com/learning/physical-ai/getting-started-with-isaac-lab/latest/train-a-robot-arm/01-project-setup.html) in **Train a Robot Arm** to
38
+ check out the pinned scaffold and set up the environment.
 
39
 
 
 
 
 
 
 
 
 
 
 
 
40
+ Both projects can use the same `IsaacLabTutorial` directory. The robot arm
41
+ lessons use the local `learning-path` branch, and the Microduck lessons use
 
42
+ `microduck-course`. Commit your lesson edits before switching branches.
43
 
44
  ### Optional Recording and Experiment Tracking
45
 
 
60
 
61
  ## SO-101 Vial Placement
62
 
63
+ This branch provides the SO-101 exercises. The starter scene has no robot.
64
+ Lesson 02 makes inspection runnable, lesson 04 adds actions, lesson 05
65
+ adds the state teacher, and lesson 06 adds camera distillation. Use the
66
+ commands below after completing the corresponding lessons. Run
67
+ `uv run pytest -q` after lesson 06.
68
+
69
+ To compare your work with the pinned reference tag created in Project Setup:
70
+
71
+ ```bash
72
+ git diff so101-reference -- src/
73
+ ```
74
+
75
  <p align="center"><img src="media/demo.gif" alt="SO-101 workshop demonstration" width="100%"></p>
76
 
77
  The SO-101 picks up a vial lying on the desk and places it upright in any of
src/isaaclab_tutorial/tasks/place_vial/config/so101/__init__.py CHANGED
@@ -4,25 +4,18 @@ import gymnasium as gym
4
 
5
  _PACKAGE = "isaaclab_tutorial.tasks.place_vial.config.so101"
6
 
7
- gym.register(
8
- id="IsaacTutorial-Place-Vial-SO101",
9
- entry_point="isaaclab.envs:ManagerBasedRLEnv",
10
- disable_env_checker=True,
11
- kwargs={
12
- "env_cfg_entry_point": f"{_PACKAGE}.env_cfg:SO101VialEnvCfg",
13
- "rsl_rl_cfg_entry_point": f"{_PACKAGE}.agents.rsl_rl_ppo_cfg:SO101StatePPORunnerCfg",
14
- "default_agent": "rsl_rl",
15
- },
 
 
 
16
- )
 
17
 
18
  gym.register(
19
- id="IsaacTutorial-Place-Vial-SO101-Camera",
20
  entry_point="isaaclab.envs:ManagerBasedRLEnv",
21
  disable_env_checker=True,
22
- kwargs={
23
- "env_cfg_entry_point": f"{_PACKAGE}.camera_env_cfg:SO101VialCameraEnvCfg",
24
- "rsl_rl_cfg_entry_point": f"{_PACKAGE}.agents.rsl_rl_distillation_cfg:SO101CameraDistillationRunnerCfg",
25
- "rsl_rl_ppo_cfg_entry_point": f"{_PACKAGE}.agents.rsl_rl_ppo_cfg:SO101CameraPPORunnerCfg",
26
- "default_agent": "rsl_rl",
27
- },
28
  )
 
4
 
5
  _PACKAGE = "isaaclab_tutorial.tasks.place_vial.config.so101"
6
 
 
 
 
7
+ # BEGIN lesson-01-registration
 
 
 
8
+ # Complete task registration in the matching lesson.
9
+ # END lesson-01-registration
10
+
11
+ # BEGIN lesson-06-camera-registration
12
+ # Complete task registration in the matching lesson.
13
+ # END lesson-06-camera-registration
14
+
15
 
16
  gym.register(
17
+ id="IsaacTutorial-Inspect-SO101",
18
  entry_point="isaaclab.envs:ManagerBasedRLEnv",
19
  disable_env_checker=True,
 
20
+ kwargs={"env_cfg_entry_point": f"{_PACKAGE}.inspection_env_cfg:SO101InspectionEnvCfg"},
 
 
 
 
21
  )
src/isaaclab_tutorial/tasks/place_vial/config/so101/agents/rsl_rl_distillation_cfg.py CHANGED
@@ -23,42 +23,8 @@ class BoundedTeacherDistillation(Distillation):
23
  return actions
24
 
25
 
 
26
  @configclass
27
  class SO101CameraDistillationRunnerCfg(RslRlDistillationRunnerCfg):
28
- """DAgger-style distillation: the student acts, the loaded state teacher labels every visited state."""
29
-
30
- seed = 42
31
- num_steps_per_env = 32
32
- max_iterations = 1600
33
- save_interval = 100
34
- experiment_name = "so101_vial_camera_distillation"
35
- run_name = ""
36
- obs_groups = {"student": ["wrist_rgb", "proprioception"], "teacher": ["teacher_state"]}
37
- clip_actions = 1.0
38
- student = RslRlCNNModelCfg(
39
- # Compact encoder for the 64 x 48 wrist image.
40
- cnn_cfg=RslRlCNNModelCfg.CNNCfg(
41
- output_channels=[16, 32, 32], kernel_size=[5, 3, 3], stride=[2, 2, 2], activation="elu"
42
- ),
43
- hidden_dims=[256, 128],
44
- activation="elu",
45
- obs_normalization=True,
46
- distribution_cfg=RslRlCNNModelCfg.GaussianDistributionCfg(init_std=0.05, std_type="log"),
47
- )
48
- # Must mirror the state actor so its checkpoint loads; the teacher always acts deterministically.
49
- teacher = RslRlMLPModelCfg(
50
- hidden_dims=[256, 256, 128],
51
- activation="elu",
52
- obs_normalization=True,
53
- distribution_cfg=RslRlMLPModelCfg.GaussianDistributionCfg(init_std=0.2, std_type="log", std_range=(0.05, 0.3)),
54
- )
55
- algorithm = RslRlDistillationAlgorithmCfg(
56
- class_name=(
57
- "isaaclab_tutorial.tasks.place_vial.config.so101.agents.rsl_rl_distillation_cfg:BoundedTeacherDistillation"
58
- ),
59
- num_learning_epochs=4,
60
- learning_rate=5.0e-4,
61
- gradient_length=1,
62
- max_grad_norm=1.0,
63
- loss_type="mse",
64
- )
 
23
  return actions
24
 
25
 
26
+ # BEGIN lesson-06-distillation
27
  @configclass
28
  class SO101CameraDistillationRunnerCfg(RslRlDistillationRunnerCfg):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
+ pass
 
 
 
 
 
 
 
 
 
 
 
 
30
+ # END lesson-06-distillation
 
 
 
 
 
 
 
 
 
src/isaaclab_tutorial/tasks/place_vial/config/so101/agents/rsl_rl_ppo_cfg.py CHANGED
@@ -5,40 +5,11 @@ from isaaclab.utils.configclass import configclass
5
  from isaaclab_rl.rsl_rl import RslRlCNNModelCfg, RslRlMLPModelCfg, RslRlOnPolicyRunnerCfg, RslRlPpoAlgorithmCfg
6
 
7
 
 
8
  @configclass
9
  class SO101StatePPORunnerCfg(RslRlOnPolicyRunnerCfg):
10
- """State teacher: fully observed actor, privileged critic."""
11
-
12
- seed = 42
13
- num_steps_per_env = 64
14
- max_iterations = 800
15
- save_interval = 50
16
- experiment_name = "so101_vial_state"
17
- run_name = ""
18
- obs_groups = {"actor": ["policy"], "critic": ["critic"]}
19
- clip_actions = 1.0
20
- actor = RslRlMLPModelCfg(
21
- hidden_dims=[256, 256, 128],
22
- activation="elu",
23
- obs_normalization=True,
24
- # Clamp the std: with clipped actions and an entropy bonus, PPO otherwise grows it without bound.
25
- distribution_cfg=RslRlMLPModelCfg.GaussianDistributionCfg(init_std=0.2, std_type="log", std_range=(0.05, 0.3)),
26
- )
27
- critic = RslRlMLPModelCfg(hidden_dims=[256, 256, 128], activation="elu", obs_normalization=True)
28
- algorithm = RslRlPpoAlgorithmCfg(
29
- value_loss_coef=1.0,
30
- use_clipped_value_loss=True,
31
- clip_param=0.2,
32
- entropy_coef=0.005,
33
- num_learning_epochs=5,
34
- num_mini_batches=8,
35
- learning_rate=3.0e-4,
36
- schedule="adaptive",
37
- gamma=0.995,
38
- lam=0.95,
39
- desired_kl=0.01,
40
- max_grad_norm=1.0,
41
- )
42
 
43
 
44
  @configclass
 
5
  from isaaclab_rl.rsl_rl import RslRlCNNModelCfg, RslRlMLPModelCfg, RslRlOnPolicyRunnerCfg, RslRlPpoAlgorithmCfg
6
 
7
 
8
+ # BEGIN lesson-05-ppo
9
  @configclass
10
  class SO101StatePPORunnerCfg(RslRlOnPolicyRunnerCfg):
 
 
 
 
 
 
 
 
 
11
+ pass
 
 
 
 
 
 
 
 
 
12
+ # END lesson-05-ppo
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
 
15
  @configclass
src/isaaclab_tutorial/tasks/place_vial/config/so101/camera_env_cfg.py CHANGED
@@ -48,98 +48,32 @@ _HORIZONTAL_APERTURE = 20.955 * 80 / 64
48
  WRIST_FOCAL_LENGTH_PIXELS = 80 * _FOCAL_LENGTH / _HORIZONTAL_APERTURE
49
 
50
 
 
51
  @configclass
52
  class SO101CameraSceneCfg(SO101SceneCfg):
53
- """SO-101 scene with the rectified pinhole wrist camera and handles to the randomized visual materials."""
54
-
55
- wrist_camera = CameraCfg(
56
- prim_path="{ENV_REGEX_NS}/Robot/gripper/wowrobo_2MP_camera/pinhole",
57
- spawn=PinholeCameraCfg(focal_length=_FOCAL_LENGTH, horizontal_aperture=_HORIZONTAL_APERTURE),
58
- offset=CameraCfg.OffsetCfg(convention="opengl"),
59
- data_types=["rgb"],
60
- width=80,
61
- height=60,
62
- update_period=1.0 / 30.0,
63
- update_latest_camera_pose=True,
64
- renderer_cfg=_camera_renderer_cfg(),
65
- background_color=(0.3, 0.3, 0.3),
66
- )
67
-
68
- # The Newton renderer only reads material color.
69
- robot_visual = VisualMaterialCfg(prim_path="{ENV_REGEX_NS}/Robot/Looks/material_a_d_printed", spawn=None)
70
- desk_visual = VisualMaterialCfg(prim_path="{ENV_REGEX_NS}/Desk/Looks/Wood", spawn=None)
71
- rack_visual = VisualMaterialCfg(prim_path="{ENV_REGEX_NS}/Rack/WorkshopVisual/Looks/OmniPBR", spawn=None)
72
- vial_body_visual = VisualMaterialCfg(prim_path="{ENV_REGEX_NS}/Vial/Looks/Vial_plastic", spawn=None)
73
- vial_cap_visual = VisualMaterialCfg(prim_path="{ENV_REGEX_NS}/Vial/Looks/Vial_cap", spawn=None)
74
- vial_label_visual = VisualMaterialCfg(prim_path="{ENV_REGEX_NS}/Vial/Looks/Label", spawn=None)
75
-
76
- def __post_init__(self):
77
- self.robot.spawn.hide_camera_housing = False
78
- self.vial.spawn.usd_path = str(VIAL_LABELED_USD)
79
 
80
 
 
81
  @configclass
82
  class WristImageCfg(ObsGroup):
83
- """Two-frame wrist RGB history with episode-consistent photometric (and, for sim2real, intrinsics) variation."""
84
-
85
- image = ObsTerm(
86
- func=mdp.wrist_rgb,
87
- params={
88
- "sensor_cfg": SceneEntityCfg("wrist_camera"),
89
- "exposure_range": (0.75, 1.25),
90
- "contrast_range": (0.85, 1.15),
91
- "white_balance_range": (0.90, 1.10),
92
- "brightness_range": (-0.05, 0.05),
93
- "gamma_range": preset(default=(1.0, 1.0), sim2real=(0.85, 1.15)),
94
- "blur_range": preset(default=(0.0, 0.0), sim2real=(0.0, 0.5)),
95
- "history_length": 2,
96
- "projection_size": POLICY_IMAGE_SIZE,
97
- "focal_length_pixels": WRIST_FOCAL_LENGTH_PIXELS,
98
- "focal_scale_range": preset(default=(1.0, 1.0), sim2real=(0.95, 1.05)),
99
- "principal_point_pixels": preset(default=0.0, sim2real=1.5),
100
- "radial_distortion_range": preset(default=(0.0, 0.0), sim2real=(-0.04, 0.04)),
101
- },
102
- noise=UniformNoiseCfg(n_min=-0.025, n_max=0.025),
103
- )
104
-
105
- def __post_init__(self):
106
- self.enable_corruption = True
107
 
108
 
 
109
  @configclass
110
  class ProprioceptionCfg(ObsGroup):
111
- """Proprioceptive observations available on the real robot, in the encoders' (possibly biased) coordinates."""
112
-
113
- joint_pos = ObsTerm(
114
- func=mdp.encoder_joint_pos,
115
- params={"asset_cfg": SceneEntityCfg("robot")},
116
- noise=UniformNoiseCfg(n_min=-0.01, n_max=0.01),
117
- )
118
- joint_vel = ObsTerm(
119
- func=mdp.joint_vel,
120
- params={"asset_cfg": SceneEntityCfg("robot")},
121
- noise=UniformNoiseCfg(n_min=-0.02, n_max=0.02),
122
- )
123
- joint_target = ObsTerm(
124
- func=mdp.encoder_joint_target,
125
- params={"asset_cfg": SceneEntityCfg("robot")},
126
- noise=UniformNoiseCfg(n_min=-0.005, n_max=0.005),
127
- )
128
- previous_action = ObsTerm(func=mdp.last_action)
129
-
130
- def __post_init__(self):
131
- self.enable_corruption = True
132
- self.concatenate_terms = True
133
 
134
 
 
135
  @configclass
136
  class CameraObservationsCfg:
137
- """Deployable student inputs, the state teacher's inputs (distillation labels), and the privileged critic."""
138
-
139
- wrist_rgb: WristImageCfg = WristImageCfg()
140
- proprioception: ProprioceptionCfg = ProprioceptionCfg()
141
- teacher_state: PolicyStateGroupCfg = PolicyStateGroupCfg()
142
- critic: CriticStateGroupCfg = CriticStateGroupCfg()
143
 
144
 
145
  def _color_event(materials: str, color_range) -> EventTerm:
@@ -173,17 +107,8 @@ class CameraSim2RealEventsCfg(Sim2RealEventsCfg):
173
  )
174
 
175
 
 
176
  @configclass
177
  class SO101VialCameraEnvCfg(SO101VialEnvCfg):
178
- """Vial placement from wrist RGB and proprioception, distilled from the state teacher."""
179
-
180
- scene: SO101CameraSceneCfg = SO101CameraSceneCfg(num_envs=1024, env_spacing=0.9, replicate_physics=True)
181
- observations: CameraObservationsCfg = CameraObservationsCfg()
182
- events: EventsCfg = preset(default=EventsCfg(), sim2real=CameraSim2RealEventsCfg())
183
-
184
- def play_mode(self):
185
- from isaaclab_tutorial.utils import evaluation
186
-
187
- super().play_mode()
188
- if not evaluation.EXACT_EVALUATION_ACTIVE:
189
- self.scene.num_envs = min(self.scene.num_envs, 8)
 
48
  WRIST_FOCAL_LENGTH_PIXELS = 80 * _FOCAL_LENGTH / _HORIZONTAL_APERTURE
49
 
50
 
51
+ # BEGIN lesson-06-SO101CameraSceneCfg
52
  @configclass
53
  class SO101CameraSceneCfg(SO101SceneCfg):
54
+ pass
 
55
+ # END lesson-06-SO101CameraSceneCfg
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
 
58
+ # BEGIN lesson-06-WristImageCfg
59
  @configclass
60
  class WristImageCfg(ObsGroup):
 
 
 
 
61
+ pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
+ # END lesson-06-WristImageCfg
 
63
 
64
 
65
+ # BEGIN lesson-06-ProprioceptionCfg
66
  @configclass
67
  class ProprioceptionCfg(ObsGroup):
 
 
68
+ pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
+ # END lesson-06-ProprioceptionCfg
 
70
 
71
 
72
+ # BEGIN lesson-06-CameraObservationsCfg
73
  @configclass
74
  class CameraObservationsCfg:
75
+ pass
 
76
+ # END lesson-06-CameraObservationsCfg
 
 
 
77
 
78
 
79
  def _color_event(materials: str, color_range) -> EventTerm:
 
107
  )
108
 
109
 
110
+ # BEGIN lesson-06-SO101VialCameraEnvCfg
111
  @configclass
112
  class SO101VialCameraEnvCfg(SO101VialEnvCfg):
 
 
 
 
 
 
113
+ pass
 
 
 
114
+ # END lesson-06-SO101VialCameraEnvCfg
 
src/isaaclab_tutorial/tasks/place_vial/config/so101/env_cfg.py CHANGED
@@ -13,7 +13,10 @@ import torch
13
 
14
  import isaaclab.sim as sim_utils
15
  from isaaclab.assets import AssetBaseCfg, RigidObjectCfg
16
- from isaaclab.envs import ManagerBasedRLEnvCfg
 
 
 
17
  from isaaclab.envs.mdp.actions.actions_cfg import RelativeJointPositionActionCfg
18
  from isaaclab.managers import EventTermCfg as EventTerm
19
  from isaaclab.managers import ObservationGroupCfg as ObsGroup
@@ -42,6 +45,14 @@ from isaaclab_tutorial.assets import DESK_USD, RACK_USD, RESET_DATASET, VIAL_USD
42
  from isaaclab_tutorial.tasks.place_vial import mdp
43
  from isaaclab_tutorial.tasks.place_vial.reset.curriculum import ALL_PHASES, CANONICAL_START
44
 
 
 
 
 
 
 
 
 
45
  JOINTS = ["shoulder_pan", "shoulder_lift", "elbow_flex", "wrist_flex", "wrist_roll", "gripper"]
46
  ARM_JOINTS = JOINTS[:-1]
47
 
@@ -449,77 +460,14 @@ def _jaw_support_sensor(link: str) -> ContactSensorCfg:
449
  class SO101SceneCfg(InteractiveSceneCfg):
450
  """One SO-101, one vial, one rack, and a desk; sim2real adds the gray mat and jaw/support contact sensing."""
451
 
 
452
- robot = SO101_CFG.replace(
453
- prim_path="{ENV_REGEX_NS}/Robot",
454
- init_state=SO101_CFG.init_state.replace(
455
- pos=preset(default=(-0.05, 0.0, 0.0), sim2real=(-0.05, 0.0, BASE_HEIGHT_CORRECTION)),
456
- # +90 degrees about world Z (XYZW).
457
- rot=(0.0, 0.0, 0.7071068, 0.7071068),
458
- joint_pos=dict(zip(JOINTS, WORKSHOP_INITIAL_JOINT_POSITION, strict=True)),
459
- ),
460
- soft_joint_pos_limit_factor=0.98,
461
- )
462
 
463
- vial = RigidObjectCfg(
464
- prim_path="{ENV_REGEX_NS}/Vial",
465
- spawn=VialSpawnCfg(
466
- usd_path=str(VIAL_USD),
467
- rigid_props=preset(
468
- default=None,
469
- physx=PhysxRigidBodyCfg(solver_position_iteration_count=PHYSX_SOLVER_POSITION_ITERATIONS),
470
- ),
471
- activate_contact_sensors=True,
472
- randomize_diameters=preset(default=False, sim2real=True),
473
- ),
474
- init_state=RigidObjectCfg.InitialStateCfg(
475
- pos=TABLETOP_VIAL_POSITION,
476
- # Horizontal vial: +90 degrees about world Y (XYZW).
477
- rot=(0.0, 0.7071068, 0.0, 0.7071068),
478
- ),
479
- )
480
-
481
- rack = RigidObjectCfg(
482
- prim_path="{ENV_REGEX_NS}/Rack",
483
- spawn=sim_utils.UsdFileCfg(usd_path=str(RACK_USD), func=_spawn_usd_with_contact_material),
484
- init_state=RigidObjectCfg.InitialStateCfg(pos=(0.18, 0.08, 0.04)),
485
- )
486
-
487
- desk = AssetBaseCfg(
488
- prim_path="{ENV_REGEX_NS}/Desk",
489
- spawn=sim_utils.UsdFileCfg(usd_path=str(DESK_USD), func=_spawn_usd_with_contact_material),
490
- init_state=AssetBaseCfg.InitialStateCfg(pos=(0.22, 0.0, 0.032), rot=(0.0, 0.0, 0.7071068, 0.7071068)),
491
- )
492
-
493
- support = preset(
494
- default=None,
495
- sim2real=RigidObjectCfg(
496
- prim_path="{ENV_REGEX_NS}/Support",
497
- spawn=SupportSpawnCfg(
498
- size=(0.39, 0.39, 0.005),
499
- rigid_props=sim_utils.UsdPhysicsRigidBodyCfg(kinematic_enabled=True),
500
- collision_props=sim_utils.UsdPhysicsCollisionCfg(),
501
- mass_props=sim_utils.MassCfg(mass=1.0),
502
- physics_material=WORKSHOP_CONTACT_MATERIAL,
503
- visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.07, 0.07, 0.07)),
504
- ),
505
- init_state=RigidObjectCfg.InitialStateCfg(pos=(0.22, 0.02, 0.0325)),
506
- ),
507
- )
508
-
509
- # Unfiltered: OV PhysX cannot build a filtered contact view for the gripper link in a cloned scene.
510
- fixed_jaw_contact = ContactSensorCfg(prim_path="{ENV_REGEX_NS}/Robot/gripper", history_length=4)
511
- moving_jaw_contact = ContactSensorCfg(
512
- prim_path="{ENV_REGEX_NS}/Robot/moving_jaw_so101_v1",
513
- filter_prim_paths_expr=["{ENV_REGEX_NS}/Vial"],
514
- history_length=4,
515
- )
516
- vial_rack_contact = ContactSensorCfg(
517
- prim_path="{ENV_REGEX_NS}/Vial",
518
- filter_prim_paths_expr=["{ENV_REGEX_NS}/Rack"],
519
- history_length=4,
520
- )
521
- fixed_jaw_support = preset(default=None, sim2real=_jaw_support_sensor("gripper"))
522
- moving_jaw_support = preset(default=None, sim2real=_jaw_support_sensor("moving_jaw_so101_v1"))
523
 
524
  light = AssetBaseCfg(
525
  prim_path="/World/Light",
@@ -532,108 +480,39 @@ class SO101SceneCfg(InteractiveSceneCfg):
532
  )
533
 
534
 
 
535
  @configclass
536
  class ActionsCfg:
537
- """Joint targets relative to the measured position, matching the real SO-101 position interface."""
538
-
539
- arm_action = RelativeJointPositionActionCfg(
540
- asset_name="robot",
541
- joint_names=ARM_JOINTS,
542
- preserve_order=True,
543
- # Small offsets stall the real shoulder and elbow, so sim2real gives them larger steps.
544
- scale=preset(
545
- default=0.033,
546
- sim2real={
547
- "shoulder_pan": 0.033,
548
- "shoulder_lift": 0.12,
549
- "elbow_flex": 0.07,
550
- "wrist_flex": 0.033,
551
- "wrist_roll": 0.033,
552
- },
553
- ),
554
- use_zero_offset=True,
555
- )
556
- gripper_action = RelativeJointPositionActionCfg(
557
- asset_name="robot",
558
- joint_names=["gripper"],
559
- # Avoid opening a grasp rapidly from a small policy bias.
560
- scale=0.02,
561
- use_zero_offset=True,
562
- )
563
 
564
 
 
565
  @configclass
566
  class PolicyStateGroupCfg(ObsGroup):
567
- """Fully observed state actor inputs."""
568
-
569
- joint_pos = ObsTerm(func=mdp.joint_pos, params={"asset_cfg": SceneEntityCfg("robot", joint_names=JOINTS)})
570
- joint_vel = ObsTerm(func=mdp.joint_vel, params={"asset_cfg": SceneEntityCfg("robot", joint_names=JOINTS)})
571
- joint_target = ObsTerm(func=mdp.joint_target, params={"asset_cfg": SceneEntityCfg("robot", joint_names=JOINTS)})
572
- previous_action = ObsTerm(func=mdp.last_action)
573
- end_effector = ObsTerm(
574
- func=mdp.body_state_b,
575
- params={
576
- "body_asset_cfg": SceneEntityCfg("robot", body_names="gripper"),
577
- "base_asset_cfg": SceneEntityCfg("robot"),
578
- },
579
- )
580
- vial = ObsTerm(
581
- func=mdp.body_state_b,
582
- params={"body_asset_cfg": SceneEntityCfg("vial"), "base_asset_cfg": SceneEntityCfg("robot")},
583
- )
584
- vial_in_rack = ObsTerm(func=mdp.vial_in_rack_frame)
585
- placement = ObsTerm(func=mdp.placement_features)
586
- # Latched milestones make the once-per-episode milestone rewards Markov.
587
- progress = ObsTerm(func=mdp.progress_flags)
588
-
589
- def __post_init__(self):
590
- self.enable_corruption = False
591
- self.concatenate_terms = True
592
 
593
 
 
594
  @configclass
595
  class CriticStateGroupCfg(PolicyStateGroupCfg):
596
- """Privileged training critic inputs."""
597
-
598
- contact = ObsTerm(func=mdp.jaw_contact_flags)
599
 
600
 
 
601
  @configclass
602
  class ObservationsCfg:
603
- policy: PolicyStateGroupCfg = PolicyStateGroupCfg()
604
- critic: CriticStateGroupCfg = CriticStateGroupCfg()
605
 
606
 
 
607
  @configclass
608
  class EventsCfg:
609
- """Task-horizon resets from the physics-validated dataset plus modest vial variation."""
610
-
611
- vial_material = EventTerm(
612
- func=mdp.randomize_rigid_body_material,
613
- mode="startup",
614
- params={
615
- "asset_cfg": SceneEntityCfg("vial"),
616
- "static_friction_range": preset(default=VIAL_FRICTION_RANGE, physx=PHYSX_VIAL_FRICTION_RANGE),
617
- "dynamic_friction_range": preset(default=VIAL_FRICTION_RANGE, physx=PHYSX_VIAL_FRICTION_RANGE),
618
- "restitution_range": (0.0, 0.02),
619
- "num_buckets": 32,
620
- },
621
- )
622
- vial_mass = EventTerm(
623
- func=mdp.randomize_rigid_body_mass,
624
- mode="startup",
625
- params={
626
- "asset_cfg": SceneEntityCfg("vial"),
627
- # Newton cannot reliably infer mass from the detailed mesh.
628
- "mass_distribution_params": (0.015, 0.025),
629
- "operation": "abs",
630
- },
631
- )
632
- reset_from_dataset = EventTerm(
633
- func=mdp.ResetFromDataset,
634
- mode="reset",
635
- params={"dataset_path": str(RESET_DATASET), "sequential": False, "phase_weights": ALL_PHASES},
636
- )
637
 
638
 
639
  def _material_event(asset_cfg: SceneEntityCfg, friction_range: tuple[float, float]) -> EventTerm:
@@ -713,43 +592,18 @@ class Sim2RealEventsCfg(EventsCfg):
713
  )
714
 
715
 
 
716
  @configclass
717
  class RewardsCfg:
718
- """Sparse physical milestones, a success bonus, two dense shaping terms, and light regularization."""
719
-
720
- # Sim2real aims the pad centre slightly above the cap, favouring a shallower pinch clear of the mat.
721
- approach_progress = RewTerm(
722
- func=mdp.approach_progress, weight=1.0, params={"height_offset": preset(default=0.0, sim2real=0.008)}
723
- )
724
- held_goal = RewTerm(func=mdp.held_goal, weight=0.1)
725
- milestones = RewTerm(func=mdp.milestones, weight=10.0)
726
- success = RewTerm(func=mdp.success, weight=200.0)
727
- vial_lost = RewTerm(
728
- func=mdp.is_terminated_term, weight=-50.0, params={"term_keys": ["vial_out_of_bounds", "vial_dropped"]}
729
- )
730
- action_rate = RewTerm(func=mdp.action_rate_l2, weight=-0.002)
731
- joint_velocity = RewTerm(func=mdp.joint_vel_l2, weight=-0.0002)
732
- joint_limits = RewTerm(func=mdp.joint_pos_limits, weight=-1.0)
733
- jaw_support_force = preset(
734
- default=None,
735
- sim2real=RewTerm(func=mdp.jaw_support_force, weight=-8.0, params={"free_force": 0.25, "force_span": 2.0}),
736
- )
737
 
738
 
 
739
  @configclass
740
  class TerminationsCfg:
741
- success = DoneTerm(func=mdp.placement_success)
742
- vial_dropped = DoneTerm(func=mdp.vial_dropped)
743
- # The robot base frame is yawed +90 degrees, so these bounds are 0.5 m to its sides and 0.62 m ahead/behind.
744
- vial_out_of_bounds = DoneTerm(
745
- func=mdp.out_of_bound,
746
- params={
747
- "asset_cfg": SceneEntityCfg("vial"),
748
- "in_bound_range": {"x": (-0.55, 0.45), "y": (-0.62, 0.62), "z": (-0.01, 1.0)},
749
- },
750
- )
751
- unstable_robot = DoneTerm(func=mdp.abnormal_robot_state)
752
- time_out = DoneTerm(func=mdp.time_out, time_out=True)
753
 
754
 
755
  @configclass
@@ -779,44 +633,23 @@ class PhysicsCfg(PresetCfg):
779
  default = newton_mjwarp
780
 
781
 
 
782
  @configclass
783
  class SO101VialEnvCfg(ManagerBasedRLEnvCfg):
784
- """State task trained from physics-validated reset poses."""
785
 
786
- scene: SO101SceneCfg = SO101SceneCfg(num_envs=4096, env_spacing=0.9, replicate_physics=True)
787
- actions: ActionsCfg = ActionsCfg()
788
- observations: ObservationsCfg = ObservationsCfg()
789
- events: EventsCfg = preset(default=EventsCfg(), sim2real=Sim2RealEventsCfg())
790
- rewards: RewardsCfg = RewardsCfg()
791
- terminations: TerminationsCfg = TerminationsCfg()
 
 
792
 
793
  def __post_init__(self):
794
  self.decimation = 4
795
- # The measured shoulder response is slower, so sim2real attempts get more time.
796
- self.episode_length_s = preset(default=20.0, sim2real=30.0)
797
- self.is_finite_horizon = False
798
  self.sim.dt = 1.0 / 120.0
799
  self.sim.render_interval = self.decimation
800
  self.sim.physics = PhysicsCfg()
801
  self.sim.default_visualizer_cfg = VisualizerCfg(eye=(0.64, 0.0, 0.36), lookat=(0.19, 0.02, 0.075))
802
-
803
- def play_mode(self):
804
- """Play and evaluate complete episodes from the home pose, in dataset order.
805
-
806
- The nominal task pins the vial to its workshop material and mass; sim2real keeps its physics randomization.
807
- """
808
- from isaaclab_tutorial.utils import evaluation
809
-
810
- requested_num_envs = self.scene.num_envs
811
- super().play_mode()
812
- if evaluation.EXACT_EVALUATION_ACTIVE:
813
- self.scene.num_envs = min(requested_num_envs, evaluation.EVALUATION_EPISODES)
814
- else:
815
- self.scene.num_envs = min(self.scene.num_envs, 16)
816
- self.events.reset_from_dataset.params["sequential"] = True
817
- self.events.reset_from_dataset.params["phase_weights"] = CANONICAL_START
818
- if not isinstance(self.events, Sim2RealEventsCfg):
819
- self.events.vial_material.params.update(
820
- static_friction_range=(0.7, 0.7), dynamic_friction_range=(0.7, 0.7), restitution_range=(0.0, 0.0)
821
- )
822
- self.events.vial_mass.params["mass_distribution_params"] = (0.020, 0.020)
 
13
 
14
  import isaaclab.sim as sim_utils
15
  from isaaclab.assets import AssetBaseCfg, RigidObjectCfg
16
+ from isaaclab.envs import (
17
+ ManagerBasedRLEnvCfg,
18
+ VideoRecorderCfg, # noqa: F401 -- used by the lesson 04 replacement
19
+ )
20
  from isaaclab.envs.mdp.actions.actions_cfg import RelativeJointPositionActionCfg
21
  from isaaclab.managers import EventTermCfg as EventTerm
22
  from isaaclab.managers import ObservationGroupCfg as ObsGroup
 
45
  from isaaclab_tutorial.tasks.place_vial import mdp
46
  from isaaclab_tutorial.tasks.place_vial.reset.curriculum import ALL_PHASES, CANONICAL_START
47
 
48
+ from .lesson_scaffold import ( # noqa: F401 -- supplied for the lesson 01-04 replacements
49
+ AgentObservationGroupsCfg,
50
+ EmptyActionsCfg,
51
+ InspectionObservationsCfg,
52
+ LessonEventsCfg,
53
+ LessonTerminationsCfg,
54
+ )
55
+
56
  JOINTS = ["shoulder_pan", "shoulder_lift", "elbow_flex", "wrist_flex", "wrist_roll", "gripper"]
57
  ARM_JOINTS = JOINTS[:-1]
58
 
 
460
  class SO101SceneCfg(InteractiveSceneCfg):
461
  """One SO-101, one vial, one rack, and a desk; sim2real adds the gray mat and jaw/support contact sensing."""
462
 
463
+ # BEGIN lesson-02-robot
464
+ robot = None
 
 
 
465
+ # END lesson-02-robot
 
 
 
 
 
466
 
467
+ # BEGIN lesson-03-objects
 
 
 
 
 
 
 
 
 
 
 
 
468
+ # Add the vial, rack, desk, and contact sensors in lesson 03.
 
469
+ pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
+ # END lesson-03-objects
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
 
472
  light = AssetBaseCfg(
473
  prim_path="/World/Light",
 
480
  )
481
 
482
 
483
+ # BEGIN lesson-04-actions
484
  @configclass
485
  class ActionsCfg:
 
 
 
 
486
+ pass
487
+ # END lesson-04-actions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488
 
489
 
490
+ # BEGIN lesson-05-policy-observations
491
  @configclass
492
  class PolicyStateGroupCfg(ObsGroup):
 
 
 
 
 
 
 
 
493
+ pass
 
 
 
 
 
 
 
 
 
494
+ # END lesson-05-policy-observations
 
 
 
 
 
 
495
 
496
 
497
+ # BEGIN lesson-05-critic-observations
498
  @configclass
499
  class CriticStateGroupCfg(PolicyStateGroupCfg):
500
+ pass
 
501
+ # END lesson-05-critic-observations
502
 
503
 
504
+ # BEGIN lesson-05-observation-groups
505
  @configclass
506
  class ObservationsCfg:
507
+ pass
508
+ # END lesson-05-observation-groups
509
 
510
 
511
+ # BEGIN lesson-05-dataset-resets
512
  @configclass
513
  class EventsCfg:
 
 
 
 
 
514
+ pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
+ # END lesson-05-dataset-resets
 
 
 
 
516
 
517
 
518
  def _material_event(asset_cfg: SceneEntityCfg, friction_range: tuple[float, float]) -> EventTerm:
 
592
  )
593
 
594
 
595
+ # BEGIN lesson-05-rewards
596
  @configclass
597
  class RewardsCfg:
 
 
 
598
+ pass
 
 
 
 
 
599
+ # END lesson-05-rewards
 
 
 
 
 
 
 
 
 
600
 
601
 
602
+ # BEGIN lesson-05-terminations
603
  @configclass
604
  class TerminationsCfg:
 
 
 
 
 
605
+ pass
 
 
 
 
 
606
+ # END lesson-05-terminations
607
 
608
 
609
  @configclass
 
633
  default = newton_mjwarp
634
 
635
 
636
+ # BEGIN lesson-environment
637
  @configclass
638
  class SO101VialEnvCfg(ManagerBasedRLEnvCfg):
639
+ """Inspection scaffold; lesson 04 adds actions and lesson 05 adds training."""
640
 
641
+ scene: SO101SceneCfg = SO101SceneCfg(num_envs=1, env_spacing=0.9, replicate_physics=True)
642
+ actions: EmptyActionsCfg = EmptyActionsCfg()
643
+ observations: InspectionObservationsCfg = InspectionObservationsCfg()
 
 
644
+ events: LessonEventsCfg = LessonEventsCfg()
645
+ rewards = None
646
+ terminations = None
647
 
648
  def __post_init__(self):
649
  self.decimation = 4
 
 
650
+ self.episode_length_s = 20.0
651
  self.sim.dt = 1.0 / 120.0
652
  self.sim.render_interval = self.decimation
653
  self.sim.physics = PhysicsCfg()
654
  self.sim.default_visualizer_cfg = VisualizerCfg(eye=(0.64, 0.0, 0.36), lookat=(0.19, 0.02, 0.075))
 
 
 
 
 
 
 
 
 
655
+ # END lesson-environment
 
 
 
 
 
 
 
 
 
 
 
src/isaaclab_tutorial/tasks/place_vial/config/so101/inspection_env_cfg.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Inspect the robot and scene before adding policy controls."""
2
+
3
+ from isaaclab.envs import ManagerBasedRLEnvCfg, VideoRecorderCfg
4
+ from isaaclab.utils.configclass import configclass
5
+ from isaaclab.visualizers import VisualizerCfg
6
+
7
+ from isaaclab_tasks.utils import preset
8
+
9
+ from .env_cfg import PhysicsCfg, SO101SceneCfg
10
+ from .lesson_scaffold import EmptyActionsCfg, InspectionObservationsCfg, LessonEventsCfg
11
+
12
+
13
+ @configclass
14
+ class SO101InspectionEnvCfg(ManagerBasedRLEnvCfg):
15
+ scene: SO101SceneCfg = SO101SceneCfg(num_envs=1, env_spacing=0.9, replicate_physics=True)
16
+ actions: EmptyActionsCfg = EmptyActionsCfg()
17
+ observations: InspectionObservationsCfg = InspectionObservationsCfg()
18
+ events: LessonEventsCfg = LessonEventsCfg()
19
+ rewards = None
20
+ terminations = None
21
+
22
+ def __post_init__(self):
23
+ self.episode_length_s = 20.0
24
+ self.decimation = 4
25
+ self.sim.dt = 1.0 / 120.0
26
+ self.sim.render_interval = self.decimation
27
+ self.sim.physics = PhysicsCfg()
28
+ self.sim.default_visualizer_cfg = VisualizerCfg(eye=(0.64, 0.0, 0.36), lookat=(0.19, 0.02, 0.075))
29
+ self.video_recorders = preset(
30
+ default=[],
31
+ record_video=[VideoRecorderCfg(
32
+ source="visualizer:newton", output_dir="videos/inspection", video_length=120, fps=30,
33
+ )],
34
+ )
src/isaaclab_tutorial/tasks/place_vial/config/so101/lesson_scaffold.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Small runnable scene scaffold used before the teacher configuration is assembled."""
2
+
3
+ # Imports are supplied for the lesson snippets, including unfinished regions.
4
+ # ruff: noqa: F401
5
+
6
+ from isaaclab.managers import EventTermCfg as EventTerm
7
+ from isaaclab.managers import ObservationGroupCfg as ObsGroup
8
+ from isaaclab.managers import ObservationTermCfg as ObsTerm
9
+ from isaaclab.managers import SceneEntityCfg
10
+ from isaaclab.managers import TerminationTermCfg as DoneTerm
11
+ from isaaclab.utils.configclass import configclass
12
+
13
+ from isaaclab_tutorial.tasks.place_vial import mdp
14
+
15
+
16
+ @configclass
17
+ class EmptyActionsCfg:
18
+ pass
19
+
20
+
21
+ @configclass
22
+ class JointObservationsCfg(ObsGroup):
23
+ joint_pos = ObsTerm(func=mdp.joint_pos, params={"asset_cfg": SceneEntityCfg("robot")})
24
+ joint_vel = ObsTerm(func=mdp.joint_vel, params={"asset_cfg": SceneEntityCfg("robot")})
25
+
26
+ def __post_init__(self):
27
+ self.enable_corruption = False
28
+ self.concatenate_terms = True
29
+
30
+
31
+ @configclass
32
+ class InspectionObservationsCfg:
33
+ policy: JointObservationsCfg = JointObservationsCfg()
34
+
35
+
36
+ # BEGIN lesson-04-AgentObservationsCfg
37
+ @configclass
38
+ class AgentObservationsCfg(JointObservationsCfg):
39
+ pass
40
+ # END lesson-04-AgentObservationsCfg
41
+
42
+
43
+ @configclass
44
+ class AgentObservationGroupsCfg:
45
+ policy: AgentObservationsCfg = AgentObservationsCfg()
46
+
47
+
48
+ @configclass
49
+ class LessonEventsCfg:
50
+ reset_scene = EventTerm(func=mdp.reset_scene_to_default, mode="reset", params={"reset_joint_targets": True})
51
+
52
+ # BEGIN lesson-03-vial-mass
53
+ pass
54
+ # END lesson-03-vial-mass
55
+
56
+
57
+ # BEGIN lesson-04-LessonTerminationsCfg
58
+ @configclass
59
+ class LessonTerminationsCfg:
60
+ pass
61
+ # END lesson-04-LessonTerminationsCfg
tests/test_config.py CHANGED
@@ -42,8 +42,14 @@ def _camera(*presets):
42
 
43
  def test_tasks_are_registered_with_rsl_rl_entry_points():
44
  ids = sorted(task for task in gym.registry if task.startswith("IsaacTutorial-"))
 
 
 
45
- assert ids == ["IsaacTutorial-Place-Vial-SO101", "IsaacTutorial-Place-Vial-SO101-Camera"]
 
46
- state, camera = (gym.spec(task).kwargs for task in ids)
 
 
47
  assert state["env_cfg_entry_point"].endswith("env_cfg:SO101VialEnvCfg")
48
  assert state["rsl_rl_cfg_entry_point"].endswith("rsl_rl_ppo_cfg:SO101StatePPORunnerCfg")
49
  assert camera["env_cfg_entry_point"].endswith("camera_env_cfg:SO101VialCameraEnvCfg")
 
42
 
43
  def test_tasks_are_registered_with_rsl_rl_entry_points():
44
  ids = sorted(task for task in gym.registry if task.startswith("IsaacTutorial-"))
45
+ assert ids == [
46
+ "IsaacTutorial-Inspect-SO101",
47
+ "IsaacTutorial-Place-Vial-SO101",
48
+ "IsaacTutorial-Place-Vial-SO101-Camera",
49
+ ]
50
+ inspection, state, camera = (gym.spec(task).kwargs for task in ids)
51
+ assert inspection["env_cfg_entry_point"].endswith("inspection_env_cfg:SO101InspectionEnvCfg")
52
+ assert "rsl_rl_cfg_entry_point" not in inspection
53
  assert state["env_cfg_entry_point"].endswith("env_cfg:SO101VialEnvCfg")
54
  assert state["rsl_rl_cfg_entry_point"].endswith("rsl_rl_ppo_cfg:SO101StatePPORunnerCfg")
55
  assert camera["env_cfg_entry_point"].endswith("camera_env_cfg:SO101VialCameraEnvCfg")
tests/test_startup.py CHANGED
@@ -18,7 +18,7 @@ def test_task_config_does_not_load_usd_before_runtime():
18
  from isaaclab_tasks.utils.parse_cfg import load_cfg_from_registry
19
 
20
  load_external_tasks()
21
- load_cfg_from_registry("IsaacTutorial-Place-Vial-SO101", "env_cfg_entry_point")
22
  assert "pxr" not in sys.modules, "Task configuration loaded OpenUSD before runtime startup"
23
  """
24
  ),
 
18
  from isaaclab_tasks.utils.parse_cfg import load_cfg_from_registry
19
 
20
  load_external_tasks()
21
+ load_cfg_from_registry("IsaacTutorial-Inspect-SO101", "env_cfg_entry_point")
22
  assert "pxr" not in sys.modules, "Task configuration loaded OpenUSD before runtime startup"
23
  """
24
  ),