Skip to content

Commit 5c2c748

Browse files
authored
Configures mesh collision schemas in convert_mesh.py (#3558)
# Description The collision approximation configuration changed in main branch, but the code in tools/convert_mesh.py does not sync. Fixes #3557 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## 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` - [ ] 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 - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: zehao-wang <[email protected]>
1 parent 161ef85 commit 5c2c748

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ Guidelines for modifications:
144144
* Yohan Choi
145145
* Yujian Zhang
146146
* Yun Liu
147+
* Zehao Wang
147148
* Ziqi Fan
148149
* Zoe McCarthy
149150
* David Leon

scripts/tools/convert_mesh.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@
4343

4444
from isaaclab.app import AppLauncher
4545

46+
# Define collision approximation choices (must be defined before parser)
47+
_valid_collision_approx = [
48+
"convexDecomposition",
49+
"convexHull",
50+
"triangleMesh",
51+
"meshSimplification",
52+
"sdf",
53+
"boundingCube",
54+
"boundingSphere",
55+
"none",
56+
]
57+
4658
# add argparse arguments
4759
parser = argparse.ArgumentParser(description="Utility to convert a mesh file into USD format.")
4860
parser.add_argument("input", type=str, help="The path to the input mesh file.")
@@ -57,11 +69,8 @@
5769
"--collision-approximation",
5870
type=str,
5971
default="convexDecomposition",
60-
choices=["convexDecomposition", "convexHull", "boundingCube", "boundingSphere", "meshSimplification", "none"],
61-
help=(
62-
'The method used for approximating collision mesh. Set to "none" '
63-
"to not add a collision mesh to the converted mesh."
64-
),
72+
choices=_valid_collision_approx,
73+
help="The method used for approximating the collision mesh. Set to 'none' to disable collision mesh generation.",
6574
)
6675
parser.add_argument(
6776
"--mass",
@@ -92,6 +101,17 @@
92101
from isaaclab.utils.assets import check_file_path
93102
from isaaclab.utils.dict import print_dict
94103

104+
collision_approximation_map = {
105+
"convexDecomposition": schemas_cfg.ConvexDecompositionPropertiesCfg,
106+
"convexHull": schemas_cfg.ConvexHullPropertiesCfg,
107+
"triangleMesh": schemas_cfg.TriangleMeshPropertiesCfg,
108+
"meshSimplification": schemas_cfg.TriangleMeshSimplificationPropertiesCfg,
109+
"sdf": schemas_cfg.SDFMeshPropertiesCfg,
110+
"boundingCube": schemas_cfg.BoundingCubePropertiesCfg,
111+
"boundingSphere": schemas_cfg.BoundingSpherePropertiesCfg,
112+
"none": None,
113+
}
114+
95115

96116
def main():
97117
# check valid file path
@@ -118,6 +138,15 @@ def main():
118138
collision_props = schemas_cfg.CollisionPropertiesCfg(collision_enabled=args_cli.collision_approximation != "none")
119139

120140
# Create Mesh converter config
141+
cfg_class = collision_approximation_map.get(args_cli.collision_approximation)
142+
if cfg_class is None and args_cli.collision_approximation != "none":
143+
valid_keys = ", ".join(sorted(collision_approximation_map.keys()))
144+
raise ValueError(
145+
f"Invalid collision approximation type '{args_cli.collision_approximation}'. "
146+
f"Valid options are: {valid_keys}."
147+
)
148+
collision_cfg = cfg_class() if cfg_class is not None else None
149+
121150
mesh_converter_cfg = MeshConverterCfg(
122151
mass_props=mass_props,
123152
rigid_props=rigid_props,
@@ -127,7 +156,7 @@ def main():
127156
usd_dir=os.path.dirname(dest_path),
128157
usd_file_name=os.path.basename(dest_path),
129158
make_instanceable=args_cli.make_instanceable,
130-
collision_approximation=args_cli.collision_approximation,
159+
mesh_collision_props=collision_cfg,
131160
)
132161

133162
# Print info

0 commit comments

Comments
 (0)