Unverified Commit bac97356 authored by Pascal Roth's avatar Pascal Roth Committed by GitHub

Fixes using strings for shapes in `MeshRepeatedObjectsTerrainCfg` (#213)

# Description

Meshes such as "box", "cylinder" and "cone" are defined in
`omni.isaac.orbit.terrains.trimesh.utils.py` and can be used in configs
such as
[here](https://github.com/isaac-orbit/orbit/blob/17fc724de7386c919f6f0367980c1d8e9855c446/extensions/omni.isaac.orbit/omni/isaac/orbit/terrains/trimesh/mesh_terrains_cfg.py#L187).
In the example, their definition as a string is allowed but as they are
not explicitly imported, the general statement cannot capture the
missing functions. This PR makes sure that all mesh helper functions in
`utils.py` are imported and that the string format can be used.

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
parent 447aa318
......@@ -13,6 +13,7 @@ import torch
import trimesh
from typing import TYPE_CHECKING
from .utils import * # noqa: F401, F403
from .utils import make_border, make_plane
if TYPE_CHECKING:
......
......@@ -329,7 +329,7 @@ def test_star_terrain(difficulty: float):
trimesh.viewer.SceneViewer(scene=scene, caption="Star Terrain")
def test_repeated_objects_terrain(difficulty: float, object_type: str):
def test_repeated_objects_terrain(difficulty: float, object_type: str, provide_as_string: bool = False):
# parameters for the terrain
if object_type == "pyramid":
cfg = mesh_gen.MeshRepeatedPyramidsTerrainCfg(
......@@ -369,6 +369,11 @@ def test_repeated_objects_terrain(difficulty: float, object_type: str):
)
else:
raise ValueError(f"Invalid object type for repeated objects terrain: {object_type}")
# provide object_type as string (check that the import works)
if provide_as_string:
cfg.object_type = object_type
# generate the terrain
meshes, origin = cfg.function(difficulty=difficulty, cfg=cfg)
# add colors to the meshes based on the height
......@@ -419,6 +424,7 @@ if __name__ == "__main__":
test_repeated_objects_terrain(difficulty=0.75, object_type="pyramid")
test_repeated_objects_terrain(difficulty=0.75, object_type="cylinder")
test_repeated_objects_terrain(difficulty=0.75, object_type="box")
test_repeated_objects_terrain(difficulty=0.75, object_type="cylinder", provide_as_string=True)
# close the app
simulation_app.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment