Skip to content

Use the same order for the GEO_ types as in MuJoCo#507

Merged
nvlukasz merged 12 commits into
newton-physics:mainfrom
nvtw:dev/tw/use_mujoco_geo_order
Aug 7, 2025
Merged

Use the same order for the GEO_ types as in MuJoCo#507
nvlukasz merged 12 commits into
newton-physics:mainfrom
nvtw:dev/tw/use_mujoco_geo_order

Conversation

@nvtw

@nvtw nvtw commented Aug 5, 2025

Copy link
Copy Markdown
Member

Description

Use the same order for the GEO_ types as in MuJoCo. Add a conversion method such that type ordering remains unchanged - otherwise big if elif trees must be adjusted which is a big hassle.

Newton Migration Guide

Please ensure the migration guide for warp.sim users is up-to-date with the changes made in this MR.

  • [~] The migration guide in docs/migration.rst is up-to date

Before your PR is "Ready for review"

  • All commits are signed-off to indicate that your contribution adheres to the Developer Certificate of Origin requirements
  • [~] Necessary tests have been added and new examples are tested (see newton/tests/test_examples.py)
  • Documentation is up-to-date
  • Code passes formatting and linting checks with pre-commit run -a

Summary by CodeRabbit

  • New Features

    • Added support for new geometry types, including HFIELD and ELLIPSOID, to align with MuJoCo standards.
  • Refactor

    • Replaced individual geometry type constants with a unified GeoType enumeration across the entire geometry module.
    • Updated all geometry type references in APIs, collision detection, rendering, and tests to use the GeoType enum for consistency.
    • Simplified imports and exports by consolidating multiple geometry constants into the GeoType enum.
    • Improved documentation to reflect the new enum-based geometry type naming.
    • Introduced a temporary mapping function to maintain compatibility with legacy geometry type orderings in collision detection.

@nvtw nvtw requested a review from eric-heiden August 5, 2025 12:24
@coderabbitai

coderabbitai Bot commented Aug 5, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes introduce a new function to convert MuJoCo-compatible geometry type integers into legacy collision detection orderings. Geometry type constants are replaced by a new GeoType enum matching MuJoCo's enumeration, including additional types and updated integer values. Collision detection kernels and all references to geometry types are updated to use the new enum and conversion function.

Changes

Cohort / File(s) Change Summary
Geometry Type Conversion Function and Kernel Updates
newton/geometry/kernels.py
Added geo_new_to_old_map function to map new geometry type integers to legacy collision detection order. Updated collision detection kernels to use this function and replaced all geometry type constants with GeoType enum members.
Geometry Type Enum Definition
newton/geometry/types.py
Removed individual geometry type constants and replaced them with a new GeoType enum class matching MuJoCo's mjGeomTypes enumeration, adding new geometry types and updating integer assignments.
Geometry Module Imports and Exports Update
newton/__init__.py, newton/geometry/__init__.py
Replaced multiple individual geometry constants imports and exports with a single GeoType enum import and export, simplifying the public API.
Geometry Type Enum Usage in Geometry Modules
newton/geometry/inertia.py, newton/geometry/raycast.py, newton/geometry/utils.py
Replaced all references to individual geometry type constants with GeoType enum members in functions and imports. No logic changes.
Geometry Type Enum Usage in Simulation Builder
newton/sim/builder.py
Replaced all geometry type constants with GeoType enum members in imports, function arguments, and internal logic related to shape types.
Geometry Type Enum Usage in MuJoCo Solver
newton/solvers/mujoco/solver_mujoco.py
Updated geometry type constant references to use GeoType enum members within the MuJoCoSolver.convert_to_mjc method and nested functions.
Geometry Type Enum Usage in Rendering Utilities
newton/utils/render.py
Updated all geometry type constant references to use GeoType enum members in the SimRenderer.populate_shapes method.
Documentation Update
docs/api/newton_geometry.rst
Updated documentation to reflect the use of GeoType enum members instead of individual geometry type constants.
Test Code Updates
newton/tests/test_gjk.py, newton/tests/test_import_urdf.py, newton/tests/test_import_usd.py, newton/tests/test_model.py, newton/tests/test_raycast.py
Updated test imports and assertions to use GeoType enum members instead of individual geometry type constants. No logic changes.
Benchmark Configuration Update
asv.conf.json
Updated the version of the warp-lang package installed during environment setup from 1.9.0.dev20250731 to 1.9.0.dev20250806.

Sequence Diagram(s)

sequenceDiagram
    participant Kernel as Collision Kernel
    participant Types as Geometry Types
    participant Converter as geo_new_to_old_map

    Kernel->>Types: Get geometry type constant
    Kernel->>Converter: Convert new geometry type to old ordering
    Converter-->>Kernel: Return legacy geometry type integer
    Kernel->>Kernel: Compare legacy geometry type integers
    Kernel-->>Kernel: Proceed with collision logic
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • eric-heiden
  • Milad-Rakhsha-NV

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2325e2e and 2fea4cc.

📒 Files selected for processing (1)
  • newton/geometry/inertia.py (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • newton/geometry/inertia.py
⏰ 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)
  • GitHub Check: Run GPU Unit Tests on AWS EC2 (Pull Request)
  • GitHub Check: Run GPU Benchmarks (Pull Request)
  • GitHub Check: run-newton-tests / newton-unittests (windows-latest)
  • GitHub Check: run-newton-tests / newton-unittests (ubuntu-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Signed-off-by: twidmer <twidmer@nvidia.com>
@nvtw nvtw force-pushed the dev/tw/use_mujoco_geo_order branch from 7faf21b to 0d36f4f Compare August 5, 2025 12:27
@nvtw nvtw self-assigned this Aug 5, 2025
@nvtw nvtw requested a review from mmacklin August 5, 2025 12:33

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 900cbd8 and 0d36f4f.

📒 Files selected for processing (2)
  • newton/geometry/kernels.py (3 hunks)
  • newton/geometry/types.py (1 hunks)
⏰ 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). (2)
  • GitHub Check: Run GPU Unit Tests on AWS EC2 (Pull Request)
  • GitHub Check: Run GPU Benchmarks (Pull Request)
🔇 Additional comments (3)
newton/geometry/kernels.py (3)

769-794: LGTM! Conversion function correctly maps geometry types.

The geo_new_to_old_python function provides a clean bridge between the new MuJoCo-compatible geometry type ordering and the legacy collision detection system. The mapping is comprehensive and handles unsupported types (HFIELD, ELLIPSOID) appropriately by treating them as equivalent to GEO_NONE.


822-822: LGTM! Conversion function usage maintains deterministic collision pair ordering.

The use of geo_new_to_old_python in the shape pair comparison ensures that collision pairs maintain consistent ordering based on the legacy collision detection scheme, which is essential for deterministic collision processing.


922-922: LGTM! Consistent conversion function usage across collision kernels.

The use of geo_new_to_old_python in broadphase_collision_pairs is consistent with its usage in count_contact_points, ensuring uniform collision pair ordering logic across the collision detection system.

Comment thread newton/geometry/types.py Outdated
nvtw added 2 commits August 5, 2025 17:53
Signed-off-by: twidmer <twidmer@nvidia.com>
Signed-off-by: twidmer <twidmer@nvidia.com>
@nvtw nvtw force-pushed the dev/tw/use_mujoco_geo_order branch from 42cbc26 to 8d4f161 Compare August 5, 2025 15:53
@nvtw nvtw requested a review from nvlukasz August 5, 2025 16:07

@nvlukasz nvlukasz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love how this simplifies the imports (just import the type instead of all the constants). Good change, just a couple of questions/suggestions about the new_to_old conversion.

Comment thread newton/geometry/kernels.py
Comment thread newton/geometry/kernels.py Outdated
Signed-off-by: twidmer <twidmer@nvidia.com>
@nvtw

nvtw commented Aug 6, 2025

Copy link
Copy Markdown
Member Author

@nvlukasz can it be that github uses an older warp version that does not yet support IntEnum? I cannot really explain the github CI failures otherwise. The tests pass on my local machine.

@nvlukasz

nvlukasz commented Aug 6, 2025

Copy link
Copy Markdown
Member

@nvlukasz can it be that github uses an older warp version that does not yet support IntEnum? I cannot really explain the github CI failures otherwise. The tests pass on my local machine.

Hmmm, I assume that the runners pull the nightly Warp, but @shi-eric can confirm.

@shi-eric

shi-eric commented Aug 6, 2025

Copy link
Copy Markdown
Member

@nvlukasz can it be that github uses an older warp version that does not yet support IntEnum? I cannot really explain the github CI failures otherwise. The tests pass on my local machine.

Hmmm, I assume that the runners pull the nightly Warp, but @shi-eric can confirm.

The versions of all dependencies we use in CI/CD are always from the uv.lock file to ensure that the main branch always has a good set of dependencies that Newton can run with. Learn more about what the lockfile is here: https://docs.astral.sh/uv/concepts/projects/layout/#the-lockfile

Ideally the pull request that needs a newer dependency will update both the uv.lock and asv.conf.json files.

For uv, you would run uv lock --upgrade-package warp-lang

uv lock --upgrade-package warp-lang
Resolved 127 packages in 2.38s
Updated warp-lang v1.8.0, v1.9.0.dev20250731 -> v1.8.1, v1.9.0.dev20250806

Then add and commit the modified uv.lock file. For asv.conf.json I just manually edit it.

nvtw and others added 4 commits August 7, 2025 08:51
Signed-off-by: twidmer <twidmer@nvidia.com>
Signed-off-by: twidmer <twidmer@nvidia.com>
Signed-off-by: twidmer <twidmer@nvidia.com>
Comment thread newton/geometry/types.py
Comment thread newton/geometry/types.py Outdated
Signed-off-by: twidmer <twidmer@nvidia.com>
@nvtw nvtw force-pushed the dev/tw/use_mujoco_geo_order branch from 1cde574 to 5500c81 Compare August 7, 2025 14:50

@nvlukasz nvlukasz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good let's goooo

Signed-off-by: twidmer <twidmer@nvidia.com>
@nvlukasz nvlukasz enabled auto-merge (squash) August 7, 2025 14:59
…ormance

Signed-off-by: twidmer <twidmer@nvidia.com>
@shi-eric

shi-eric commented Aug 7, 2025

Copy link
Copy Markdown
Member

@nvtw I'm curious if the regression in simulation.bench_mujoco.FastHumanoid.time_simulate in https://github.com/newton-physics/newton/actions/runs/16808101740/job/47610041431 was found to be accurate after additional testing on your machine? Trying to get a sense of how reliable the AWS machines are for ASV benchmarking and if we need to make any tweaks...

@nvlukasz

nvlukasz commented Aug 7, 2025

Copy link
Copy Markdown
Member

@nvtw I'm curious if the regression in simulation.bench_mujoco.FastHumanoid.time_simulate in https://github.com/newton-physics/newton/actions/runs/16808101740/job/47610041431 was found to be accurate after additional testing on your machine? Trying to get a sense of how reliable the AWS machines are for ASV benchmarking and if we need to make any tweaks...

@shi-eric We re-ran it a few times with a few different variations, but the results seem consistent overall. The failure might be due to this branch being one commit behind main, and that commit increased the perf of the benchmark that's failing. I just merged main into this branch, so we shall see.

@nvlukasz nvlukasz merged commit a390cda into newton-physics:main Aug 7, 2025
11 checks passed
@Milad-Rakhsha-NV

Milad-Rakhsha-NV commented Aug 8, 2025

Copy link
Copy Markdown
Member

I started getting this error in

AttributeError: Error while parsing function "count_contact_points" at /home/mrakhsha/Documents/Repos/newton/newton/geometry/kernels.py:828:
        actual_type_b = GeoType.PLANE
;'GeoType' object has no attribute 'type'. Did you mean: '_return_value'?

not sure if this is related to this PR or not @nvlukasz @nvtw ?

@shi-eric

shi-eric commented Aug 8, 2025

Copy link
Copy Markdown
Member

I started getting this error in

AttributeError: Error while parsing function "count_contact_points" at /home/mrakhsha/Documents/Repos/newton/newton/geometry/kernels.py:828:
        actual_type_b = GeoType.PLANE
;'GeoType' object has no attribute 'type'. Did you mean: '_return_value'?

not sure if this is related to this PR or not @nvlukasz @nvtw ?

Make sure your Warp is updated to at least 1.9.0.dev20250806

@Milad-Rakhsha-NV

Copy link
Copy Markdown
Member

I started getting this error in

AttributeError: Error while parsing function "count_contact_points" at /home/mrakhsha/Documents/Repos/newton/newton/geometry/kernels.py:828:
        actual_type_b = GeoType.PLANE
;'GeoType' object has no attribute 'type'. Did you mean: '_return_value'?

not sure if this is related to this PR or not @nvlukasz @nvtw ?

Make sure your Warp is updated to at least 1.9.0.dev20250806

I am on (1.9.0.dev20250808) now but I still see

AttributeError: Error while parsing function "count_contact_points" at /home/horde/Documents/Repos/IsaacLab/_isaac_sim/kit/python/lib/python3.11/site-packages/newton/geometry/kernels.py:828:
        actual_type_b = GeoType.PLANE
;'GeoType' object has no attribute 'type'

@coderabbitai coderabbitai Bot mentioned this pull request Aug 8, 2025
5 tasks
@shi-eric

Copy link
Copy Markdown
Member

I am on (1.9.0.dev20250808) now but I still see

AttributeError: Error while parsing function "count_contact_points" at /home/horde/Documents/Repos/IsaacLab/_isaac_sim/kit/python/lib/python3.11/site-packages/newton/geometry/kernels.py:828:
        actual_type_b = GeoType.PLANE
;'GeoType' object has no attribute 'type'

Not saying this is what you're doing, but I get the:

AttributeError: Error while parsing function "count_contact_points" at /home/eshi/code-projects/newton/newton/geometry/kernels.py:828:
        actual_type_b = GeoType.PLANE.value
;'int' object has no attribute 'type'

error when I uninstall the locked version of warp-lang and install 1.9.0.dev20250725, which apparently doesn't support the IntEnum.

@nvlukasz

nvlukasz commented Aug 12, 2025

Copy link
Copy Markdown
Member

I am on (1.9.0.dev20250808) now but I still see

AttributeError: Error while parsing function "count_contact_points" at /home/horde/Documents/Repos/IsaacLab/_isaac_sim/kit/python/lib/python3.11/site-packages/newton/geometry/kernels.py:828:
        actual_type_b = GeoType.PLANE
;'GeoType' object has no attribute 'type'

If this is in Kit, make sure you're using Warp extensions with version 1.9.0.-beta.5 or higher. @AntoineRichard had a similar issue, but updating the extensions helped.

If you don't see the Warp init message on startup, you can print warp.__version__ to check.

@Milad-Rakhsha-NV

Copy link
Copy Markdown
Member

no this happens directly in Newton when running examples; However, it seems that upgrading to warp-lang 1.9.0.dev20250812 fixes this

@coderabbitai coderabbitai Bot mentioned this pull request Aug 27, 2025
3 tasks
eric-heiden pushed a commit to eric-heiden/newton that referenced this pull request Jan 28, 2026
Also use IntEnum instead of named constants

Signed-off-by: twidmer <twidmer@nvidia.com>
@coderabbitai coderabbitai Bot mentioned this pull request Feb 24, 2026
4 tasks
mmacklin pushed a commit to mmacklin/newton that referenced this pull request Apr 7, 2026
Also use IntEnum instead of named constants

Signed-off-by: twidmer <twidmer@nvidia.com>
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.

4 participants