From 8a01cb299f291f9abf248f494dfe61205a3283d7 Mon Sep 17 00:00:00 2001 From: zehao-wang <59912787+zehao-wang@users.noreply.github.com> Date: Thu, 25 Sep 2025 12:32:38 +0200 Subject: [PATCH 1/4] Fix bugs: change of mesh collision configuration strategy in v2.2.0 Signed-off-by: zehao-wang <59912787+zehao-wang@users.noreply.github.com> --- scripts/tools/convert_mesh.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/tools/convert_mesh.py b/scripts/tools/convert_mesh.py index 50b295397d3..4147f618d22 100644 --- a/scripts/tools/convert_mesh.py +++ b/scripts/tools/convert_mesh.py @@ -118,6 +118,18 @@ def main(): collision_props = schemas_cfg.CollisionPropertiesCfg(collision_enabled=args_cli.collision_approximation != "none") # Create Mesh converter config + collision_cfg = None + if args_cli.collision_approximation == 'convexDecomposition': + collision_cfg = schemas_cfg.ConvexDecompositionPropertiesCfg() + elif args_cli.collision_approximation == 'convexHull': + collision_cfg = schemas_cfg.ConvexHullPropertiesCfg() + elif args_cli.collision_approximation == 'boundingCube': + collision_cfg = schemas_cfg.BoundingCubePropertiesCfg() + elif args_cli.collision_approximation == "boundingSphere": + collision_cfg = schemas_cfg.BoundingSpherePropertiesCfg() + elif args_cli.collision_approximation == "meshSimplification": + collision_cfg = schemas_cfg.TriangleMeshSimplificationPropertiesCfg() + mesh_converter_cfg = MeshConverterCfg( mass_props=mass_props, rigid_props=rigid_props, @@ -127,7 +139,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 From 93dad85aa40ea53298cac0100478243301edfe27 Mon Sep 17 00:00:00 2001 From: zehao-wang <59912787+zehao-wang@users.noreply.github.com> Date: Thu, 25 Sep 2025 13:07:05 +0200 Subject: [PATCH 2/4] Update CONTRIBUTORS.md Signed-off-by: zehao-wang <59912787+zehao-wang@users.noreply.github.com> --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index ed704177acd..e46de6d4677 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -142,6 +142,7 @@ Guidelines for modifications: * Yohan Choi * Yujian Zhang * Yun Liu +* Zehao Wang * Ziqi Fan * Zoe McCarthy * David Leon From e17e5a2e2f467c11fe15b7da4f51ef112ab63d7e Mon Sep 17 00:00:00 2001 From: zehao-wang Date: Sun, 12 Oct 2025 12:13:14 +0200 Subject: [PATCH 3/4] refactor(convert_mesh): raise error for unmatched types and apply pre-commit formatting --- scripts/tools/convert_mesh.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/tools/convert_mesh.py b/scripts/tools/convert_mesh.py index 4147f618d22..8229fa68bc3 100644 --- a/scripts/tools/convert_mesh.py +++ b/scripts/tools/convert_mesh.py @@ -119,17 +119,19 @@ def main(): # Create Mesh converter config collision_cfg = None - if args_cli.collision_approximation == 'convexDecomposition': + if args_cli.collision_approximation == "convexDecomposition": collision_cfg = schemas_cfg.ConvexDecompositionPropertiesCfg() - elif args_cli.collision_approximation == 'convexHull': + elif args_cli.collision_approximation == "convexHull": collision_cfg = schemas_cfg.ConvexHullPropertiesCfg() - elif args_cli.collision_approximation == 'boundingCube': + elif args_cli.collision_approximation == "boundingCube": collision_cfg = schemas_cfg.BoundingCubePropertiesCfg() elif args_cli.collision_approximation == "boundingSphere": collision_cfg = schemas_cfg.BoundingSpherePropertiesCfg() elif args_cli.collision_approximation == "meshSimplification": collision_cfg = schemas_cfg.TriangleMeshSimplificationPropertiesCfg() - + else: + raise ValueError(f"Invalid collision approximation type {args_cli.collision_approximation}.") + mesh_converter_cfg = MeshConverterCfg( mass_props=mass_props, rigid_props=rigid_props, @@ -139,7 +141,7 @@ def main(): usd_dir=os.path.dirname(dest_path), usd_file_name=os.path.basename(dest_path), make_instanceable=args_cli.make_instanceable, - mesh_collision_props=collision_cfg + mesh_collision_props=collision_cfg, ) # Print info From 8aa0de809d0bd8e2873cb9b9890cca577bbc6d90 Mon Sep 17 00:00:00 2001 From: zehao-wang <59912787+zehao-wang@users.noreply.github.com> Date: Tue, 14 Oct 2025 12:20:30 +0200 Subject: [PATCH 4/4] remove dangling if-else refer to @ooctipus solution Signed-off-by: zehao-wang <59912787+zehao-wang@users.noreply.github.com> --- scripts/tools/convert_mesh.py | 51 ++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/scripts/tools/convert_mesh.py b/scripts/tools/convert_mesh.py index 8229fa68bc3..bce2c66ef71 100644 --- a/scripts/tools/convert_mesh.py +++ b/scripts/tools/convert_mesh.py @@ -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.") @@ -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", @@ -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 @@ -118,19 +138,14 @@ def main(): collision_props = schemas_cfg.CollisionPropertiesCfg(collision_enabled=args_cli.collision_approximation != "none") # Create Mesh converter config - collision_cfg = None - if args_cli.collision_approximation == "convexDecomposition": - collision_cfg = schemas_cfg.ConvexDecompositionPropertiesCfg() - elif args_cli.collision_approximation == "convexHull": - collision_cfg = schemas_cfg.ConvexHullPropertiesCfg() - elif args_cli.collision_approximation == "boundingCube": - collision_cfg = schemas_cfg.BoundingCubePropertiesCfg() - elif args_cli.collision_approximation == "boundingSphere": - collision_cfg = schemas_cfg.BoundingSpherePropertiesCfg() - elif args_cli.collision_approximation == "meshSimplification": - collision_cfg = schemas_cfg.TriangleMeshSimplificationPropertiesCfg() - else: - raise ValueError(f"Invalid collision approximation type {args_cli.collision_approximation}.") + 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,