Skip to content

Commit e66eac3

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

16 files changed

Lines changed: 1046 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: 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)