Add builder.add_joint_free in parse_body in import_usd#426
Conversation
Signed-off-by: apradhana <andre.pradhana@gmail.com>
📝 WalkthroughWalkthroughThe update adds a new method Changes
Sequence Diagram(s)sequenceDiagram
participant import_usd
participant builder
import_usd->>builder: set_inverse_inertia_matrices()
import_usd->>builder: add_free_joints_to_floating_bodies()
import_usd->>builder: collapse_fixed_joints()
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
newton/utils/import_usd.py(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
newton/utils/import_usd.py (1)
newton/sim/builder.py (1)
add_joint_free(1106-1157)
Signed-off-by: apradhana <andre.pradhana@gmail.com>
Signed-off-by: apradhana <andre.pradhana@gmail.com>
Signed-off-by: apradhana <andre.pradhana@gmail.com>
Signed-off-by: apradhana <andre.pradhana@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
newton/tests/test_import_usd.py (1)
158-167: LGTM! Test correctly validates the new free joint functionality.The test properly validates that the new
add_free_joints_to_floating_bodiesfunctionality works as expected, ensuring MJWarp compatibility by adding at least one joint to USD imports.Consider enhancing the test with additional assertions to make it more comprehensive:
@unittest.skipUnless(USD_AVAILABLE, "Requires usd-core") def test_import_cube_cylinder_joint_count(self): + """Test that floating bodies get free joints added for MJWarp compatibility.""" builder = newton.ModelBuilder() parse_usd( os.path.join(os.path.dirname(__file__), "assets", "cube_cylinder.usda"), builder, collapse_fixed_joints=True, invert_rotations=True, ) self.assertEqual(builder.joint_count, 1) + # Verify the added joint is a free joint + self.assertEqual(builder.joint_type[0], newton.JOINT_FREE)This would provide better validation that the correct type of joint is being added and include documentation explaining the test's purpose.
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
newton/tests/assets/cube_cylinder.usda(1 hunks)newton/tests/test_import_usd.py(1 hunks)
🧠 Learnings (1)
newton/tests/test_import_usd.py (1)
Learnt from: dylanturpin
PR: #394
File: newton/tests/test_ik.py:119-119
Timestamp: 2025-07-15T21:00:03.709Z
Learning: In the Newton physics engine codebase, it's acceptable to test private API functions (those prefixed with underscore) in unit and component tests, as the maintainers consider this appropriate for testing internal functionality.
✅ Files skipped from review due to trivial changes (1)
- newton/tests/assets/cube_cylinder.usda
🧰 Additional context used
🧠 Learnings (1)
newton/tests/test_import_usd.py (1)
Learnt from: dylanturpin
PR: #394
File: newton/tests/test_ik.py:119-119
Timestamp: 2025-07-15T21:00:03.709Z
Learning: In the Newton physics engine codebase, it's acceptable to test private API functions (those prefixed with underscore) in unit and component tests, as the maintainers consider this appropriate for testing internal functionality.
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Run GPU Unit Tests on AWS EC2 (Pull Request)
Signed-off-by: apradhana <andre.pradhana@gmail.com>
Signed-off-by: apradhana <andre.pradhana@gmail.com>
Signed-off-by: apradhana <andre.pradhana@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Signed-off-by: Eric Heiden <eheiden@nvidia.com>
|
pre-commit.ci autofix |
…s#426) Signed-off-by: apradhana <andre.pradhana@gmail.com> Signed-off-by: Eric Heiden <eheiden@nvidia.com> Co-authored-by: Eric Heiden <eheiden@nvidia.com>
…s#426) Signed-off-by: apradhana <andre.pradhana@gmail.com> Signed-off-by: Eric Heiden <eheiden@nvidia.com> Co-authored-by: Eric Heiden <eheiden@nvidia.com>
Purpose: In import_usd, free_floating_bodies should have free_joint. This should only be applied to bodies that are added by
import_usd.We want the result of parsing a USD as a

modelto also work with MJWarp. As MJWarp requires at least one joint, we add a free joint in the body that has none when we add a body to the builder. Here's an example of a simulation that we get after running the result of import_usd through MJWarp:Here's the result of simulating cube_cylinder.usda that is in


tests/assetsthrough MJWarp and XPBD:Summary by CodeRabbit