Skip to content

Implement randomization and runtime update of equality constraint data + active #1192#1430

Merged
vreutskyy merged 7 commits into
newton-physics:mainfrom
vreutskyy:1192-implement-randomization-and-runtime-update-of-equality-constraint-data-active
Jan 22, 2026
Merged

Implement randomization and runtime update of equality constraint data + active #1192#1430
vreutskyy merged 7 commits into
newton-physics:mainfrom
vreutskyy:1192-implement-randomization-and-runtime-update-of-equality-constraint-data-active

Conversation

@vreutskyy

@vreutskyy vreutskyy commented Jan 21, 2026

Copy link
Copy Markdown
Member

Description

Closes #1192

Implements runtime update and randomization support for equality constraint eq_data and eq_active in SolverMuJoCo.

Changes

New Warp kernels (newton/_src/solvers/mujoco/kernels.py):

  • update_eq_data_kernel: Updates MuJoCo's eq_data from Newton's equality constraint properties based on constraint type:
    • CONNECT: copies equality_constraint_anchor
    • JOINT: copies equality_constraint_polycoef
    • WELD: copies anchor, equality_constraint_relpose, and equality_constraint_torquescale
  • update_eq_active_kernel: Updates MuJoCo's eq_active (in mjData) from Newton's equality_constraint_enabled

Solver updates (newton/_src/solvers/mujoco/solver_mujoco.py):

  • Extended update_eq_properties() to launch the new kernels when SolverNotifyFlags.EQUALITY_CONSTRAINT_PROPERTIES is set
  • Enabled "eq_data" in model_fields_to_expand for multi-world support

Documentation (newton/_src/solvers/flags.py):

  • Updated EQUALITY_CONSTRAINT_PROPERTIES docstring to reflect the new fields it covers

Tests (newton/tests/test_mujoco_solver.py):

  • Added test_eq_data_conversion_and_update: validates initial conversion and runtime updates of equality constraint data
  • Added test_eq_active_conversion_and_update: validates initial conversion and runtime toggling of constraint enabled state

Newton Migration Guide

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

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

Before your PR is "Ready for review"

  • 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

  • Documentation

    • Expanded equality-constraint docs to list additional related attributes and custom properties.
  • Improvements

    • Broadened propagation so equality constraint parameters and enablement reliably sync across replicated simulation worlds.
  • Tests

    • Added multi-world tests validating conversion and runtime updates of equality constraint data, torque scaling, and active/inactive toggling.

✏️ Tip: You can customize this high-level summary in your review settings.

…a + active newton-physics#1192

Signed-off-by: Viktor Reutskyy <vreutskyy@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds per-constraint equality data and active-state propagation from Newton models into MuJoCo Warp via a new combined kernel and solver wiring, expands the equality-constraint flag docstring, and adds multi-world tests for eq_data and eq_active updates.

Changes

Cohort / File(s) Summary
Flag documentation
newton/_src/solvers/flags.py
Expanded EQUALITY_CONSTRAINT_PROPERTIES docstring to list additional attributes: equality_constraint_anchor, equality_constraint_relpose, equality_constraint_polycoef, equality_constraint_torquescale, equality_constraint_enabled, and custom mujoco.eq_solref, mujoco.eq_solimp.
Kernel implementation
newton/_src/solvers/mujoco/kernels.py
Added import of EqType, new vector alias vec11, and the update_eq_data_and_active_kernel kernel. Kernel maps Newton equality constraint fields (type, anchor, relpose, polycoef, torquescale, enabled) into per-constraint MuJoCo storage (eq_data as vec11 and eq_active). Handles type-specific layouts and relpose quaternion ordering.
Solver integration
newton/_src/solvers/mujoco/solver_mujoco.py
Imported the new kernel, added eq_data to expand_model_fields, and updated update_eq_properties to launch update_eq_data_and_active_kernel to populate eq_data and eq_active across worlds.
Tests
newton/tests/test_mujoco_solver.py
Added test_eq_data_conversion_and_update and test_eq_active_conversion_and_update to validate per-world/per-equation propagation and runtime updates for eq_data and eq_active from Newton attributes.

Sequence Diagram(s)

sequenceDiagram
    participant Newton as Newton Model
    participant Solver as SolverMuJoCo
    participant Kernel as update_eq_data_and_active_kernel
    participant MuJoCo as MuJoCo Warp

    Newton->>Solver: notify equality_constraint_* updates
    Solver->>Kernel: launch with mjc_eq_to_newton_eq, types, anchors, relposes, polycoef, torquescale, enabled
    Kernel->>Kernel: map by EqType (CONNECT/JOINT/WELD), pack vec11, set active
    Kernel->>MuJoCo: write eq_data[world, mjc_eq] and eq_active[world, mjc_eq]
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • adenzler-nvidia
  • eric-heiden
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: implementing randomization and runtime updates for equality constraint data and active flags.
Linked Issues check ✅ Passed The PR successfully implements all primary coding objectives from issue #1192: propagates Newton equality constraint properties to MuJoCo eq_data, enables runtime updates for CONNECT/JOINT/WELD types, synchronizes equality_constraint_enabled with eq_active, supports multi-world scenarios, and includes comprehensive tests.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the equality constraint data and active flag functionality from issue #1192; no out-of-scope modifications were introduced.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jan 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Signed-off-by: Viktor Reutskyy <vreutskyy@nvidia.com>

Copilot AI 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.

Pull request overview

This PR implements runtime update and randomization support for equality constraint data (eq_data) and active state (eq_active) in the MuJoCo solver.

Changes:

  • Added two new Warp kernels (update_eq_data_kernel and update_eq_active_kernel) to synchronize Newton's equality constraint properties with MuJoCo's internal data structures
  • Extended update_eq_properties() to launch the new kernels when SolverNotifyFlags.EQUALITY_CONSTRAINT_PROPERTIES is set
  • Enabled "eq_data" in model_fields_to_expand for multi-world support

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
newton/_src/solvers/flags.py Updated EQUALITY_CONSTRAINT_PROPERTIES docstring to document all related fields
newton/_src/solvers/mujoco/kernels.py Added update_eq_data_kernel and update_eq_active_kernel to sync equality constraint data
newton/_src/solvers/mujoco/solver_mujoco.py Extended update_eq_properties to call new kernels and enabled eq_data field expansion
newton/tests/test_mujoco_solver.py Added tests for eq_data and eq_active conversion and runtime updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread newton/tests/test_mujoco_solver.py
Comment thread newton/tests/test_mujoco_solver.py
Comment thread newton/tests/test_mujoco_solver.py

@adenzler-nvidia adenzler-nvidia 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.

Thanks, 1 comment and can you check whether the copilot suggestions for the tests make any sense?

Comment thread newton/_src/solvers/mujoco/kernels.py
vreutskyy and others added 2 commits January 22, 2026 10:06
Signed-off-by: Viktor Reutskyy <vreutskyy@nvidia.com>

@adenzler-nvidia adenzler-nvidia 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.

Thank you!

@adenzler-nvidia adenzler-nvidia added this pull request to the merge queue Jan 22, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 22, 2026
@vreutskyy vreutskyy added this pull request to the merge queue Jan 22, 2026
Merged via the queue into newton-physics:main with commit aefb337 Jan 22, 2026
22 checks passed
jnskkmhr pushed a commit to jnskkmhr/newton that referenced this pull request Jan 22, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jan 27, 2026
4 tasks
eric-heiden pushed a commit to eric-heiden/newton that referenced this pull request Jan 28, 2026
mmacklin pushed a commit to mmacklin/newton that referenced this pull request Apr 7, 2026
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.

Implement randomization and runtime update of equality constraint data + active

3 participants