Skip to content
Merged
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 @@ -144,6 +144,7 @@ Guidelines for modifications:
* Yohan Choi
* Yujian Zhang
* Yun Liu
* Zehao Wang
* Ziqi Fan
* Zoe McCarthy
* David Leon
Expand Down
41 changes: 35 additions & 6 deletions scripts/tools/convert_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@

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.")
Expand All @@ -57,11 +69,8 @@
"--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",
Expand Down Expand Up @@ -92,6 +101,17 @@
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
Expand All @@ -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,
Expand All @@ -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
Expand Down
Loading