-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[FEATURE] Add support of USD import for Rigid Body. #2067
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
base: main
Are you sure you want to change the base?
Conversation
|
can you add a unit test? The assets can be put into the huggingface repo. An example is like this Genesis/tests/test_rigid_physics.py Line 581 in 4922239
|
|
🔴 Benchmark Regression Detected ➡️ Report |
|
You are getting some timeout error in example CI for your newly introduced example. |
|
The scene is too complex. You are dying processing more than 511 geometries. EDIT: Several options:
|
I think I will remove it from CI, because we have unit tests |
There is no relation between both. Example CI is not there to serve as unit test, because they do not check anything in the first place... But to make sure that the example scripts that we provide are running! Completely different objective. It is very important to run all our example scripts on the CI? otherwise they will break sooner than later. |
I see, then I would like to upload a relative simple asset to Huggingface and use it. |
…amples according to review; Improve polar, and its test
|
Do not forget to update the official Genesis documentation accordingly (not the documenting the API) but real doc with tutorial and explanation of the basics and what is supported for now. |
Yep, I'll add it when we are almost done. |
Yes, go ahead. For example scripts it is completely fine. |
| return transform_by_R(pos - trans, R_inv) | ||
|
|
||
|
|
||
| def _polar_torch(A, pure_rotation: bool, side: Literal["right", "left"]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use _tc_ prefix for torch implementation.
| return transform_by_R(pos - trans, R_inv) | ||
|
|
||
|
|
||
| def _polar_torch(A, pure_rotation: bool, side: Literal["right", "left"]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add typing for A: torch.Tensor
| return U, P | ||
|
|
||
|
|
||
| def _polar_numpy(A, pure_rotation: bool, side: Literal["right", "left"]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_np_ prefix + A typing : def _np_polar(A: np.ndarray,
| if isinstance(A, torch.Tensor): | ||
| return _polar_torch(A, pure_rotation, side) | ||
| elif isinstance(A, np.ndarray): | ||
| return _polar_numpy(A, pure_rotation, side) | ||
| else: | ||
| gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(A)=}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you return, no need for elif-else clauses. It will raise an exception in the future when Ruff will be fully enforced.
if isinstance(A, torch.Tensor):
return _polar_torch(A, pure_rotation, side)
if isinstance(A, np.ndarray):
return _polar_numpy(A, pure_rotation, side)
gs.raise_exception(f"the input must be either torch.Tensor or np.ndarray. got: {type(A)=}")|
I don't have any more comments to add. Just need to resolve what is still open and we are good to go! |
| @pytest.fixture | ||
| def tol(): | ||
| """ | ||
| Custom tolerance for USD tests. | ||
| USD Joint Limits use float32 (C++ float) precision, so we need a tolerance | ||
| that's appropriate for float32 rather than the default float64 tolerance. | ||
| """ | ||
| return 1e-6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right approach. You should rather use @pytest.mark.parametrize("precision", ["32"]) "decorator". This will map tol to the appropriate tolerance. It is np.finfo(np.float32).eps, i.e. ~1.19e-7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it does not pass, hardcode 1e-6 where needed with a comment stating that large tolerance is needed for unknown reason.
Description
This PR adds comprehensive USD (Universal Scene Description) import functionality to Genesis, enabling users to directly import USD stages containing articulated structures and rigid bodies into Genesis simulation scenes.
The implementation includes:
Scene.add_stage()method for easy USD file importUSDArticulationandUSDRigidBodymorph classes for USD-based entitiesKey components:
UsdParser: Main parser entrance withimport_from_stage()methodUsdArticulationParser: Extracts and parses articulation structures from USD stagesUsdRigidBodyParser: Extracts and parses rigid body prims from USD stagesUsdRenderingMaterialParser: Parses USD materials and shadersUsdParserContext: Context manager for tracking parsed entities and materialsUsdParserUtils: Utility functions for transform computation, mesh conversion, and coordinate system transformationsMotivation and Context
USD is a widely-used format in the robotics and simulation community, particularly in tools like NVIDIA Isaac Sim, Omniverse, and other industry-standard platforms. Adding USD import capability allows Genesis users to:
This feature significantly improves Genesis's interoperability with the broader robotics and simulation ecosystem.
How Has This Been / Can This Be Tested?
The feature can be tested using the provided example script:
Testing Checklist:
Test Files:
examples/usd/import_stage.pyScreenshots (if appropriate):
20251202-115133.mp4
Checklist:
I read the CONTRIBUTING document.
I followed the
Submitting Code Changessection of CONTRIBUTING document.I tagged the title correctly (including BUG FIX/FEATURE/MISC/BREAKING)
I updated the documentation accordingly or no change is needed.
I tested my changes and added instructions on how to test it for reviewers.
I have added tests to cover my changes.
All new and existing tests passed.