Repository navigation
[Core] Refactor and cleanup core subpackage for 3.0 [4/N] - #7980
Conversation
…otted mesh file names
There was a problem hiding this comment.
Isaac Lab Review Bot
Reviewed four targeted fixes covering terrain object resolution, explicit USD stage usage, Sdf.Path handling, and dotted mesh filenames. The changes are narrowly scoped and paired with regression coverage and an Isaac Lab changelog fragment.
- Design and architecture: The fixes remain within the owning components. Callable-first terrain resolution preserves plain string lookup while supporting callable
ResolvableStringvalues, and articulation fixed-joint lookup now consistently uses the caller-provided stage. - API: Public signatures, defaults, exports, and return types are unchanged. Converting
str | Sdf.Pathtostralignsfind_global_fixed_joint_primwith its declared input contract, while the terrain error-path change only improves the reported configured value. - Implementation: The producer and consumer paths support the changes:
stageis forwarded to the existing query helper,Sdf.Pathis normalized before string validation, andos.path.splitextfeeds the existing USD identifier sanitization so dotted basenames become valid prim names. The removed mesh-format local had no remaining consumer. Focused regression tests cover each corrected path.
No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.
Automated review; human maintainers own approval decisions.
|
Spawn a mesh from an .obj/.stl/.fbx file (converted with MeshConverter) or from in-memory triangle data, with optional collision, mesh collision, rigid body, mass, and material properties. The terrain mesh helper now uses it; the authored USD is unchanged. Ported from isaac-sim#5407. Co-authored-by: Octi Zhang <[email protected]>
|
run-ci |
|
Backported to |
# Description Fourth PR in a series that splits the core cleanup in #7949 into small, reviewable pieces. This one fixes four small bugs in `isaaclab.terrains` and `isaaclab.sim`, and adds a spawner for meshes (e.g. terrain from an `.obj` file) ported from #5407 by @ooctipus (closed as stale). The PhysX `useEnvIds` and clone-spawner changes from that PR are not included. Each fix has a regression test that fails without it. ## Fixes - `terrains.trimesh.mesh_terrains.repeated_objects_terrain`: the built-in `MeshRepeatedBoxesTerrainCfg`, `MeshRepeatedCylindersTerrainCfg`, and `MeshRepeatedPyramidsTerrainCfg` default `object_type` to strings such as `"{DIR}.utils:make_box"`, which configclass turns into a `ResolvableString` (a callable `str` subclass). The function checked `isinstance(str)` before `callable`, looked up `make_{DIR}.utils:make_box` in the module, got `None`, and raised `ValueError`. Callables are now checked first; plain names such as `"box"` still resolve to `make_box`. The error message now shows the configured value instead of `None`. - `sim.schemas.modify_articulation_root_properties`: with `fix_root_link` set, the existing fixed joint was searched for on the current stage instead of the `stage` argument. - `sim.utils.queries.find_global_fixed_joint_prim`: the signature accepts `Sdf.Path`, but `prim_path.startswith(...)` raised `AttributeError` for one. The path is converted to `str` first, like the sibling query functions. - `sim.converters.MeshConverter`: the prim name was taken from `basename.split(".")`, which raised `ValueError` for file names with more than one dot (e.g. `duck.v2.obj`). It now uses `os.path.splitext`; the existing invalid-identifier fallback turns `duck.v2` into `duck_v2`. The unused `mesh_file_format` variable is removed. ## Mesh spawner **Added** - `sim_utils.MeshFileCfg` / `sim_utils.spawn_from_mesh` spawn a mesh from: - a mesh file path (`.obj`, `.stl`, `.fbx`, ...), converted with `MeshConverter` and referenced, or - in-memory triangle data: `MeshFileCfg.TriangleMeshCfg(vertices, faces, vertex_colors)` or a `trimesh.Trimesh` through `MeshFileCfg.TrimeshObjectCfg`, authored as an Xform with a USD mesh at `{prim_path}/mesh`. - The mesh is visual-only by default. `collision_props`, `mesh_collision_props` (e.g. triangle mesh for terrain, convex hull for objects), `rigid_props`, `mass_props`, `visual_material`, and `physics_material` are optional and accept both the legacy cfgs and schema fragments, like the other spawners. ```python terrain = sim_utils.MeshFileCfg( mesh="/path/to/terrain.obj", collision_props=[sim_utils.UsdPhysicsCollisionCfg(collision_enabled=True)], mesh_collision_props=[sim_utils.UsdPhysicsMeshCollisionCfg(mesh_approximation_name="none")], ) terrain.func("/World/ground", terrain) ``` **Changed** - `isaaclab.terrains.utils.create_prim_from_mesh` (used by `TerrainImporter.import_mesh`) now spawns through `MeshFileCfg`. I checked that the authored USD is byte-for-byte identical to `develop` for a colored terrain mesh with visual and physics materials. The only difference: its `translation`/`orientation` kwargs now apply to the root prim instead of the `mesh` child (same world pose). **Differences from #5407** - Mesh file paths reuse `MeshConverter` for collision, mass, and rigid body properties, so both legacy cfgs and fragments work. The in-memory path follows the same legacy-or-fragment routing as the mesh-primitive spawners. - Dropped the `.usd` branch (use `UsdFileCfg` for USD files), the duplicate "prim already exists" check (`create_prim` already raises), and the new public `utils.mesh` helpers; mesh-data validation is a private helper in the spawner. ## Tests - `test/sim/test_spawn_from_files.py`: `test_spawn_mesh_from_triangle_data` (colored rigid body with a convex-hull collider) and `test_spawn_mesh_from_obj_file`. - The trimesh terrain path is covered by the existing terrain importer, ray caster, and material fragment tests; `test_terrain_importer.py` passes in full. **Fix tests** (one focused check per fix, extending existing tests where possible) - `test/terrains/test_terrain_generator.py`: new `test_repeated_objects_default_object_type` (the three repeated-object configs share the code path, so one config is covered). - `test/sim/test_schemas.py`: new `test_modify_articulation_root_fix_root_link_uses_given_stage` (in-memory stage that is not the current stage). - `test/sim/test_utils_queries.py`: `test_find_global_fixed_joint_prim` also passes an `Sdf.Path`. - `test/sim/test_mesh_converter.py`: `test_convert_obj` now converts the OBJ from a dotted file name (`duck.v2.obj`) and checks the prim name, instead of adding a separate conversion. All of these fail against `develop` sources and pass with the fixes. ## Type of change - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump `extension.toml` — CI handles that) - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Co-authored-by: Octi Zhang <[email protected]> (cherry picked from commit f7e528f)
Description
Fourth PR in a series that splits the core cleanup in #7949 into small, reviewable pieces. This one fixes four small bugs in
isaaclab.terrainsandisaaclab.sim, and adds a spawner for meshes (e.g. terrain from an.objfile) ported from #5407 by @ooctipus (closed as stale). The PhysXuseEnvIdsand clone-spawner changes from that PR are not included. Each fix has a regression test that fails without it.Fixes
terrains.trimesh.mesh_terrains.repeated_objects_terrain: the built-inMeshRepeatedBoxesTerrainCfg,MeshRepeatedCylindersTerrainCfg, andMeshRepeatedPyramidsTerrainCfgdefaultobject_typeto strings such as"{DIR}.utils:make_box", which configclass turns into aResolvableString(a callablestrsubclass). The function checkedisinstance(str)beforecallable, looked upmake_{DIR}.utils:make_boxin the module, gotNone, and raisedValueError. Callables are now checked first; plain names such as"box"still resolve tomake_box. The error message now shows the configured value instead ofNone.sim.schemas.modify_articulation_root_properties: withfix_root_linkset, the existing fixed joint was searched for on the current stage instead of thestageargument.sim.utils.queries.find_global_fixed_joint_prim: the signature acceptsSdf.Path, butprim_path.startswith(...)raisedAttributeErrorfor one. The path is converted tostrfirst, like the sibling query functions.sim.converters.MeshConverter: the prim name was taken frombasename.split("."), which raisedValueErrorfor file names with more than one dot (e.g.duck.v2.obj). It now usesos.path.splitext; the existing invalid-identifier fallback turnsduck.v2intoduck_v2. The unusedmesh_file_formatvariable is removed.Mesh spawner
Added
sim_utils.MeshFileCfg/sim_utils.spawn_from_meshspawn a mesh from:.obj,.stl,.fbx, ...), converted withMeshConverterand referenced, orMeshFileCfg.TriangleMeshCfg(vertices, faces, vertex_colors)or atrimesh.TrimeshthroughMeshFileCfg.TrimeshObjectCfg, authored as an Xform with a USD mesh at{prim_path}/mesh.collision_props,mesh_collision_props(e.g. triangle mesh for terrain, convex hull for objects),rigid_props,mass_props,visual_material, andphysics_materialare optional and accept both the legacy cfgs and schema fragments, like the other spawners.Changed
isaaclab.terrains.utils.create_prim_from_mesh(used byTerrainImporter.import_mesh) now spawns throughMeshFileCfg. I checked that the authored USD is byte-for-byte identical todevelopfor a colored terrain mesh with visual and physics materials. The only difference: itstranslation/orientationkwargs now apply to the root prim instead of themeshchild (same world pose).Differences from #5407
MeshConverterfor collision, mass, and rigid body properties, so both legacy cfgs and fragments work. The in-memory path follows the same legacy-or-fragment routing as the mesh-primitive spawners..usdbranch (useUsdFileCfgfor USD files), the duplicate "prim already exists" check (create_primalready raises), and the new publicutils.meshhelpers; mesh-data validation is a private helper in the spawner.Tests
test/sim/test_spawn_from_files.py:test_spawn_mesh_from_triangle_data(colored rigid body with a convex-hull collider) andtest_spawn_mesh_from_obj_file.test_terrain_importer.pypasses in full.Fix tests (one focused check per fix, extending existing tests where possible)
test/terrains/test_terrain_generator.py: newtest_repeated_objects_default_object_type(the three repeated-object configs share the code path, so one config is covered).test/sim/test_schemas.py: newtest_modify_articulation_root_fix_root_link_uses_given_stage(in-memory stage that is not the current stage).test/sim/test_utils_queries.py:test_find_global_fixed_joint_primalso passes anSdf.Path.test/sim/test_mesh_converter.py:test_convert_objnow converts the OBJ from a dotted file name (duck.v2.obj) and checks the prim name, instead of adding a separate conversion.All of these fail against
developsources and pass with the fixes.Type of change
Release backport
developChecklist
pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists there