Skip to content

Commit 20e2d41

Browse files
committed
Added a feature to modify base env, showed using bin stack example for skillgen
1 parent 0a70f01 commit 20e2d41

17 files changed

Lines changed: 1143 additions & 5 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ env.bak/
158158
venv.bak/
159159
# The env/ pattern above targets Python virtualenvs; re-include our env interface package.
160160
!isaac_autodata_interfaces/env/
161+
!isaac_autodata_tests/interfaces/env/
161162

162163
# Spyder project settings
163164
.spyderproject
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Environment Profiles: bin-stack SkillGen on the neutral task id
2+
3+
Design record for the `EnvironmentProfile` mechanism
4+
(`isaac_autodata_interfaces/env/env_profile.py`) and its first user, the Franka bin-stack
5+
SkillGen variant.
6+
7+
## Problem
8+
9+
Bin-stack differs from plain cube-stack only in the *scene*: a sorting bin, different cube reset
10+
distributions, and stiffer contact solving. Upstream Isaac Lab expresses this as specialized env
11+
subclasses and ids (`Isaac-Stack-Cube-Bin-Franka-IK-Rel-Mimic-v0`), coupling scene variants to
12+
algorithm-named env ids and `isaaclab_mimic`. AutoData already runs MimicGen and SkillGen
13+
cube-stack on the neutral `Isaac-Stack-Cube-Franka-IK-Rel-v0`; bin-stack should not be the reason
14+
to reintroduce specialized env classes.
15+
16+
## Mechanism
17+
18+
An environment profile is a YAML overlay applied to the parsed env config between
19+
`parse_env_cfg` and `gym.make` (hooked into `setup_env_config`, shared by
20+
`generate_dataset.py` and `annotate_demos.py` via `--env_profile`). It relies on verified
21+
Isaac Lab behavior: `InteractiveScene._add_entities_from_cfg` and `EventManager._prepare_terms`
22+
iterate the config instance's `__dict__`, and skip terms set to `None` — so dynamically set
23+
scene assets and event terms are consumed exactly like class-declared ones, and
24+
`setattr(events, name, None)` removes a term.
25+
26+
Profile sections:
27+
28+
- `scene.rigid_objects` — assets to add (`RigidObjectCfg` from a USD file).
29+
- `scene.rigid_body_properties` — physics patches on existing assets' spawn configs.
30+
- `reset_events.remove / override / add` — event-term changes; added terms reference their
31+
function as a `"module.path:function"` string resolved via `string_to_callable`, so the
32+
upstream coupling lives in the YAML, not in AutoData imports. `*_cfg`/`*_cfgs` params name
33+
scene assets and become `SceneEntityCfg` at apply time.
34+
- `planner` — name of the cuRobo planner profile tuned for the resulting scene, resolved via
35+
the explicit registry in `CuroboPlannerCfg.from_profile`. This replaces env-id substring
36+
matching (`from_task_name`), which on the neutral id would silently pick the cube config
37+
(wrong `static_objects`, gripper, retreat, and debug/visualization settings). Without a
38+
profile the substring fallback is preserved, so existing runs are byte-identical.
39+
40+
## Ownership boundaries
41+
42+
| Concern | Owner |
43+
|---|---|
44+
| Subtasks, constraints, generation policy | TaskDescriptor YAML (`tasks/*.yaml`) |
45+
| Robot frames/kinematics (`eef_offset`) | Embodiment YAML (`embodiments/*.yaml`) |
46+
| Scene additions, reset randomization, planner-profile name | EnvironmentProfile YAML (`environments/*.yaml`) |
47+
| Planner tuning per named profile | `CuroboPlannerCfg.from_profile` registry |
48+
| Generation plumbing (terminations/recorders/obs) | `setup_env_config` |
49+
50+
The upstream bin env's `body_offset`/`ee_frame` = 0.0 is the SkillGen frame convention that this
51+
repo deliberately replaced with the embodiment `eef_offset` (0.1034 back to `panda_hand`);
52+
profiles must not replicate it.
53+
54+
## Bin-stack specifics
55+
56+
`environments/franka_bin_stack.yaml` reproduces the upstream deltas verbatim
57+
(`bin_stack_joint_pos_env_cfg.py`): bin fixed at (0.4, 0, 0.0203); cube_1 (stack base) pinned at
58+
the same spot inside the bin; cube_2/cube_3 randomized at x(0.65–0.70), y(±0.18),
59+
min_separation 0.1; `solver_position_iteration_count=40` on the cubes. One deliberate deviation:
60+
upstream's dead third element in the yaw range tuple is dropped. The success term is untouched —
61+
the bin env inherits `cubes_stacked` unchanged.
62+
63+
**Quaternion convention:** this repo's pinned Isaac Lab defines
64+
`InitialStateCfg.rot` as **(x, y, z, w)** — identity is `(0, 0, 0, 1)`, not the `(1, 0, 0, 0)`
65+
of older wxyz-convention Isaac Lab. Profile `rotation` follows the same (x, y, z, w) order.
66+
Getting this wrong flips the asset 180° about X **on the USD stage only**: reset events reposition
67+
the physics body (via Fabric) but never write back to USD, so the sim renders correctly while the
68+
planner — which builds its static collision world from the stage — sees the asset inverted.
69+
Upstream's odd-looking bin `init_state.rot=(0, 0, 0, 0.1)` is simply xyzw-identity with a typo'd
70+
w, normalized away. Corollary: a profile asset's spawn position/rotation must match its pinned
71+
reset event, because the stage keeps the spawn pose forever.
72+
73+
The planner needs no code changes for the bin: the collision world is extracted from the live
74+
USD stage per env, and `_is_static` lowercase-substring matching makes the scene asset name
75+
`blue_sorting_bin` match the bin planner profile's `static_objects=["bin", "table"]`. Keep added
76+
asset names substring-matching the chosen planner profile's `static_objects`.
77+
78+
`tasks/franka_bin_stack_skillgen.yaml` is structurally identical to the cube-stack SkillGen
79+
descriptor (same four subtasks and signals) with `action_noise: 0.0` (bin walls leave little
80+
clearance) — the scene difference lives entirely in the profile. It reuses the cube-stack
81+
annotated SkillGen source dataset; MimicGen's per-object transforms retarget the skill segments
82+
to the bin scene, and the planner avoids the bin during transits.
83+
84+
## Caveats
85+
86+
- **Dataset provenance**: the generated HDF5 records only the base env id. Replaying or
87+
annotating a profile-generated dataset without `--env_profile` builds a scene missing the
88+
added assets, and `reset_to` will hit unknown state entries. The generation-result sidecar
89+
records `env_profile: {name, path, planner}`; stamping the resolved profile into the HDF5
90+
`env_args` via a recorder hook is a follow-up.
91+
- **Bin-native auto-annotation** is not possible today: the neutral env's `subtask_terms` group
92+
lacks `stack_2`, and `annotate_demos.py` rejects `--auto` for SkillGen descriptors. Fine for
93+
the current workflow (bin reuses the cube-stack annotated dataset). A future `observations:`
94+
profile section would unblock it.
95+
- **cuRobo v2** is not wired into `generate_dataset.py` (v1 only); when it is, it should adopt
96+
the same planner-profile names. The v2 mesh-SDF false-positive issue for small/concave
97+
obstacles (bins) is fixed upstream as of dev34 (see `curobo_v2_mesh_collision_bug.md`).
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright (c) 2026, The Isaac AutoData Project Developers.
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# Environment profile: Franka cube stacking inside a blue sorting bin, on the neutral IK-Rel task.
7+
#
8+
# Overlays the scene and reset-event deltas of the upstream bin-stack env config
9+
# (bin_stack_joint_pos_env_cfg.py) so no specialized env id is needed. Spawn poses of pinned
10+
# assets match their reset events: the planner's collision world reads spawn poses from the
11+
# USD stage, not physics resets.
12+
13+
name: franka_bin_stack
14+
description: Blue sorting bin fixed at table center with the blue cube inside; red and green cubes spawn outside the bin.
15+
base_env: Isaac-Stack-Cube-Franka-IK-Rel-v0
16+
planner: franka_stack_cube_bin
17+
18+
scene:
19+
rigid_objects:
20+
blue_sorting_bin:
21+
prim_path: "{ENV_REGEX_NS}/BlueSortingBin"
22+
usd_path: "{ISAACLAB_NUCLEUS_DIR}/Mimic/nut_pour_task/nut_pour_assets/sorting_bin_blue.usd"
23+
position: [0.4, 0.0, 0.0203]
24+
rotation: [0.0, 0.0, 0.0, 1.0] # identity (x, y, z, w)
25+
scale: [1.1, 1.6, 3.3]
26+
# Stiffer contact solving for cubes settling against the bin walls (base task uses 16).
27+
rigid_body_properties:
28+
cube_1: {solver_position_iteration_count: 40}
29+
cube_2: {solver_position_iteration_count: 40}
30+
cube_3: {solver_position_iteration_count: 40}
31+
32+
reset_events:
33+
remove: [randomize_cube_positions]
34+
add:
35+
# Bin and cube_1 (the stack base) are pinned at the table center; cube_2/cube_3 randomize
36+
# outside the bin.
37+
reset_blue_bin_pose:
38+
func: "isaaclab_tasks.manager_based.manipulation.stack.mdp.franka_stack_events:randomize_object_pose"
39+
mode: reset
40+
params:
41+
pose_range: {x: [0.4, 0.4], y: [0.0, 0.0], z: [0.0203, 0.0203], yaw: [0.0, 0.0]}
42+
min_separation: 0.0
43+
asset_cfgs: [blue_sorting_bin]
44+
reset_cube_1_pose:
45+
func: "isaaclab_tasks.manager_based.manipulation.stack.mdp.franka_stack_events:randomize_object_pose"
46+
mode: reset
47+
params:
48+
pose_range: {x: [0.4, 0.4], y: [0.0, 0.0], z: [0.0203, 0.0203], yaw: [0.0, 0.0]}
49+
min_separation: 0.0
50+
asset_cfgs: [cube_1]
51+
reset_cube_pose:
52+
func: "isaaclab_tasks.manager_based.manipulation.stack.mdp.franka_stack_events:randomize_object_pose"
53+
mode: reset
54+
params:
55+
pose_range: {x: [0.65, 0.70], y: [-0.18, 0.18], z: [0.0203, 0.0203], yaw: [-1.0, 1.0]}
56+
min_separation: 0.1
57+
asset_cfgs: [cube_2, cube_3]

‎isaac_autodata_examples/generate_dataset.py‎

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
--alg {mimicgen|dexmimicgen|skillgen} \\
1414
--task_descriptor <task_descriptor.yaml> \\
1515
--embodiment <embodiment.yaml> \\
16+
--env_profile <environment_profile.yaml> \\
1617
--input_file <source.hdf5> \\
1718
--output_file <out.hdf5> \\
1819
--generation_num_trials <N> \\
@@ -61,6 +62,15 @@
6162
required=True,
6263
help="Path to the embodiment YAML (defines the robot's pose ↔ action transforms).",
6364
)
65+
parser.add_argument(
66+
"--env_profile",
67+
type=str,
68+
default=None,
69+
help=(
70+
"Optional environment profile YAML overlaid on the base task before env creation "
71+
"(scene additions, reset randomization, motion-planner profile)."
72+
),
73+
)
6474
parser.add_argument("--generation_num_trials", type=int, default=None, help="Number of demos to generate.")
6575
parser.add_argument("--num_envs", type=int, default=1, help="Number of parallel environments.")
6676
parser.add_argument("--input_file", type=str, required=True, help="Source dataset HDF5 file.")
@@ -104,6 +114,7 @@
104114
from isaac_autodata_interfaces.datastream import Datastream # noqa: E402
105115
from isaac_autodata_interfaces.embodiments import embodiment_adapter_from_yaml # noqa: E402
106116
from isaac_autodata_interfaces.env import ( # noqa: E402
117+
EnvironmentProfile,
107118
env_loop,
108119
get_env_name_from_dataset,
109120
setup_env_config,
@@ -209,18 +220,23 @@ def setup_async_generation(
209220
}
210221

211222

212-
def _build_motion_planners(datastream, num_envs: int, env_name: str) -> dict:
223+
def _build_motion_planners(datastream, num_envs: int, env_name: str, planner_profile: str | None = None) -> dict:
213224
"""Construct one cuRobo v1 motion planner per env_id satisfying the SkillGen interface.
214225
215226
Planners read all world state (collision-geometry source, object poses, joint configuration)
216227
through the shared :class:`Datastream`, so they never touch the env/robot handles directly.
228+
The planner config comes from ``planner_profile`` (named by the environment profile) when
229+
given, else from task-name matching.
217230
"""
218231
from isaac_autodata_interfaces.motion_planners.curobo.curobo_planner import CuroboPlanner
219232
from isaac_autodata_interfaces.motion_planners.curobo.curobo_planner_cfg import CuroboPlannerCfg
220233

221234
planners: dict[int, CuroboPlanner] = {}
222235
for env_id in range(num_envs):
223-
planner_config = CuroboPlannerCfg.from_task_name(env_name)
236+
if planner_profile is not None:
237+
planner_config = CuroboPlannerCfg.from_profile(planner_profile)
238+
else:
239+
planner_config = CuroboPlannerCfg.from_task_name(env_name)
224240
# Visualization is rerun-based; limit to env_id 0 to keep simulation responsive.
225241
if env_id != 0:
226242
planner_config.visualize_spheres = False
@@ -266,13 +282,18 @@ def main() -> None:
266282
alg_cls = REGISTERED_ALGORITHMS[args_cli.alg]
267283
generation_policy_params.use_skillgen = alg_cls.uses_subtask_start_signals
268284

285+
# The environment profile, when given, overlays scene/reset changes onto the base task and
286+
# names the motion-planner profile tuned for the resulting scene.
287+
env_profile = EnvironmentProfile.from_yaml(args_cli.env_profile) if args_cli.env_profile else None
288+
269289
env_cfg, success_term = setup_env_config(
270290
env_name=env_name,
271291
output_dir=output_dir,
272292
output_file_name=output_file_name,
273293
num_envs=args_cli.num_envs,
274294
device=args_cli.device,
275295
generation_policy_params=generation_policy_params,
296+
env_profile=env_profile,
276297
)
277298

278299
env = gym.make(env_name, cfg=env_cfg).unwrapped
@@ -295,7 +316,12 @@ def main() -> None:
295316
motion_planners: dict | None = None
296317
alg_kwargs: dict = {}
297318
if args_cli.alg == "skillgen":
298-
motion_planners = _build_motion_planners(datastream, args_cli.num_envs, env_name)
319+
motion_planners = _build_motion_planners(
320+
datastream,
321+
args_cli.num_envs,
322+
env_name,
323+
planner_profile=env_profile.planner if env_profile else None,
324+
)
299325
alg_kwargs["motion_planners"] = motion_planners
300326
algorithm = get_algorithm(args_cli.alg, **alg_kwargs)
301327

@@ -338,6 +364,11 @@ def main() -> None:
338364
algorithm=args_cli.alg,
339365
requested_trials=generation_policy_params.num_trials,
340366
stats=async_components["stats"],
367+
env_profile=(
368+
{"name": env_profile.name, "path": args_cli.env_profile, "planner": env_profile.planner}
369+
if env_profile
370+
else None
371+
),
341372
)
342373
finally:
343374
env.close()
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Copyright (c) 2026, The Isaac AutoData Project Developers.
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# Franka bin cube stack (SkillGen). Runs on the neutral Isaac-Stack-Cube-Franka-IK-Rel-v0 task
7+
# with the franka_bin_stack environment profile (--env_profile) and reuses the cube-stack
8+
# annotated SkillGen source dataset. action_noise stays 0.0: the bin walls leave little
9+
# clearance for perturbed skill segments.
10+
11+
name: franka_bin_stack_skillgen
12+
description: Stack red and green cubes onto the blue cube inside a bin, avoiding the bin (SkillGen).
13+
algo: skillgen
14+
15+
generation_policy:
16+
name: franka_bin_stack_skillgen
17+
seed: 1
18+
num_trials: 10
19+
guarantee_success: true
20+
keep_failed: false
21+
source_dataset_path: null
22+
generation_path: null
23+
task_name: null
24+
use_skillgen: true
25+
use_navigation_controller: false
26+
select_src_per_subtask: true
27+
select_src_per_arm: false
28+
transform_first_robot_pose: false
29+
interpolate_from_last_target_pose: true
30+
31+
subtasks:
32+
franka:
33+
- object_ref: cube_2
34+
description: Grasp red cube.
35+
subtask_term_signal: grasp_1
36+
selection_strategy: nearest_neighbor_object
37+
selection_strategy_kwargs:
38+
nn_k: 3
39+
subtask_term_offset_range: [0, 0]
40+
action_noise: 0.0
41+
num_interpolation_steps: 0
42+
num_fixed_steps: 0
43+
apply_noise_during_interpolation: false
44+
45+
- object_ref: cube_1
46+
description: Stack red cube on top of blue cube, inside the bin.
47+
subtask_term_signal: stack_1
48+
selection_strategy: nearest_neighbor_object
49+
selection_strategy_kwargs:
50+
nn_k: 3
51+
subtask_term_offset_range: [0, 0]
52+
action_noise: 0.0
53+
num_interpolation_steps: 0
54+
num_fixed_steps: 0
55+
apply_noise_during_interpolation: false
56+
57+
- object_ref: cube_3
58+
description: Grasp green cube.
59+
subtask_term_signal: grasp_2
60+
selection_strategy: nearest_neighbor_object
61+
selection_strategy_kwargs:
62+
nn_k: 3
63+
subtask_term_offset_range: [0, 0]
64+
action_noise: 0.0
65+
num_interpolation_steps: 0
66+
num_fixed_steps: 0
67+
apply_noise_during_interpolation: false
68+
69+
# Final subtask: SkillGen *does* need a term signal here (unlike MimicGen), so the
70+
# planner knows when the last skill segment finishes.
71+
- object_ref: cube_2
72+
description: Stack green cube on top of red cube, inside the bin.
73+
subtask_term_signal: stack_2
74+
selection_strategy: nearest_neighbor_object
75+
selection_strategy_kwargs:
76+
nn_k: 3
77+
subtask_term_offset_range: [0, 0]
78+
action_noise: 0.0
79+
num_interpolation_steps: 0
80+
num_fixed_steps: 0
81+
apply_noise_during_interpolation: false

‎isaac_autodata_interfaces/env/__init__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55

66
"""Data generation interfaces for Isaac Lab environments."""
77

8+
from isaac_autodata_interfaces.env.env_profile import EnvironmentProfile
89
from isaac_autodata_interfaces.env.isaaclab_env_interface import (
10+
apply_env_profile,
911
env_loop,
1012
get_env_name_from_dataset,
1113
setup_env_config,
1214
setup_output_paths,
1315
)
1416

1517
__all__ = [
18+
"EnvironmentProfile",
19+
"apply_env_profile",
1620
"get_env_name_from_dataset",
1721
"setup_output_paths",
1822
"env_loop",

0 commit comments

Comments
 (0)