Skip to content

Fix MJCF joint springdamper import - #3736

Open
han-xudong wants to merge 1 commit into
newton-physics:mainfrom
han-xudong:fix/mjcf-joint-springdamper
Open

Fix MJCF joint springdamper import#3736
han-xudong wants to merge 1 commit into
newton-physics:mainfrom
han-xudong:fix/mjcf-joint-springdamper

Conversation

@han-xudong

@han-xudong han-xudong commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Description

Preserve MJCF joint springdamper parameters and forward them to MjSpec, so MuJoCo can derive passive stiffness and damping from effective joint inertia during compilation. The compiled values are also retained when Newton synchronizes mutable joint properties to MJWarp.

Closes #3735

Checklist

  • New or existing tests cover these changes
  • The documentation is up to date with these changes
  • CHANGELOG.md has been updated (if user-facing change)

Test plan

uv run --extra dev -m newton.tests -k test_joint_springdamper_matches_native_mujoco
uvx pre-commit run -a

Bug fix

Steps to reproduce:

  1. Import an MJCF hinge with springdamper="0.2 1.5" and a massive child body.
  2. Construct SolverMuJoCo and inspect the compiled joint stiffness and DOF damping.
  3. Observe that both values were zero instead of the effective-inertia-dependent values produced by native MuJoCo.

Minimal reproduction:

See #3735.

Summary by CodeRabbit

  • Bug Fixes

    • Preserved MJCF joint springdamper settings when importing models.
    • Prevented imported spring-damper values from being overridden by default damping or stiffness synchronization.
    • Applied spring-damper settings consistently to ball, linear, and angular joints.
  • Tests

    • Added coverage verifying imported spring-damper values match native MuJoCo behavior.

Preserve authored springdamper parameters until MuJoCo compiles the\neffective-inertia-dependent stiffness and damping. Keep those compiled\nvalues when Newton synchronizes mutable joint properties to MJWarp.
@han-xudong
han-xudong requested a deployment to external-pr-approval July 31, 2026 06:32 — with GitHub Actions Waiting
@han-xudong
han-xudong requested a deployment to external-pr-approval July 31, 2026 06:32 — with GitHub Actions Waiting
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f09b779-e052-4e4a-a2de-ed70707e6c1d

📥 Commits

Reviewing files that changed from the base of the PR and between 0f97d2a and bad4455.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • newton/_src/solvers/mujoco/kernels.py
  • newton/_src/solvers/mujoco/solver_mujoco.py
  • newton/tests/test_import_mjcf.py
👮 Files not reviewed due to content moderation or server errors (4)
  • newton/_src/solvers/mujoco/solver_mujoco.py
  • newton/_src/solvers/mujoco/kernels.py
  • newton/tests/test_import_mjcf.py
  • CHANGELOG.md

📝 Walkthrough

Walkthrough

The MJCF importer now preserves joint springdamper values, forwards them to MuJoCo joint creation, and retains compiled stiffness and damping during runtime updates. A regression test compares Newton and native MuJoCo results.

Changes

MJCF springdamper import

Layer / File(s) Summary
Import metadata and joint creation
newton/_src/solvers/mujoco/solver_mujoco.py
Adds the dof_springdamper attribute, loads MJCF values, and applies nonzero values to ball, linear, and angular joints.
Runtime property synchronization
newton/_src/solvers/mujoco/solver_mujoco.py, newton/_src/solvers/mujoco/kernels.py
Passes springdamper data to property kernels. Compiled springdamper values prevent overwriting MuJoCo damping and stiffness.
Regression validation and changelog
newton/tests/test_import_mjcf.py, CHANGELOG.md
Compares imported values with native MuJoCo and documents the fix.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ModelBuilder
  participant SolverMuJoCo
  participant MuJoCoMjSpec as MuJoCo MjSpec
  ModelBuilder->>SolverMuJoCo: load dof_springdamper metadata
  SolverMuJoCo->>MuJoCoMjSpec: apply springdamper to joint creation
  MuJoCoMjSpec-->>SolverMuJoCo: compile joint stiffness and damping
Loading

Possibly related PRs

Suggested reviewers: adenzler-nvidia

🚥 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 title clearly describes the primary change: fixing MJCF joint springdamper import.
Linked Issues check ✅ Passed The changes preserve springdamper values, forward them to MuJoCo, retain compiled values, and add regression coverage for issue #3735.
Out of Scope Changes check ✅ Passed All changes support the linked issue by updating import, synchronization, documentation, and regression coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

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

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.

[BUG] MJCF importer ignores joint springdamper

1 participant