Unverified Commit c0d01d7e authored by robotsfan's avatar robotsfan Committed by GitHub

Ensures mesh name is compatible with USD convention in mesh converter (#1302)

# Description

Fixes #1287

**Issue details**: When using the convert_mesh.py script to convert .obj
to .usd, if the obj file in this scene starts with a
number(0c334eaabb844eaaad049cbbb2e0a4f2.obj), while the USD API
prohibits names that start with a number
[Link](https://openusd.org/release/api/group__group__tf___string.html#gaa129b294af3f68d01477d430b70d40c8).
This issue is described in more detail here:
[Link](https://forums.developer.nvidia.com/t/cant-create-prims-if-name-starts-with-number/249617).

Also deleted useless debugging output code.

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [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
- [x] 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
parent 952f6484
...@@ -10,7 +10,7 @@ import omni ...@@ -10,7 +10,7 @@ import omni
import omni.kit.commands import omni.kit.commands
import omni.usd import omni.usd
from omni.isaac.core.utils.extensions import enable_extension from omni.isaac.core.utils.extensions import enable_extension
from pxr import Usd, UsdGeom, UsdPhysics, UsdUtils from pxr import Tf, Usd, UsdGeom, UsdPhysics, UsdUtils
from omni.isaac.lab.sim.converters.asset_converter_base import AssetConverterBase from omni.isaac.lab.sim.converters.asset_converter_base import AssetConverterBase
from omni.isaac.lab.sim.converters.mesh_converter_cfg import MeshConverterCfg from omni.isaac.lab.sim.converters.mesh_converter_cfg import MeshConverterCfg
...@@ -81,6 +81,16 @@ class MeshConverter(AssetConverterBase): ...@@ -81,6 +81,16 @@ class MeshConverter(AssetConverterBase):
mesh_file_basename, mesh_file_format = os.path.basename(cfg.asset_path).split(".") mesh_file_basename, mesh_file_format = os.path.basename(cfg.asset_path).split(".")
mesh_file_format = mesh_file_format.lower() mesh_file_format = mesh_file_format.lower()
# Check if mesh_file_basename is a valid USD identifier
if not Tf.IsValidIdentifier(mesh_file_basename):
# Correct the name to a valid identifier and update the basename
mesh_file_basename_original = mesh_file_basename
mesh_file_basename = Tf.MakeValidIdentifier(mesh_file_basename)
omni.log.warn(
f"Input file name '{mesh_file_basename_original}' is an invalid identifier for the mesh prim path."
f" Renaming it to '{mesh_file_basename}' for the conversion."
)
# Convert USD # Convert USD
asyncio.get_event_loop().run_until_complete( asyncio.get_event_loop().run_until_complete(
self._convert_mesh_to_usd( self._convert_mesh_to_usd(
......
...@@ -106,10 +106,6 @@ def main(): ...@@ -106,10 +106,6 @@ def main():
if not os.path.isabs(dest_path): if not os.path.isabs(dest_path):
dest_path = os.path.abspath(dest_path) dest_path = os.path.abspath(dest_path)
print(dest_path)
print(os.path.dirname(dest_path))
print(os.path.basename(dest_path))
# Mass properties # Mass properties
if args_cli.mass is not None: if args_cli.mass is not None:
mass_props = schemas_cfg.MassPropertiesCfg(mass=args_cli.mass) mass_props = schemas_cfg.MassPropertiesCfg(mass=args_cli.mass)
......
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