Repository navigation
Add heterogeneous clone scene composition - #6529
Conversation
Greptile SummaryThis PR introduces heterogeneous clone-scene composition: a new
Confidence Score: 3/5Two real concerns need resolution before merging: the mutable-list default on The composition engine itself (
Important Files Changed
|
| if len(asset_names) != len(variant_counts): | ||
| raise ValueError(f"Expected one variant count per asset, got {len(variant_counts)} and {len(asset_names)}.") | ||
| if not asset_names: | ||
| raise ValueError("Expected at least one asset name.") | ||
| if any(count <= 0 for count in variant_counts): | ||
| raise ValueError("Variant counts must be positive.") | ||
|
|
||
| if not clone_combinations: | ||
| rows = itertools.product(*[range(count) for count in variant_counts]) | ||
| return torch.tensor(list(rows), dtype=torch.long, device=device) | ||
|
|
There was a problem hiding this comment.
Empty
InclusionSet(assets=[]) silently produces all-inactive rows
make_valid_clone_combinations does not validate that each InclusionSet.assets list is non-empty. An entry like InclusionSet(assets=[]) is accepted: combination_assets for that row becomes an empty intersection, and the loop marks every claimed asset as inactive, producing a valid-looking tensor row of all (-1,) entries. The result is a set of environments that receive none of the task-specific assets — an empty env that is almost certainly unintended and produces no validation error.
Consider adding if not combination.assets: raise ValueError(...) before the intersection step.
| def _make_scene( | ||
| source: InteractiveSceneCfg, | ||
| entities: dict[str, AssetBaseCfg], | ||
| slots: dict[str, str], | ||
| rows: list[InclusionSet], | ||
| ) -> InteractiveSceneCfg: | ||
| """Build a configclass that InteractiveScene can parse normally.""" | ||
| clone_cfg = copy.deepcopy(source.clone_cfg) | ||
| clone_cfg.clone_combinations = rows | ||
| values = {name: copy.deepcopy(getattr(source, name)) for name in InteractiveSceneCfg.__dataclass_fields__} | ||
| values["clone_cfg"] = clone_cfg | ||
| namespace = {"__module__": __name__, "__doc__": "Scene configuration produced by scene_add.", **entities} | ||
| scene_type = configclass(type("_AddedSceneCfg", (InteractiveSceneCfg,), namespace)) | ||
| scene_cfg = scene_type(**values) | ||
| setattr(scene_type, _SLOT_METADATA, slots) | ||
| return scene_cfg |
There was a problem hiding this comment.
Dynamically-created
_AddedSceneCfg class is not picklable
type("_AddedSceneCfg", (InteractiveSceneCfg,), namespace) creates a fresh class on every scene_add call. Even though __module__ is set to scene_composition.__name__, the class is not actually importable from that module — pickle looks up _AddedSceneCfg in isaaclab.scene.scene_composition at deserialisation time and raises AttributeError. Any code path that tries to serialise a composed scene config (e.g., checkpointing, Ray workers, multiprocessing spawn mode) will fail silently or with a confusing error. Consider registering the produced type in the module dict (sys.modules[__name__]._AddedSceneCfg = scene_type) or documenting this constraint in the docstring.
d9819f7 to
4d8df66
Compare
4d8df66 to
78b2505
Compare
# Description
Replaces expanded `/World/envs/env_.*` prim paths with the canonical
`{ENV_REGEX_NS}` macro across task scene configurations, declares the
Franka Cabinet robot and end-effector frame in the scene configuration
instead of mutating them after construction, and aligns the Reach and
OpenArm Lift table bindings and initial states.
These are behavior-preserving config normalizations (`{ENV_REGEX_NS}`
expands to the same regex at scene construction). They are split out of
#6529, which composes task scenes and requires the canonical
literal-binding form.
## Type of change
- This change requires a documentation update (changelog fragment
included)
## Checklist
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have added a changelog fragment under
`source/<pkg>/changelog.d/`
- [x] My name is in the `CONTRIBUTORS.md`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
a6e5a33 to
16054a6
Compare
|
This PR is missing scripts/demos/multitask_clone_scene.py which is reported in the PR description! |
e7ee838 to
e66e04d
Compare
AntoineRichard
left a comment
There was a problem hiding this comment.
Some bits are overly complicated for no reasons that I can see. Please simplify a bit :D
| def _registered_task_ids() -> list[str]: | ||
| """Return registered task IDs owned by isaaclab_tasks, skipping ``-Play`` variants.""" | ||
| task_ids = [] | ||
| for task_spec in gym.registry.values(): | ||
| if task_spec.id.endswith("-Play"): | ||
| continue | ||
| entry_point = task_spec.kwargs.get("env_cfg_entry_point") | ||
| if isinstance(entry_point, str): | ||
| module_name = entry_point.split(":", maxsplit=1)[0] | ||
| else: | ||
| module_name = getattr(entry_point, "__module__", type(entry_point).__module__) | ||
| if module_name.startswith("isaaclab_tasks."): | ||
| task_ids.append(task_spec.id) | ||
| return sorted(task_ids) |
There was a problem hiding this comment.
Why do we need a private method here?
There was a problem hiding this comment.
I would return a bool, and a string.
| def reject_scene(env_cfg: object) -> str | None: | ||
| """Return why one resolved task config is outside this demo's scope.""" | ||
| # inspect cfg metadata only: importing a backend package to type-check would | ||
| # defeat the resolvable class_type pattern (backends load via cfg resolution). | ||
| physics_cfg = env_cfg.sim.physics | ||
| if physics_cfg is not None and any( | ||
| cls.__module__.startswith("isaaclab_newton.") for cls in type(physics_cfg).__mro__ | ||
| ): | ||
| return f"Newton physics config {type(physics_cfg).__name__}" | ||
|
|
||
| scene_cfg = env_cfg.scene | ||
| fields = [value for name, value in vars(scene_cfg).items() if name not in InteractiveSceneCfg.__dataclass_fields__] | ||
| # flat terrain importers always place their plane at the stage origin | ||
| floor_levels = [0.0 for value in fields if isinstance(value, TerrainImporterCfg) and value.terrain_type == "plane"] | ||
| floor_levels += [ | ||
| value.init_state.pos[2] | ||
| for value in fields | ||
| if isinstance(value, AssetBaseCfg) and isinstance(value.spawn, sim_utils.GroundPlaneCfg) | ||
| ] | ||
| if not floor_levels: | ||
| return "no declarative flat floor" | ||
| mismatched = [level for level in floor_levels if abs(level) > 1e-6] | ||
| if mismatched: | ||
| return f"floor level {mismatched[0]} is not 0" | ||
| return None |
There was a problem hiding this comment.
Why would this one be public?
| env_cfg, _ = resolve_task_config(task_id, "") | ||
| reason = reject_scene(env_cfg) | ||
| if reason is not None: | ||
| skipped.append((task_id, reason)) | ||
| continue | ||
| accepted_ids.append(task_id) | ||
| accepted_scenes.append(env_cfg.scene) |
There was a problem hiding this comment.
This is a bit ugly. Why do not return a bool and a string?
Something like if not rejected then add it. etc...
| if skipped: | ||
| print("\n[INFO] Skipped task scenes outside the composition scope:") | ||
| for task_id, reason in skipped: | ||
| print(f" {task_id}: {reason}") | ||
| if len(accepted_ids) < 2: | ||
| raise ValueError("Select at least two supported task scenes.") | ||
| return accepted_ids, accepted_scenes |
There was a problem hiding this comment.
Do we really need such a fancy system to skip tasks?
There was a problem hiding this comment.
I feel like the task selection is over engineered. I love over engineered stuff but this is making the readability of the code way worse. Why not pick a set of tasks here, it will be fixed yes, but at least we know what we load? I feel like the current code is opening the door to breaking sutff.
137b86b to
34f0a27
Compare
34f0a27 to
721870c
Compare
The develop merge resolution hoisted the AssetBaseCfg import back to module level, regressing the kitless-importability contract enforced by test_factories_are_kitless_in_fresh_process: config construction must not import isaaclab.assets; only scene composition pays for it. Restore the deferred import inside _scene_assets and keep the annotation-only import under TYPE_CHECKING.
Review feedback: 'this' reads like C++'s this-pointer and the paired tuple assignments bundled unrelated values. Rename add()'s operands to target/source (matching the existing target_name/source_name locals), rename left/right to target_assets/source_assets, and give base_fields, target_names, available, added_names and used_names one assignment each.
|
Addressed the review comments in 9b98503: renamed 🤖 Generated with Claude Code |
…6534) # Description Replaces expanded `/World/envs/env_.*` prim paths with the canonical `{ENV_REGEX_NS}` macro across task scene configurations, declares the Franka Cabinet robot and end-effector frame in the scene configuration instead of mutating them after construction, and aligns the Reach and OpenArm Lift table bindings and initial states. These are behavior-preserving config normalizations (`{ENV_REGEX_NS}` expands to the same regex at scene construction). They are split out of isaac-sim#6529, which composes task scenes and requires the canonical literal-binding form. ## Type of change - This change requires a documentation update (changelog fragment included) ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` - [x] My name is in the `CONTRIBUTORS.md` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
> [!IMPORTANT] > **Depends on isaac-sim#6534** (task scene-binding normalization). Merge isaac-sim#6534 first — this PR's task-side diffs assume the canonical `{ENV_REGEX_NS}` bindings introduced there. ## Summary - Added heterogeneous clone-plan support so one `InteractiveScene` can instantiate different task asset sets across different environment rows. - Added `scene_add` composition utilities for folding registered task scene configs into a single declarative scene with clone combinations. - Added `scripts/demos/multitask_clone_scene.py`, which composes supported task scenes, skips global floor/light assets, and runs the resulting scene directly without task envs or managers. - Converted env-local static task props such as tables, stands, and static scene props from plain `AssetBaseCfg` to kinematic `RigidObjectCfg`, so they participate in normal physics/USD replication instead of needing scene-level special <img width="1349" height="752" alt="Screenshot from 2026-07-14 19-56-19" src="https://github.com/user-attachments/assets/f8a06a24-e7d2-4532-8b83-086d7c803124" /> handling. ## Motivation This PR is meant to support multitask scene demos where each cloned environment may contain a different robot/task asset bundle. The previous clone flow assumed every env received the same source assets, which made it hard to build one scene from multiple existing task configs without manually rewriting each task into a shared schema. The composition path keeps the existing task scene configs as the source of truth. It reads their declarative scene fields, deduplicates equivalent asset slots, and emits clone-combination rows that the cloner can use to populate only the assets needed by each task group. ## Design Notes - `scene_add` only composes env-scoped, spawned, physics-backed assets rooted at literal `{ENV_REGEX_NS}/Leaf` paths. Global floors/lights should be skipped during composition and added once to the composed scene. - Plain env-scoped `AssetBaseCfg` is rejected in `scene_add`; env-local props that need per-env instances should be modeled as `RigidObjectCfg` or `ArticulationCfg` instead. - Static props that should not move are represented as kinematic rigid objects, which keeps them fixed while letting the existing backend replication paths handle them. - The demo filters out scenes outside its current scope, including Newton-only scenes and scenes without a level-0 declarative flat floor. ## Test Plan - `./isaaclab.sh -p -m py_compile source/isaaclab/isaaclab/scene/interactive_scene.py source/isaaclab/isaaclab/scene/scene_composition.py source/isaaclab_tasks/isaaclab_tasks/core/lift/lift_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/core/lift/config/franka_soft/franka_soft_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/core/reach/reach_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/stack/stack_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/stack/stack_instance_randomize_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/deploy/reach/reach_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/deploy/gear_assembly/gear_assembly_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/lift/config/openarm/lift_openarm_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/reach/config/openarm/unimanual/reach_openarm_uni_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/core/lift/config/franka_soft/franka_cloth_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/assemble_trocar/g129_dex3_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/place/config/agibot/place_toy2box_rmp_rel_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/place/config/agibot/place_upright_mug_rmp_rel_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/pick_place/nutpour_gr1t2_base_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/pick_place/exhaustpipe_gr1t2_base_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/locomanip_pick_place/locomanipulation_g1_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/locomanip_pick_place/fixed_base_upper_body_ik_g1_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/pick_place/pickplace_gr1t2_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/pick_place/pickplace_unitree_g1_inspire_hand_env_cfg.py` - Searched for remaining env-scoped plain table/stand/scene/cube `AssetBaseCfg` assignments after converting static props to `RigidObjectCfg`.
Important
Depends on #6534 (task scene-binding normalization). Merge #6534 first — this PR's task-side diffs assume the canonical
{ENV_REGEX_NS}bindings introduced there.Summary
InteractiveScenecan instantiate different task asset sets across different environment rows.scene_addcomposition utilities for folding registered task scene configs into a single declarative scene with clone combinations.scripts/demos/multitask_clone_scene.py, which composes supported task scenes, skips global floor/light assets, and runs the resulting scene directly without task envs or managers.AssetBaseCfgto kinematicRigidObjectCfg, so they participate in normal physics/USD replication instead of needing scene-level specialMotivation
This PR is meant to support multitask scene demos where each cloned environment may contain a different robot/task asset bundle. The previous clone flow assumed every env received the same source assets, which made it hard to build one scene from multiple existing task configs without manually rewriting each task into a shared schema.
The composition path keeps the existing task scene configs as the source of truth. It reads their declarative scene fields, deduplicates equivalent asset slots, and emits clone-combination rows that the cloner can use to populate only the assets needed by each task group.
Design Notes
scene_addonly composes env-scoped, spawned, physics-backed assets rooted at literal{ENV_REGEX_NS}/Leafpaths. Global floors/lights should be skipped during composition and added once to the composed scene.AssetBaseCfgis rejected inscene_add; env-local props that need per-env instances should be modeled asRigidObjectCfgorArticulationCfginstead.Test Plan
./isaaclab.sh -p -m py_compile source/isaaclab/isaaclab/scene/interactive_scene.py source/isaaclab/isaaclab/scene/scene_composition.py source/isaaclab_tasks/isaaclab_tasks/core/lift/lift_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/core/lift/config/franka_soft/franka_soft_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/core/reach/reach_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/stack/stack_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/stack/stack_instance_randomize_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/deploy/reach/reach_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/deploy/gear_assembly/gear_assembly_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/lift/config/openarm/lift_openarm_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/reach/config/openarm/unimanual/reach_openarm_uni_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/core/lift/config/franka_soft/franka_cloth_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/assemble_trocar/g129_dex3_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/place/config/agibot/place_toy2box_rmp_rel_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/place/config/agibot/place_upright_mug_rmp_rel_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/pick_place/nutpour_gr1t2_base_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/pick_place/exhaustpipe_gr1t2_base_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/locomanip_pick_place/locomanipulation_g1_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/locomanip_pick_place/fixed_base_upper_body_ik_g1_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/pick_place/pickplace_gr1t2_env_cfg.py source/isaaclab_tasks/isaaclab_tasks/contrib/pick_place/pickplace_unitree_g1_inspire_hand_env_cfg.pyAssetBaseCfgassignments after converting static props toRigidObjectCfg.