Skip to content

Fix Newton USD import dropping mjc joint attributes - #7386

Closed
AntoineRichard wants to merge 2 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/fix-newton-mjc-frictionloss
Closed

AntoineRichard wants to merge 2 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/fix-newton-mjc-frictionloss

Conversation

@AntoineRichard

@AntoineRichard AntoineRichard commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes #6829.

Joint Coulomb friction authored on a USD as mjc:frictionloss never reached the Newton solver: Isaac Lab's add_usd calls passed schema_resolvers=[SchemaResolverNewton(), SchemaResolverPhysx()], so mjc:* attributes were dropped and Model.joint_friction stayed 0.0 even though the same asset loads correctly through Newton core's Mjc resolver.

This adds SchemaResolverMjc to the schema-resolver list on the two paths that build the live physics model:

  • isaaclab_newton/physics/newton_manager.py (main stage import)
  • isaaclab_newton/cloner/replicate.py (clone-plan build path)

The visualization builder and the core ordering-resolver emulation are deliberately left untouched: schema resolvers only control which attributes are parsed, so they cannot affect rendering or joint ordering, and keeping them out makes the change minimal.

Safety: SchemaResolverMjc populates the core Model.joint_friction field and is a no-op-safe addition when a solver has not registered MuJoCo custom attributes (verified with a no-registration import), so the change is unconditional rather than MJWarp-gated.

Adds a kitless regression test in test_newton_manager_abstraction.py that authors a revolute joint with mjc:frictionloss=0.11 and asserts the value reaches Model.joint_friction through NewtonManager.instantiate_builder_from_stage() — it fails without this change and passes with it.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • test_newton_manager_abstraction.py::test_usd_mjc_frictionloss_reaches_newton_model — new regression (fails on develop, passes here); full file 162 passed
  • source/isaaclab/test/assets/test_articulation_ordering.py — 63 passed (untouched by this PR)

Checklist

  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@AntoineRichard
AntoineRichard requested a review from a team August 27, 2026 16:02
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Aug 27, 2026
@greptile-apps

greptile-apps Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR consistently adds the MuJoCo USD schema resolver to Newton's main import, replication, visualization, and articulation-ordering paths so authored mjc:* joint properties reach the Newton model.

  • Adds SchemaResolverMjc after the existing Newton and PhysX resolvers at all four coordinated builder paths.
  • Adds a regression test for importing mjc:frictionloss.
  • Updates ordering-test mocks and changelog fragments.

Confidence Score: 4/5

The implementation appears safe to merge, with one non-blocking test-portability issue caused by fixing the regression test to cuda:0.

The resolver lists remain aligned across the relevant Newton builder paths and the new regression covers the intended import behavior; only the test's hard-coded device can make it fail on otherwise supported test hosts or shards.

Files Needing Attention: source/isaaclab_newton/test/sim/test_mjc_usd_import.py

Important Files Changed

Filename Overview
source/isaaclab_newton/isaaclab_newton/physics/newton_manager.py Adds the MJC resolver to the primary USD-to-Newton model import path in the same order used by the coordinated paths.
source/isaaclab_newton/isaaclab_newton/cloner/replicate.py Preserves MJC-authored properties while building replicated Newton worlds.
source/isaaclab_newton/isaaclab_newton/physics/visualization_builder.py Keeps visualization-only model construction aligned with the primary resolver list.
source/isaaclab/isaaclab/assets/articulation/ordering_resolvers.py Keeps MJWarp ordering emulation aligned with the live Newton import path.
source/isaaclab_newton/test/sim/test_mjc_usd_import.py Adds effective friction-import coverage, but hard-codes cuda:0 instead of honoring the repository's test-device selection.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[USD stage with mjc attributes] --> B[Newton / PhysX / MJC schema resolvers]
  B --> C[Newton ModelBuilder]
  C --> D[Cloned simulation worlds]
  C --> E[Visualization builder]
  C --> F[Articulation ordering emulation]
  C --> G[Final Newton model joint friction]
Loading

Reviews (1): Last reviewed commit: "Fix Newton USD import dropping mjc joint..." | Re-trigger Greptile

"""A USD joint authored with ``mjc:frictionloss`` yields a matching ``joint_friction``."""
sim_cfg = SimulationCfg(
dt=0.005,
device="cuda:0",

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.

P2 Hard-coded CUDA test device

The regression test bypasses the repository's ISAACLAB_TEST_DEVICES-based selection by fixing SimulationCfg.device to cuda:0. On a CPU-only host or a shard assigned another GPU, initialization fails independently of the resolver behavior; please parameterize this through the existing test-device utility.

@isaaclab-review-bot isaaclab-review-bot 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.

Isaac Lab Review Bot

The change appends SchemaResolverMjc to the Newton USD import paths used by stage loading, clone replication, visualization building, and articulation-ordering emulation, with a focused mjc:frictionloss regression test and package changelog fragments.

  • Design and architecture: The resolver ordering remains consistent across the four affected producer paths, preserving the documented lockstep relationship between live Newton imports and MJWarp ordering emulation. Existing joint and body ordering settings are unchanged.
  • API: No public signatures, defaults, exports, or return types change. The behavioral compatibility surface is limited to retaining USD-authored mjc:* attributes that were previously dropped during Newton import.
  • Implementation: The resolver list is updated wherever the relevant builders call add_usd, and the ordering-resolver mock is extended accordingly. The regression test exercises the manager import through Model.joint_friction; its explicit cuda:0 device remains a non-blocking portability tradeoff for CPU-only test environments.

No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.

Automated review; human maintainers own approval decisions.

@hujc7

hujc7 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Aug 27, 2026

@hujc7 hujc7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This might have wider effect as previously dropped attributes are now read in newton?

@NeoZng NeoZng mentioned this pull request Aug 28, 2026
8 tasks done
@NeoZng

NeoZng commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

i think it is better to patch mjc schema only for mjwarp manager?
check my pr #7298, hope it help

@kellyguo11

Copy link
Copy Markdown
Contributor

my agent also believes #7298 is a better fix.

kellyguo11 pushed a commit that referenced this pull request Sep 7, 2026
# Description

Fixes #6829.

Preserve MuJoCo-authored joint friction loss when Isaac Lab imports USD
stages for the Newton MJWarp backend.

Before this change, both Newton production import paths passed only
`SchemaResolverNewton` and `SchemaResolverPhysx` to Newton:

* vectorized clone replication; and
* standalone stage import.

Consequently, a joint authored with `mjc:frictionloss=0.11` finalized
with `Model.joint_friction=0.0`, even though Newton supports the
attribute through `SchemaResolverMjc`.

This PR makes USD resolver selection an active-manager policy:

* `NewtonManager` defaults to Newton then PhysX resolvers;
* `NewtonMJWarpManager` appends the MuJoCo resolver;
* clone and standalone imports consume the same manager-owned resolver
list; and
* resolver order remains Newton → PhysX → MuJoCo, so MJC values are
fallbacks and do not override higher-priority authored values.

MuJoCo custom attributes continue to be registered through the existing
`_builder_attribute_solvers = (SolverMuJoCo,)` mechanism. The follow-up
removes the redundant MJWarp registration override instead of
duplicating that base-class path.

## Scope and alternative considered

PR #7386 fixes the immediate `frictionloss` symptom by appending the
complete `SchemaResolverMjc` to every Newton physics import. That
resolver also interprets additional joint, shape, contact, and scene
attributes. Applying it unconditionally would therefore expand MJC
semantics to Featherstone, XPBD, VBD, Kamino, and MPM rather than
changing only MJWarp.

This PR intentionally keeps the immediate fix solver-scoped: the manager
that registers and consumes MuJoCo-specific attributes also owns the
MuJoCo resolver. Regression coverage verifies that MJWarp imports
`mjc:frictionloss` and `mjc:damping`, while Featherstone preserves its
previous behavior.

A broader cross-backend solution should separately classify portable MJC
core semantics from MuJoCo-specific extensions, ideally by splitting
those resolver responsibilities in Newton upstream. That larger
architecture change is outside the scope of this bug fix.

No dependency or public API is added.

## Type of change

* Bug fix (non-breaking change which fixes an issue)

## Release backport

* [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

## Screenshots

Not applicable; this fixes a non-visual USD import path.

## Verification

Latest follow-up commit:

* focused production-path regression matrix: 5 passed;

* MJWarp × clone/standalone preserves `frictionloss=0.11` and
`damping=0.23`;
* Featherstone × clone/standalone leaves both MJC-authored values
unconsumed;
  * the existing explicit-global clone import test still passes;
* full pre-commit suite passed;
* changelog validation passed;
* Python bytecode compilation passed; and
* `git diff --check` passed.

Previous PR head verification in the matching isolated environment:

* Python 3.12.13;
* `isaaclab-newton==5.4.0`;
* `newton==1.5.0`;
* `warp-lang==1.16.0`;
* `mujoco-warp==3.11.0`; and
* full Newton manager abstraction suite: 157 passed on a CUDA host.

## Checklist

* [x] I have read and understood the [[contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
* [x] I have run the pre-commit checks
* [x] I have made corresponding changes to the documentation (not
applicable: no public API or user workflow changed)
* [x] My changes generate no new warnings
* [x] I have added tests that prove my fix is effective
* [x] I have added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package
* [x] I have added my name to `CONTRIBUTORS.md`

---------

Co-authored-by: NeoZng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants