Skip to content

[BugFix] fix bug of joint relationship process in USDAsset._as_trimesh_scene() #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

Kobayashi-z
Copy link

Why

Previously, joints were being processed twice due to USD's bidirectional nature, causing incorrect hierarchy issues. This fix ensures consistent scene graph construction. So I skip processing when encountering the reversed entry
USD joints are bidirectional (A-B is same as B-A).

                joints[(body_0, body_1)] = joint_prim

                joints[(body_1, body_0)] = "reversed"

here

@clemense
Copy link
Collaborator

Do you have an example USD file that fails, and for which this change improves things? I'm getting errors with some test file imports due to this change.

@clemense
Copy link
Collaborator

Just to be clear joints are not being processed twice currently.

@Kobayashi-z
Copy link
Author

Kobayashi-z commented Apr 9, 2025

Thanks for your response. You can test with the USD file in the attachment (note: you'll need to rename the file extension to .usd). I encountered an error when running the following code.

import scene_synthesizer
from scene_synthesizer.assets import USDAsset
scene = scene_synthesizer.Scene()
asset = USDAsset("FoodMixer.usd")
scene.add_object(asset, "foodmixer")

The traceback is below

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xiaolin.zhou/code/scene_synthesizer/src/scene_synthesizer/scene.py", line 1388, in add_object
    scene_to_add = asset.as_trimesh_scene(
  File "/home/xiaolin.zhou/code/scene_synthesizer/src/scene_synthesizer/assets.py", line 648, in as_trimesh_scene
    trimesh_scene = self._as_trimesh_scene(
  File "/home/xiaolin.zhou/code/scene_synthesizer/src/scene_synthesizer/assets.py", line 1195, in _as_trimesh_scene
    raise ValueError("Can't parse USD. Tree structure incorrect.")
ValueError: Can't parse USD. Tree structure incorrect.

FoodMixer.txt

@clemense
Copy link
Collaborator

clemense commented May 14, 2025

Thanks! The USD contains a loop, that's why it can't be parsed into the scene_synth scene graph (which is a DAG).

Two immediate options:

  1. If you don't care about the articulation of the object, you can use ignore_articulation=True during import. This will ignore all joints in the USD.
  2. You can load the asset as a reference via reference_only=True which will not parse the USD but keep a pointer to it. During export to USD you can do write_usd_object_files=False which will include a reference to the original file.

If that doesn't fit your use case we can look into adding an option to break the loop by ignoring a joint during parsing.

@clemense
Copy link
Collaborator

clemense commented May 14, 2025

Let me revise my explanation: There doesn't seem to be a kinematic loop. Instead the problem is that the PhysicsArticulationRootAPI is applied twice, to the following prims: /world/object/_body_0 and /world/object/worldBody.

@clemense
Copy link
Collaborator

Ok. The latest version (v1.14.13) has two additional changes:

  • The USD import logic now breaks loops (by preferring to not ignore joint constraints) which enables it to load more files (such as the FoodMixer.usd)
  • The visibility attribute is now respected, i.e. meshes/prims that are invisible are not loaded (old behavior can be reproduced by setting ignore_visibility=True)

I will now also close the MR, since the issue (that this MR tried to address) is resolved.

@clemense clemense closed this May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants