Unverified Commit 5c2c748c authored by zehao-wang's avatar zehao-wang Committed by GitHub

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: 's avatarzehao-wang <59912787+zehao-wang@users.noreply.github.com>
parent 161ef855
......@@ -144,6 +144,7 @@ Guidelines for modifications:
* Yohan Choi
* Yujian Zhang
* Yun Liu
* Zehao Wang
* Ziqi Fan
* Zoe McCarthy
* David Leon
......
......@@ -43,6 +43,18 @@ import argparse
from isaaclab.app import AppLauncher
# Define collision approximation choices (must be defined before parser)
_valid_collision_approx = [
"convexDecomposition",
"convexHull",
"triangleMesh",
"meshSimplification",
"sdf",
"boundingCube",
"boundingSphere",
"none",
]
# add argparse arguments
parser = argparse.ArgumentParser(description="Utility to convert a mesh file into USD format.")
parser.add_argument("input", type=str, help="The path to the input mesh file.")
......@@ -57,11 +69,8 @@ parser.add_argument(
"--collision-approximation",
type=str,
default="convexDecomposition",
choices=["convexDecomposition", "convexHull", "boundingCube", "boundingSphere", "meshSimplification", "none"],
help=(
'The method used for approximating collision mesh. Set to "none" '
"to not add a collision mesh to the converted mesh."
),
choices=_valid_collision_approx,
help="The method used for approximating the collision mesh. Set to 'none' to disable collision mesh generation.",
)
parser.add_argument(
"--mass",
......@@ -92,6 +101,17 @@ from isaaclab.sim.schemas import schemas_cfg
from isaaclab.utils.assets import check_file_path
from isaaclab.utils.dict import print_dict
collision_approximation_map = {
"convexDecomposition": schemas_cfg.ConvexDecompositionPropertiesCfg,
"convexHull": schemas_cfg.ConvexHullPropertiesCfg,
"triangleMesh": schemas_cfg.TriangleMeshPropertiesCfg,
"meshSimplification": schemas_cfg.TriangleMeshSimplificationPropertiesCfg,
"sdf": schemas_cfg.SDFMeshPropertiesCfg,
"boundingCube": schemas_cfg.BoundingCubePropertiesCfg,
"boundingSphere": schemas_cfg.BoundingSpherePropertiesCfg,
"none": None,
}
def main():
# check valid file path
......@@ -118,6 +138,15 @@ def main():
collision_props = schemas_cfg.CollisionPropertiesCfg(collision_enabled=args_cli.collision_approximation != "none")
# Create Mesh converter config
cfg_class = collision_approximation_map.get(args_cli.collision_approximation)
if cfg_class is None and args_cli.collision_approximation != "none":
valid_keys = ", ".join(sorted(collision_approximation_map.keys()))
raise ValueError(
f"Invalid collision approximation type '{args_cli.collision_approximation}'. "
f"Valid options are: {valid_keys}."
)
collision_cfg = cfg_class() if cfg_class is not None else None
mesh_converter_cfg = MeshConverterCfg(
mass_props=mass_props,
rigid_props=rigid_props,
......@@ -127,7 +156,7 @@ def main():
usd_dir=os.path.dirname(dest_path),
usd_file_name=os.path.basename(dest_path),
make_instanceable=args_cli.make_instanceable,
collision_approximation=args_cli.collision_approximation,
mesh_collision_props=collision_cfg,
)
# Print info
......
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