Skip to content

[Feature] Importing a terrain from a mesh #2848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Guidelines for modifications:
* Ritvik Singh
* Rosario Scalise
* Ryley McCarroll
* Sami Bouziri
* Shafeef Omar
* Shaoshu Su
* Shundo Kishi
Expand Down
8 changes: 8 additions & 0 deletions source/isaaclab/docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Changelog
---------
0.41.0 (2025-07-03)
~~~~~~~~~~~~~~~~~~~~

Added
^^^^^

* Added the possibility to import a terrain from a mesh. For that, a new terrain type name ``mesh`` and a new attribute named ``mesh_path`` were added to
the :class:`~isaaclab.terrains.terrains_importer_cfg.TerrainImporterCfg`

0.40.11 (2025-06-27)
~~~~~~~~~~~~~~~~~~~~
Expand Down
17 changes: 15 additions & 2 deletions source/isaaclab/isaaclab/terrains/terrain_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ def __init__(self, cfg: TerrainImporterCfg):
self.import_ground_plane("terrain")
# configure the origins in a grid
self.configure_env_origins()
elif self.cfg.terrain_type == "mesh":
# check if config is provided
if self.cfg.mesh_path is None:
raise ValueError("Input terrain type is 'mesh' but no value provided for 'mesh_path'.")
# import the terrain
mesh = trimesh.load_mesh(self.cfg.mesh_path)
self.import_mesh("terrain", mesh)
# configure the origins in a grid
self.configure_env_origins()
else:
raise ValueError(f"Terrain type '{self.cfg.terrain_type}' not available.")

Expand Down Expand Up @@ -217,7 +226,7 @@ def import_ground_plane(self, name: str, size: tuple[float, float] = (2.0e6, 2.0
ground_plane_cfg = sim_utils.GroundPlaneCfg(physics_material=self.cfg.physics_material, size=size, color=color)
ground_plane_cfg.func(prim_path, ground_plane_cfg)

def import_mesh(self, name: str, mesh: trimesh.Trimesh):
def import_mesh(self, name: str, mesh: trimesh.Trimesh, **kwargs):
"""Import a mesh into the simulator.

The mesh is imported into the simulator under the prim path ``cfg.prim_path/{key}``. The created path
Expand All @@ -243,7 +252,11 @@ def import_mesh(self, name: str, mesh: trimesh.Trimesh):

# import the mesh
create_prim_from_mesh(
prim_path, mesh, visual_material=self.cfg.visual_material, physics_material=self.cfg.physics_material
prim_path,
mesh,
visual_material=self.cfg.visual_material,
physics_material=self.cfg.physics_material,
**kwargs,
)

def import_usd(self, name: str, usd_path: str):
Expand Down
10 changes: 8 additions & 2 deletions source/isaaclab/isaaclab/terrains/terrain_importer_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class TerrainImporterCfg:
:attr:`isaaclab.scene.InteractiveSceneCfg.num_envs` attribute.
"""

terrain_type: Literal["generator", "plane", "usd"] = "generator"
terrain_type: Literal["generator", "plane", "usd", "mesh"] = "generator"
"""The type of terrain to generate. Defaults to "generator".

Available options are "plane", "usd", and "generator".
Available options are "plane", "usd", "generator", "mesh".
"""

terrain_generator: TerrainGeneratorCfg | None = None
Expand All @@ -61,6 +61,12 @@ class TerrainImporterCfg:
Only used if ``terrain_type`` is set to "usd".
"""

mesh_path: str | None = None
"""The path to the mesh file containing the terrain.

Only used if ``terrain_type`` is set to "mesh".
"""

env_spacing: float | None = None
"""The spacing between environment origins when defined in a grid. Defaults to None.

Expand Down