Repository navigation
Spawn object-set members from their own spawn configurations - #1434
Conversation
🤖 Isaac Lab-Arena Review BotSummary
Findings🟡 Warning: VerdictMinor fixes needed |
|
Derive `Object` bounds, corners, contact-sensor body and MESH-mode collision mesh from `object_cfg.spawn` through a new `SpawnCfgGeometry` class, instead of from the constructor inputs. This is the first step toward asset selection as a variation, which installs the chosen asset by replacing `object_cfg.spawn`. ## Why this change? We want experiments to choose which registered asset a scene object spawns with, the way they already vary lighting, camera pose or mass. One environment can then be evaluated on many objects without editing it, and every episode result names its asset. The planned `AssetSelectionVariation` makes this choice at build time, before objects are placed. Each `Object` stores an Isaac Lab spawn configuration in `object_cfg.spawn`. It tells Isaac Lab what to spawn: for a USD asset the file, scale and physics settings, for a primitive the shape and size. Asset selection keeps the scene object, for example `pickup`, and swaps its asset by replacing `object_cfg.spawn` with the chosen asset's spawn configuration. Before the scene is spawned, Arena also needs the object's geometry. Placement relations such as `On` use its bounding box, collision checks in MESH mode use its mesh, and contact sensors attach to its rigid body. On `main`, Arena computes this geometry from the arguments the object was built with (`usd_path`, `scale` and `spawn_cfg_addon["variants"]`), not from `object_cfg.spawn`. After a swap, the geometry would still describe the old asset. For example, if `pickup` is built as a cracker box and selection installs a sugar box, placement uses the cracker box's height and the contact sensor looks for the cracker box's rigid body. This PR computes the geometry from `object_cfg.spawn`, so placement, collision checks and contact sensors always see the asset that is actually spawned. Replacing `object_cfg.spawn` is then all selection has to do. Objects built directly from a spawn configuration, such as primitive shapes or `spawner_cfg=UsdFileCfg(...)`, have no `usd_path`. On `main` they therefore get no bounding box and no contact-sensor body. With this PR they get both. ## What changes? - `SpawnCfgGeometry` computes bounds and the contact-body path from one spawn config, before anything is spawned. `ArenaWorld` still reports the live geometry of the spawned scene. - `UsdFileCfg`: references the USD into an in-memory stage and applies the USD variant selections in `UsdFileCfg.variants`. Bounds use the same frame and scale rule as `compute_local_bounding_box_from_usd()`. The contact body is the shallowest rigid body. - Primitive shapes (`CuboidCfg`, `SphereCfg`, ...): analytic bounds. The contact body is the root when `rigid_props` is set. - Other spawners assert and point to `Object.bounding_box`. - `Object` caches one `SpawnCfgGeometry` per geometry key (USD path, scale, USD variant selections, shape size, `rigid_props`). A geometric edit to `object_cfg.spawn` recomputes it, a physics or rendering edit does not. - `WarpMeshAndSphereCache` takes the MESH-mode USD path and scale from `object_cfg.spawn`. It ignores USD variant selections, as before. - `RigidObjectSet` builds a `UsdFileCfg` per member to find its contact body. The next PR spawns members from their own spawn configs and removes this. Effect on existing code: all 294 registered library objects keep their bounds and contact paths, and no environment behaves differently. Only direct callers of these methods and unusual USD files see a difference: - `get_contact_sensor_prim_path()` no longer takes a `usd_path` argument. No caller in the repo passes one. - `get_bounding_box()` no longer writes its result into `bounding_box`. Setting `bounding_box` still overrides the bounds, and no code read the written value. - A USD file without a default prim now fails with an assertion that names the file. Main bounded the whole stage, but Isaac Lab spawns such a file as an empty prim, so it never spawned any geometry. - For a default prim nested under transformed parent prims, bounds no longer include the parents' transforms. This matches how Isaac Lab references the asset. No library asset is affected. - `tabletop_place_upright_environment` scales its background after construction. The background's bounds and mesh now include that 0.6 z-scale, matching what spawns. Nothing in that environment reads them. Left for follow-ups: - Bounds stay in main's default-prim frame, while `ArenaWorld.get_aabb_in_local_frame()` measures from the rigid body. They differ for assets whose rigid body is offset below the default prim. - MESH-mode extraction multiplies a tuple scale onto the authored root scale, while Isaac Lab replaces it. This is the same on main. A TODO in `warp_mesh_manager.py` describes the fix. - The old file-based helpers stay for their remaining callers; they now call the same code as `SpawnCfgGeometry`. #1434 deletes `find_shallowest_rigid_body`. Follow-ups move `DeformableObject` bounds, the BASE contact filter in `Object.get_contact_sensor_cfg()` and MESH-mode mesh extraction onto `SpawnCfgGeometry`. `compute_local_bounding_box_from_usd` can go after that, and `read_asset_rigid_body_paths` will share the in-memory stage setup instead of repeating it. ## Validation - `pre-commit run --all-files` passes. - Parity with main: for all 294 registered library objects with a USD path, bounds (atol 1e-5) and contact paths match main, with 0 differences. The two SimReady assets that `kitchen_bench` and `maple_table_top` spawn with a USD variant selection (`{"Physics": "physics"}`) match as well. `RigidObjectSet` is not covered. - `run-tests` phases in the Arena container: 1470 passed and 3 failed, 27 passed, 64 passed and 2 failed. The full phases ran on c59d2de and 378c665. After the review rounds, the affected test files pass on bbeddef (54 passed), and the geometry and object-set tests on 554a60a (24 passed). All 5 failures also fail on main in the same container: - `test_all_assets_in_registry`, `test_experiment_runner_all_environments` and two `test_deformable_object.py` tests need Isaac Lab's optional tetrahedralization dependency, which is not installed. So the registry-wide scene build and the all-environments run are not verified here. - The multi-env Franka door mimic test hits the 900 s timeout. The single-env version of that test passes. --------- Signed-off-by: Clemens Volk <[email protected]>
Isaac Lab finds a rigid object's body path in one environment and uses it for all of them, so every spawn entry of one object needs its body at the same path. align_rigid_body_paths() returns copies of the given spawn configs unchanged when their body paths agree. Otherwise it writes a cache copy of each USD asset with the body moved to /rigid_body, named by a hash of its content. Spawn scales stay on the configs and USD variant selections are baked into the copy. Settings that name prims inside the asset, and assets with more than one rigid body, are rejected before any file is written. Signed-off-by: Clemens Volk <[email protected]>
RigidObjectSet used to spawn a MultiUsdFileCfg built from the members' USD paths only, and rewrote member USDs to bake in scale and move the rigid body. Member physics, USD variant selections and materials were lost, and primitive members were not possible. The set now spawns copies of each member's object_cfg.spawn, aligned by align_rigid_body_paths(): one member spawns its plain config, more members spawn a MultiAssetSpawnerCfg. The set has no usd_path of its own. assign_variants() keeps giving each environment its member, now by replacing object_cfg.spawn with one spawn entry per environment and keeping set-wide settings made on the live config. A set as a member is rejected with a message naming both sets, as main rejected it through an unreadable empty usd_path. The check that all entries share one rigid-body path moves to Object._get_shared_contact_body_path(). Review-GUI member thumbnails use each member's own USD file. Signed-off-by: Clemens Volk <[email protected]>
Build a four-environment scene with a set of two USD members that differ in mass, scale and rigid-body depth, assign members to the environments, and check that each environment spawns its assigned member with both its own mass and its own scale. Both members are relocated, so the test also spawns the cached copies that align_rigid_body_paths() writes, through the per-environment spawn config that assign_variants() builds. Signed-off-by: Clemens Volk <[email protected]>
RigidObjectSet no longer rescales member USDs or renames their rigid bodies into <name>_<scale>.usd cache files. align_rigid_body_paths() replaced that code, so object_set_utils.py and its tests have no users left. Signed-off-by: Clemens Volk <[email protected]>
Say that members spawn from copies of their own spawn configurations, that primitive members are allowed, when and how member USDs are copied with the rigid body at /rigid_body, which settings that blocks, and that a set is not a fixed obstacle. Replace the outdated note that contact sensors use the first member. Signed-off-by: Clemens Volk <[email protected]>
Relationships and connections from prims outside a nested rigid body into that body still named its removed copy below /Prepared/source after relocation. Sdf.CopySpec remaps only paths inside the copied subtree, and the previous rewrite step mapped /Asset paths, which no longer existed by the time it ran, so it changed nothing. Map every relationship target and attribute connection that names the body's /Prepared/source path to /Prepared/rigid_body, and test a prim outside the body that targets it. Signed-off-by: Clemens Volk <[email protected]>
Since the set spawns from its members' spawn configurations, a scale passed to RigidObjectSet reached Object as self.scale but was never applied to what spawns. Before, the constructor passed its own scale, so a caller's scale raised a TypeError. Reject it with a message that points to the member objects, which keep their own scale. Signed-off-by: Clemens Volk <[email protected]>
- Docs: a relative visual_material_path is rejected only when visual_material is set, and member edits after construction change the set's placement bounds but not what it spawns. - Shorten the align_rigid_body_paths docstring to what callers need. - Name the live spawn entries in get_contact_sensor_prim_path, which hold one entry per environment after assign_variants(). - Review GUI: members built from a spawner config have no usd_path and get no thumbnail, even when the spawner is a UsdFileCfg. Signed-off-by: Clemens Volk <[email protected]>
Its last production caller went away when object-set members started spawning from their own spawn configs. Only tests still used it. The rigid-body tests now open their own stage and call find_shallowest_rigid_body_from_stage, selecting the Physics variant with apply_usd_variant_selections where the old call passed variants. The nested-USD geometry test keeps its literal contact body assertion and drops the parity check against the removed function. Signed-off-by: Clemens Volk <[email protected]>
Spawn each source asset and its relocated copy at the same pose and check that the rigid bodies match. The test fails when the spawn root's authored translation or rotation is baked into the moved body. Signed-off-by: Clemens Volk <[email protected]>
Replace the hand-written de-instancing loop with Isaac Lab's helper, which the USD spawner already uses. Add tests that relocate a body holding instanced and nested instanced geometry, and that reject an asset with a second rigid body inside an instance, which body discovery does not see. Signed-off-by: Clemens Volk <[email protected]>
Settings that name prims inside the source asset are rejected only when a body has to move. Check that each one is accepted and kept on the fast path, without touching the cache. Signed-off-by: Clemens Volk <[email protected]>
RigidObjectSet is always rigid, so its NotImplementedError overrides for articulation, base and spawner configs never run. In the rigid asset preparation, map the inherited material through the same helper that redirects relationship targets into the moved body. Signed-off-by: Clemens Volk <[email protected]>
Fold the two physics-variant tie tests in test_rigid_bodies.py into one, and let the contact-path object-set test write its members with the shared rigid cube writer. Signed-off-by: Clemens Volk <[email protected]>
Members are read from the member objects now, so the review GUI can pass them through resolve_node_usd_paths and resolve_aabb_dimensions_m instead of repeating both. Signed-off-by: Clemens Volk <[email protected]>
Document that per-environment assignment rebuilds the entries in object_cfg.spawn.assets_cfg from the member copies, so members are configured before the set is built, and state when the sequential cloning mapping holds. Describe the relocation helper's inputs as spawn configurations rather than set members, and refer to spawned members rather than USDs now that members can be primitive shapes. Signed-off-by: Clemens Volk <[email protected]>
5e01c88 to
aa9b074
Compare
The module moves rigid bodies to one common prim path, so it is now rigid_body_path_alignment.py. Its helpers, constants, error messages and tests say "move the rigid body" and "copy" instead of "relocate" and "prepared", and the module docstring explains why Isaac Lab needs one body path for all environments. Signed-off-by: Clemens Volk <[email protected]>
Keep two facts users need: members spawn from their own spawn configuration, and members with different rigid-body paths spawn a copy with the body moved to a common path. Drop the outdated contact-sensor note instead of rewriting it. Signed-off-by: Clemens Volk <[email protected]>
The private helpers become _choose_member_indices and _apply_member_assignment, and the docstrings and messages describe members instead of variants. The public assign_variants() and variant_indices_by_env keep their names until assignment moves to Object, noted in a TODO. Signed-off-by: Clemens Volk <[email protected]>
_build_copy_with_body_moved now reads as a sequence: open the asset for editing, check it has one rigid body, read the body's transform and bound materials, move the body to /Prepared/rigid_body, then restore its transform and materials. Helpers are renamed after what they do, and the Sdf.CopySpec calls no longer run inside assert statements, so they also run under python -O. The written copies and their cache file names are unchanged. Signed-off-by: Clemens Volk <[email protected]>
The body has three paths while it is moved: below /Asset in the source stage, below /Prepared/source in the copy, and /Prepared/rigid_body. Rename old_body_path to source_body_path and body_path_before_move to body_path_in_rest_of_asset, so each name says which tree it is in. Signed-off-by: Clemens Volk <[email protected]>
_build_copy_with_body_moved works out where the body sits under /Prepared/source and passes it to both steps, so _move_body_to_common_path returns only the stage. The path is named body_path_under_source after the prim it sits in. Signed-off-by: Clemens Volk <[email protected]>
|
/review |
On main a set had usd_path="", so passive-obstacle discovery used a relation-free set with a fixed pose as an obstacle with its tallest member's box. The set's usd_path is now None, which made discovery skip it. Let sets through again and test that they block placement. The usd_path check no longer tells whether an object has bounds; a TODO records the follow-up to decide by geometry instead. Signed-off-by: Clemens Volk <[email protected]>
Read the source asset root from the stage's default prim instead of repeating the /Asset path that SpawnCfgGeometry.open_usd_stage() sets, and pass it to the helpers that need it. Remove the cache layout version: cache files are named by a hash of their content, so a changed layout already gives new names. Rename the copy's default prim from /Prepared to /AlignedAsset. Signed-off-by: Clemens Volk <[email protected]>
Describe why the rigid-body paths must match, using the cracker box and sweet potato as an example, and what the function returns when the paths already match. Signed-off-by: Clemens Volk <[email protected]>
Spell out why settings that name prims inside the USD file are rejected: the copy gives those prims new paths, so the settings would point at nothing and be skipped without an error. Read the *_props fields with Isaac Lab's private fragment_mapping helper instead of our own type checks, so the check follows how Isaac Lab reads those fields. A TODO notes that bare fragments could be allowed, since Isaac Lab applies them to the whole asset. Signed-off-by: Clemens Volk <[email protected]>
_BoundMaterial only carried the body's material bindings from a read step before the move to a write step after it. Building the copy never edits the source stage, so one function now reads the body's transform and bound materials from the source stage and authors them on the moved body. Isaac Lab's bind_visual_material does not fit here: it binds every descendant, has no material purpose and only knows stronger or weaker than descendants. The written copies are byte-identical for 169 of 170 library assets; broccoli loads a different source file per run. Signed-off-by: Clemens Volk <[email protected]>
The docstring said only changed configurations point at a copy, but when the rigid-body paths differ every configuration gets one. When they match, the function returns copies, not the inputs. Signed-off-by: Clemens Volk <[email protected]>
_assert_settings_do_not_name_asset_prims read prim_physics and physics_material_prim_path with getattr defaults, which hid that only UsdFileCfgPrimPhysicsWrapper and UsdFileWithCompliantContactCfg declare them. Check those fields behind an isinstance test instead, so a renamed field fails instead of passing. Read the physics property fields that accept schema fragments by name, as Isaac Lab's USD spawner does, instead of scanning every *_props field. A new test checks each *_props field of UsdFileCfg except deformable_props, so a field Isaac Lab adds later fails until the check lists it. Signed-off-by: Clemens Volk <[email protected]>
qianl-nv
left a comment
There was a problem hiding this comment.
Thanks for putting this together. Overall LGTM, have a few suggestions for improving code cleaness.
Plz also do a pass on the isaaclab_arena/utils/usd/rigid_body_path_alignment.py docstring/comments, feels overly verbose atm.
Object._get_shared_contact_body_path() had a single caller, RigidObjectSet.get_contact_sensor_prim_path(), which already reads the spawn entries from object_cfg.spawn. Check there that all entries share one rigid-body path, and remove the helper from Object. Signed-off-by: Clemens Volk <[email protected]>
discover_passive_assets() skipped every object without a USD path, because bounds used to come from the USD file. Since #1430 they come from object_cfg.spawn, so a rigid object without a USD path, such as a primitive shape or an object set, has bounds too. Skip only non-rigid objects without a USD path, such as lights and the ground plane, and drop the object-set special case. A relation-free rigid primitive with a fixed pose now blocks placement, like ProceduralTable and ProceduralCube, which pass usd_path="". Signed-off-by: Clemens Volk <[email protected]>
align_rigid_body_paths() zipped the geometries with a parallel list of their body paths to build the copies. SpawnCfgGeometry already caches the body path, so _build_copy_with_body_moved() reads it from the geometry and takes only that. Signed-off-by: Clemens Volk <[email protected]>
The module docstring repeated what align_rigid_body_paths() explains, so remove it. Replace the function's prose example with the cracker box and sweet potato hierarchies before and after their rigid bodies move to /rigid_body. Signed-off-by: Clemens Volk <[email protected]>
Cut comments that repeated a docstring or the code down to the reason they give, and shorten the _path_after_body_move and _save_to_cache docstrings to one line. Say why the asset is made uninstanceable, that the inherited state is read from the source stage because the copy no longer has the body's parents, and that the temporary file keeps the cache path from ever naming a half-written file. Signed-off-by: Clemens Volk <[email protected]>
Spawn each
RigidObjectSetmember from its own spawn configuration through Isaac Lab'sMultiAssetSpawnerCfg, so members keep their scale and the physics settings, USD variant selections and materials set in their spawn configurations. This is the second step toward choosing an object's asset through a variation, after #1430.Why this change?
We plan to let experiments choose which registered asset a scene object spawns with, the way they already vary lighting, camera pose or mass. This will be a build-time variation,
AssetSelectionVariation: for an object such aspickupit picks one of several registered assets, for example a cracker box or a sugar box, for each environment. Each chosen asset must spawn exactly as registered, with its own scale and physics settings.Isaac Lab supports this natively:
MultiAssetSpawnerCfgspawns every entry from its own spawn configuration.RigidObjectSetdoes not use it yet. It spawns aMultiUsdFileCfg, which gives all members one configuration, so members lose the physics settings, USD variant selections and visual materials set in their spawn configurations, and Arena writes rescaled copies of member USD files to keep their scale. Materials authored in the USD files were already kept.This PR switches
RigidObjectSettoMultiAssetSpawnerCfg. It keeps one step that Isaac Lab does not cover: Isaac Lab finds a rigid object's body through one path for all environments, so members whose bodies sit at different paths get a cached copy with the body moved to a common path.AssetSelectionVariationwill use both:MultiAssetSpawnerCfgto spawn the assets chosen for the environments, andalign_rigid_body_pathsto give them a common body path.What changes?
align_rigid_body_paths(spawn_cfgs)(utils/usd/rigid_body_path_alignment.py) returns copies of the spawn configurations with their rigid bodies at one path. If the paths already agree, the copies are unchanged and nothing is written. Otherwise every member must be a USD asset, and each gets a cachedrigid_<sha256>.usdcopy with its body at/rigid_body, its materials kept and its USD variant selections baked in. Settings that name prims inside the asset, such asprim_physicsorvisual_material_bindings, are rejected in that case.RigidObjectSetspawns the aligned copies: one member as a plain config, more members as aMultiAssetSpawnerCfg. Members may be primitive shapes when their body paths agree.assign_variants()still expands the spawn entries to one per environment. This expansion is transitional. The next PR pins assignments through Isaac Lab's clone strategy.object_set_utils.py, the old rescale-and-rename cache, and its tests are deleted.find_shallowest_rigid_bodyis deleted, because its last production caller was the old set code. Its tests usefind_shallowest_rigid_body_from_stageinstead.Effect on existing code:
sweet_potatoandjugkeep their rigid body at different paths, so they spawn copies with the body moved to/rigid_body, with their scales kept on the spawn config instead of baked into the file.member_usd_pathsandobject_usd_pathsare removed. A set with several members exposes its spawn entries asobject_cfg.spawn.assets_cfg: one per member, or one per environment afterassign_variants(). A one-member set spawns the member's own config atobject_cfg.spawn. Callers in the repo are updated.object_cfg.spawn.assets_cfgfrom the members, so edits to single entries do not survive it. Set-wide settings onobject_cfg.spawndo.scaleorspawn_cfg_addonis rejected, and a set-levelasset_cfg_addonnow applies, as forObject. No caller passes any of them.computer_mouse_hot3d_robolab, this swaps two bounds axes compared with Derive Object geometry from its spawn configuration #1430's bounds, which keep the rotation (follow-up: Derive Object geometry from its spawn configuration #1430's bounds will drop the authored root rotation too).Usage example
Before (the set kept only each member's USD path and scale):
After:
Validation
pre-commit run --all-filespasses.pytetwild), and the multi-env mimic test hits its 900 s timeout. The review GUI tests give 45 passed and 1 failed (test_run_sim_preview_via_simapp_subprocess), which fails the same way on Derive Object geometry from its spawn configuration #1430's head.test_run_sim_preview_via_simapp_subprocess(45 passed). Unify placement sampling and replay #1427's placement tests passed after the main merge (16 and 51). The library check gives the same result as above.rigid_body_path_alignment.py(7941495), its tests and the object-set tests pass (45 passed).