Skip to content
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

Adds option for default plane color to terrain importer #1791

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
7 changes: 4 additions & 3 deletions source/isaaclab/isaaclab/terrains/terrain_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __init__(self, cfg: TerrainImporterCfg):
self.configure_env_origins()
elif self.cfg.terrain_type == "plane":
# load the plane
self.import_ground_plane("terrain")
self.import_ground_plane("terrain", color=self.cfg.color)
# configure the origins in a grid
self.configure_env_origins()
else:
Expand Down Expand Up @@ -176,12 +176,13 @@ def set_debug_vis(self, debug_vis: bool) -> bool:
Operations - Import.
"""

def import_ground_plane(self, key: str, size: tuple[float, float] = (2.0e6, 2.0e6)):
def import_ground_plane(self, key: str, size: tuple[float, float] = (2.0e6, 2.0e6), color: tuple[float, float, float] = (0.0, 0.0, 0.0)):
"""Add a plane to the terrain importer.

Args:
key: The key to store the mesh.
size: The size of the plane. Defaults to (2.0e6, 2.0e6).
color: The color of the plane. Defaults to (0.0, 0.0, 0.0).

Raises:
ValueError: If a terrain with the same key already exists.
Expand All @@ -198,7 +199,7 @@ def import_ground_plane(self, key: str, size: tuple[float, float] = (2.0e6, 2.0e
self.warp_meshes[key] = convert_to_warp_mesh(mesh.vertices, mesh.faces, device=device)

# get the mesh
ground_plane_cfg = sim_utils.GroundPlaneCfg(physics_material=self.cfg.physics_material, size=size)
ground_plane_cfg = sim_utils.GroundPlaneCfg(physics_material=self.cfg.physics_material, size=size, color=color)
ground_plane_cfg.func(self.cfg.prim_path, ground_plane_cfg)

def import_mesh(self, key: str, mesh: trimesh.Trimesh):
Expand Down
8 changes: 8 additions & 0 deletions source/isaaclab/isaaclab/terrains/terrain_importer_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ class TerrainImporterCfg:
This parameter is used only when the ``terrain_type`` is ``"generator"``.
"""

color: tuple[float, float, float] = (0.0, 0.0, 0.0)
"""The color of the terrain. Defaults to black.

.. note::
This parameter is used only when the ``terrain_type`` is ``"plane"``.

"""

physics_material: sim_utils.RigidBodyMaterialCfg = sim_utils.RigidBodyMaterialCfg()
"""The physics material of the terrain. Defaults to a default physics material.

Expand Down