refactor(convert): Add physx_max_convex_hulls, max_vertices, max_voxel_res to MeshtoUSDConverter. (#57)
This commit is contained in:
parent
a256674bf2
commit
fb637f9afc
@ -45,8 +45,8 @@ with gr.Blocks(delete_cache=(43200, 43200), theme=custom_theme) as demo:
|
|||||||
## ***EmbodiedGen***: Image-to-3D Asset
|
## ***EmbodiedGen***: Image-to-3D Asset
|
||||||
**🔖 Version**: {VERSION}
|
**🔖 Version**: {VERSION}
|
||||||
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
|
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
|
||||||
<a href="https://horizonrobotics.github.io/robot_lab/embodied_gen/index.html">
|
<a href="https://horizonrobotics.github.io/EmbodiedGen">
|
||||||
<img alt="🌐 Project Page" src="https://img.shields.io/badge/🌐-Project_Page-blue">
|
<img alt="📖 Documentation" src="https://img.shields.io/badge/📖-Documentation-blue">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://arxiv.org/abs/2506.10600">
|
<a href="https://arxiv.org/abs/2506.10600">
|
||||||
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">
|
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">
|
||||||
|
|||||||
@ -45,8 +45,8 @@ with gr.Blocks(delete_cache=(43200, 43200), theme=custom_theme) as demo:
|
|||||||
## ***EmbodiedGen***: Text-to-3D Asset
|
## ***EmbodiedGen***: Text-to-3D Asset
|
||||||
**🔖 Version**: {VERSION}
|
**🔖 Version**: {VERSION}
|
||||||
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
|
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
|
||||||
<a href="https://horizonrobotics.github.io/robot_lab/embodied_gen/index.html">
|
<a href="https://horizonrobotics.github.io/EmbodiedGen">
|
||||||
<img alt="🌐 Project Page" src="https://img.shields.io/badge/🌐-Project_Page-blue">
|
<img alt="📖 Documentation" src="https://img.shields.io/badge/📖-Documentation-blue">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://arxiv.org/abs/2506.10600">
|
<a href="https://arxiv.org/abs/2506.10600">
|
||||||
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">
|
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">
|
||||||
|
|||||||
@ -55,8 +55,8 @@ with gr.Blocks(delete_cache=(43200, 43200), theme=custom_theme) as demo:
|
|||||||
## ***EmbodiedGen***: Texture Generation
|
## ***EmbodiedGen***: Texture Generation
|
||||||
**🔖 Version**: {VERSION}
|
**🔖 Version**: {VERSION}
|
||||||
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
|
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
|
||||||
<a href="https://horizonrobotics.github.io/robot_lab/embodied_gen/index.html">
|
<a href="https://horizonrobotics.github.io/EmbodiedGen">
|
||||||
<img alt="🌐 Project Page" src="https://img.shields.io/badge/🌐-Project_Page-blue">
|
<img alt="📖 Documentation" src="https://img.shields.io/badge/📖-Documentation-blue">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://arxiv.org/abs/2506.10600">
|
<a href="https://arxiv.org/abs/2506.10600">
|
||||||
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">
|
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">
|
||||||
|
|||||||
@ -479,8 +479,8 @@ with gr.Blocks(
|
|||||||
|
|
||||||
**🔖 Version**: {VERSION}
|
**🔖 Version**: {VERSION}
|
||||||
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
|
<p style="display: flex; gap: 10px; flex-wrap: nowrap;">
|
||||||
<a href="https://horizonrobotics.github.io/robot_lab/embodied_gen/index.html">
|
<a href="https://horizonrobotics.github.io/EmbodiedGen">
|
||||||
<img alt="🌐 Project Page" src="https://img.shields.io/badge/🌐-Project_Page-blue">
|
<img alt="📖 Documentation" src="https://img.shields.io/badge/📖-Documentation-blue">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://arxiv.org/abs/2506.10600">
|
<a href="https://arxiv.org/abs/2506.10600">
|
||||||
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">
|
<img alt="📄 arXiv" src="https://img.shields.io/badge/📄-arXiv-b31b1b">
|
||||||
|
|||||||
@ -488,8 +488,8 @@ class MeshtoUSDConverter(AssetConverterBase):
|
|||||||
|
|
||||||
DEFAULT_BIND_APIS = [
|
DEFAULT_BIND_APIS = [
|
||||||
"MaterialBindingAPI",
|
"MaterialBindingAPI",
|
||||||
# "PhysicsMeshCollisionAPI",
|
"PhysicsMeshCollisionAPI",
|
||||||
"PhysxDecompositionCollisionAPI",
|
"PhysxConvexDecompositionCollisionAPI",
|
||||||
"PhysicsCollisionAPI",
|
"PhysicsCollisionAPI",
|
||||||
"PhysxCollisionAPI",
|
"PhysxCollisionAPI",
|
||||||
"PhysicsMassAPI",
|
"PhysicsMassAPI",
|
||||||
@ -515,10 +515,10 @@ class MeshtoUSDConverter(AssetConverterBase):
|
|||||||
if simulation_app is not None:
|
if simulation_app is not None:
|
||||||
self.simulation_app = simulation_app
|
self.simulation_app = simulation_app
|
||||||
|
|
||||||
if "exit_close" in kwargs:
|
self.exit_close = kwargs.pop("exit_close", True)
|
||||||
self.exit_close = kwargs.pop("exit_close")
|
self.physx_max_convex_hulls = kwargs.pop("physx_max_convex_hulls", 32)
|
||||||
else:
|
self.physx_max_vertices = kwargs.pop("physx_max_vertices", 16)
|
||||||
self.exit_close = True
|
self.physx_max_voxel_res = kwargs.pop("physx_max_voxel_res", 10000)
|
||||||
|
|
||||||
self.usd_parms = dict(
|
self.usd_parms = dict(
|
||||||
force_usd_conversion=force_usd_conversion,
|
force_usd_conversion=force_usd_conversion,
|
||||||
@ -548,12 +548,12 @@ class MeshtoUSDConverter(AssetConverterBase):
|
|||||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
"""Context manager exit, closes simulation app if created."""
|
"""Context manager exit, closes simulation app if created."""
|
||||||
# Close the simulation app if it was created here
|
# Close the simulation app if it was created here
|
||||||
if hasattr(self, "app_launcher") and self.exit_close:
|
|
||||||
self.simulation_app.close()
|
|
||||||
|
|
||||||
if exc_val is not None:
|
if exc_val is not None:
|
||||||
logger.error(f"Exception occurred: {exc_val}.")
|
logger.error(f"Exception occurred: {exc_val}.")
|
||||||
|
|
||||||
|
if hasattr(self, "app_launcher") and self.exit_close:
|
||||||
|
self.simulation_app.close()
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def convert(self, urdf_path: str, output_file: str):
|
def convert(self, urdf_path: str, output_file: str):
|
||||||
@ -601,8 +601,6 @@ class MeshtoUSDConverter(AssetConverterBase):
|
|||||||
|
|
||||||
# Add convex decomposition collision and set ShrinkWrap.
|
# Add convex decomposition collision and set ShrinkWrap.
|
||||||
elif prim.GetName() == "mesh":
|
elif prim.GetName() == "mesh":
|
||||||
approx_attr = prim.GetAttribute("physics:approximation")
|
|
||||||
if not approx_attr:
|
|
||||||
approx_attr = prim.CreateAttribute(
|
approx_attr = prim.CreateAttribute(
|
||||||
"physics:approximation", Sdf.ValueTypeNames.Token
|
"physics:approximation", Sdf.ValueTypeNames.Token
|
||||||
)
|
)
|
||||||
@ -613,6 +611,15 @@ class MeshtoUSDConverter(AssetConverterBase):
|
|||||||
prim
|
prim
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
physx_conv_api.GetMaxConvexHullsAttr().Set(
|
||||||
|
self.physx_max_convex_hulls
|
||||||
|
)
|
||||||
|
physx_conv_api.GetHullVertexLimitAttr().Set(
|
||||||
|
self.physx_max_vertices
|
||||||
|
)
|
||||||
|
physx_conv_api.GetVoxelResolutionAttr().Set(
|
||||||
|
self.physx_max_voxel_res
|
||||||
|
)
|
||||||
physx_conv_api.GetShrinkWrapAttr().Set(True)
|
physx_conv_api.GetShrinkWrapAttr().Set(True)
|
||||||
|
|
||||||
api_schemas = prim.GetMetadata("apiSchemas")
|
api_schemas = prim.GetMetadata("apiSchemas")
|
||||||
@ -639,8 +646,8 @@ class PhysicsUSDAdder(MeshtoUSDConverter):
|
|||||||
|
|
||||||
DEFAULT_BIND_APIS = [
|
DEFAULT_BIND_APIS = [
|
||||||
"MaterialBindingAPI",
|
"MaterialBindingAPI",
|
||||||
# "PhysicsMeshCollisionAPI",
|
"PhysicsMeshCollisionAPI",
|
||||||
"PhysxDecompositionCollisionAPI",
|
"PhysxConvexDecompositionCollisionAPI",
|
||||||
"PhysicsCollisionAPI",
|
"PhysicsCollisionAPI",
|
||||||
"PhysxCollisionAPI",
|
"PhysxCollisionAPI",
|
||||||
"PhysicsRigidBodyAPI",
|
"PhysicsRigidBodyAPI",
|
||||||
@ -675,18 +682,23 @@ class PhysicsUSDAdder(MeshtoUSDConverter):
|
|||||||
if "lightfactory" in prim.GetName().lower():
|
if "lightfactory" in prim.GetName().lower():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
approx_attr = prim.GetAttribute(
|
|
||||||
"physics:approximation"
|
|
||||||
)
|
|
||||||
if not approx_attr:
|
|
||||||
approx_attr = prim.CreateAttribute(
|
approx_attr = prim.CreateAttribute(
|
||||||
"physics:approximation",
|
"physics:approximation", Sdf.ValueTypeNames.Token
|
||||||
Sdf.ValueTypeNames.Token,
|
|
||||||
)
|
)
|
||||||
approx_attr.Set("convexDecomposition")
|
approx_attr.Set("convexDecomposition")
|
||||||
|
|
||||||
physx_conv_api = PhysxSchema.PhysxConvexDecompositionCollisionAPI.Apply(
|
physx_conv_api = PhysxSchema.PhysxConvexDecompositionCollisionAPI.Apply(
|
||||||
prim
|
prim
|
||||||
)
|
)
|
||||||
|
physx_conv_api.GetMaxConvexHullsAttr().Set(
|
||||||
|
self.physx_max_convex_hulls
|
||||||
|
)
|
||||||
|
physx_conv_api.GetHullVertexLimitAttr().Set(
|
||||||
|
self.physx_max_vertices
|
||||||
|
)
|
||||||
|
physx_conv_api.GetVoxelResolutionAttr().Set(
|
||||||
|
self.physx_max_voxel_res
|
||||||
|
)
|
||||||
physx_conv_api.GetShrinkWrapAttr().Set(True)
|
physx_conv_api.GetShrinkWrapAttr().Set(True)
|
||||||
|
|
||||||
rigid_body_api = UsdPhysics.RigidBodyAPI.Apply(prim)
|
rigid_body_api = UsdPhysics.RigidBodyAPI.Apply(prim)
|
||||||
@ -790,8 +802,6 @@ class URDFtoUSDConverter(MeshtoUSDConverter):
|
|||||||
with Usd.EditContext(stage, layer):
|
with Usd.EditContext(stage, layer):
|
||||||
for prim in stage.Traverse():
|
for prim in stage.Traverse():
|
||||||
if prim.GetName() == "collisions":
|
if prim.GetName() == "collisions":
|
||||||
approx_attr = prim.GetAttribute("physics:approximation")
|
|
||||||
if not approx_attr:
|
|
||||||
approx_attr = prim.CreateAttribute(
|
approx_attr = prim.CreateAttribute(
|
||||||
"physics:approximation", Sdf.ValueTypeNames.Token
|
"physics:approximation", Sdf.ValueTypeNames.Token
|
||||||
)
|
)
|
||||||
@ -802,6 +812,9 @@ class URDFtoUSDConverter(MeshtoUSDConverter):
|
|||||||
prim
|
prim
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
physx_conv_api.GetMaxConvexHullsAttr().Set(32)
|
||||||
|
physx_conv_api.GetHullVertexLimitAttr().Set(16)
|
||||||
|
physx_conv_api.GetVoxelResolutionAttr().Set(10000)
|
||||||
physx_conv_api.GetShrinkWrapAttr().Set(True)
|
physx_conv_api.GetShrinkWrapAttr().Set(True)
|
||||||
|
|
||||||
api_schemas = prim.GetMetadata("apiSchemas")
|
api_schemas = prim.GetMetadata("apiSchemas")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user