Skip to content

[Core] Refactor and cleanup core subpackage for 3.0 [4/N] - #7980

Merged
StafaH merged 4 commits into
isaac-sim:developfrom
StafaH:core-cleanup/04-sim-terrain-fixes
Sep 24, 2026
Merged

StafaH merged 4 commits into
isaac-sim:developfrom
StafaH:core-cleanup/04-sim-terrain-fixes

Conversation

@StafaH

@StafaH StafaH commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

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.
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

  • Backport this pull request to the active release branch after it merges into develop

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • 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)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@StafaH
StafaH requested a review from a team September 23, 2026 19:24
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Sep 23, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ResolvableString values, 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.Path to str aligns find_global_fixed_joint_prim with 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: stage is forwarded to the existing query helper, Sdf.Path is normalized before string validation, and os.path.splitext feeds 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.

@greptile-apps

greptile-apps Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the fixes are narrowly scoped, internally consistent, and covered by targeted regression tests.

Summary

This PR fixes four isolated input-handling and stage-selection defects in terrain generation and simulation utilities.

  • Resolves callable string defaults before applying plain-name terrain helper lookup.
  • Uses the explicitly supplied USD stage when locating an articulation’s fixed joint.
  • Normalizes supported Sdf.Path values before fixed-joint queries.
  • Derives mesh prim names correctly from filenames containing multiple dots.
  • Adds focused regression coverage and a changelog fragment for each corrected behavior.

Reviews (1) · Last reviewed commit: "Fix repeated-object terrain defaults, fi..."

StafaH and others added 3 commits September 23, 2026 14:03
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]>
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 23, 2026
@ooctipus ooctipus added the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Sep 24, 2026
@StafaH

StafaH commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Sep 24, 2026
@StafaH
StafaH merged commit f7e528f into isaac-sim:develop Sep 24, 2026
57 of 84 checks passed
@isaaclab-bot

isaaclab-bot Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Backported to release/3.0.0 as 5a5c439.

isaaclab-bot Bot pushed a commit that referenced this pull request Sep 24, 2026
# 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)
@ooctipus
ooctipus deleted the core-cleanup/04-sim-terrain-fixes branch September 24, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants