Skip to content

Add MuJoCo per-collider configuration - #6706

Merged
kellyguo11 merged 2 commits into
isaac-sim:developfrom
kellyguo11:kellyguo11/mujoco-collision-cfg
Jul 24, 2026
Merged

kellyguo11 merged 2 commits into
isaac-sim:developfrom
kellyguo11:kellyguo11/mujoco-collision-cfg

Conversation

@kellyguo11

Copy link
Copy Markdown
Contributor

Description

Adds a public MujocoCollisionCfg schema fragment for the per-collider custom attributes registered by Newton's MuJoCo solver: condim, group, priority, solimp, solmix, and solref.

The custom applier writes scalar values under mjc:* and writes solimp/solref as canonical USD double[] arrays matching Newton's importer output. The PhysX-to-MJWarp migration guide and asset-preparation skill now use this config instead of defining a task-local collision fragment, document the other supported per-collider fields, and route margin/gap and mesh-cooking settings to the existing Newton configs.

Follow-up to #6684.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Documentation update

Testing

  • isaaclab.bat -p -m pytest source/isaaclab/test/sim/test_collision_fragments.py -q (15 passed)
  • uv run --no-project python tools/skills/cli.py check (19 skills validated)
  • Warning-as-error Sphinx dummy build for the changed API and migration pages (passed)
  • uv run isaaclab -f (passed before commit, before push, and after rebasing onto current develop)

Screenshots

Not applicable.

Checklist

  • I have read and understood the contribution guidelines
  • 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 added a changelog fragment under source/<pkg>/changelog.d/ for every touched package
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

Expose MJWarp's per-collider contact parameters through a typed schema fragment and canonical USD array authoring. Replace the task-local condim workaround in the migration guide and asset-preparation skill.
@github-actions github-actions Bot added documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team labels Jul 24, 2026
Mark the test-only Isaac Lab package change as requiring no release entry so the changelog gate recognizes every touched package.
@kellyguo11
kellyguo11 marked this pull request as ready for review July 24, 2026 06:46
@kellyguo11
kellyguo11 requested a review from a team July 24, 2026 06:46
@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces MujocoCollisionCfg, a public CollisionFragment subclass that authors Newton's MJWarp per-collider mjc:* attributes (condim, group, priority, solimp, solmix, solref) via a custom apply_mujoco_collision applier, replacing a task-local fragment used in the migration guide and asset-preparation skill.

  • apply_mujoco_collision validates scalar fields upfront, writes them via safe_set_attribute_on_usd_prim, and writes the fixed-length solimp/solref arrays as canonical USD double[] arrays via change_prim_property, matching Newton's importer output format.
  • Four new tests cover namespace writes, none-field guards, parametrized invalid-value rejection, and multi-namespace composition.
  • Documentation and skill files are updated consistently to use MujocoCollisionCfg instead of the inline fragment and to document routing of margin/gap/mesh-cooking settings to existing Newton configs.

Confidence Score: 4/5

Safe to merge. The new applier is additive, well-tested, and follows existing codebase patterns closely.

The implementation is clean and the two findings are minor inconsistencies in the applier's return-value contract and validation order — neither affects correctness under normal usage. All validations do fire before Newton reads the attributes, tests pass, and the documentation update is accurate.

schemas.py — the scalar-write result and the mid-loop length-check ordering are worth a second look.

Important Files Changed

Filename Overview
source/isaaclab_newton/isaaclab_newton/sim/schemas/schemas.py Adds apply_mujoco_collision: scalar writes succeed silently (return value dropped), array-length validation fires mid-loop allowing partial writes on error.
source/isaaclab_newton/isaaclab_newton/sim/schemas/schemas_cfg.py Adds MujocoCollisionCfg(CollisionFragment) with condim/group/priority/solimp/solmix/solref fields; clean implementation with proper ClassVar markers and custom func override.
source/isaaclab/test/sim/test_collision_fragments.py Adds 4 new tests: namespace write, none-field guard, parametrized validation rejects, and multi-namespace compose; good coverage of the new applier.
source/isaaclab_newton/isaaclab_newton/sim/schemas/init.pyi Correctly exposes MujocoCollisionCfg and apply_mujoco_collision in all and imports.
docs/source/overview/core-concepts/physical-backends/newton/migrating-assets-from-physx-to-newton.rst Replaces task-local MujocoCondimCfg fragment with MujocoCollisionCfg and adds a reference table covering all exposed per-collider fields with routing guidance.
skills/user/prepare-assets-for-newton/SKILL.md Updates MujocoPropertiesCfg references to the broader MujocoCfg pattern and documents priority/solmix/solref/solimp as expert overrides.
skills/user/prepare-assets-for-newton/reference.md Adds MujocoCollisionCfg to the MJWarp-specific row and updates the copy-ready code guidance to use the new class.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["apply_collision_properties(prim_path, [fragments], stage)"] --> B{Fragment type?}
    B -->|MujocoCollisionCfg| C["apply_mujoco_collision(cfg, prim_path, stage)"]
    B -->|Other fragments| D["apply_namespaced / other dispatch"]
    C --> E{prim.IsValid?}
    E -->|No| F["raise ValueError"]
    E -->|Yes| G["Validate scalars upfront\ncondim ∈ {1,3,4,6}\ngroup ∈ [0,5]\npriority ≥ 0\nsolmix ≥ 0"]
    G -->|Invalid| F
    G -->|Valid| H["Write scalars via safe_set_attribute_on_usd_prim\nmjc:condim, mjc:group, mjc:priority, mjc:solmix"]
    H --> I["For solimp, solref in loop:"]
    I --> J{len == expected?}
    J -->|No| F
    J -->|Yes| K["Write Vt.DoubleArray via change_prim_property\nmjc:solimp as double[5]\nmjc:solref as double[2]"]
    K --> L["return success"]
Loading

Reviews (1): Last reviewed commit: "Add Isaac Lab changelog fragment" | Re-trigger Greptile

Comment on lines +62 to +66
success = True
for attr_name in ("condim", "group", "priority", "solmix"):
value = getattr(cfg, attr_name)
if value is not None:
safe_set_attribute_on_usd_prim(prim, f"mjc:{attr_name}", value, camel_case=False)

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 Scalar write results not tracked in success

The return value of safe_set_attribute_on_usd_prim is silently dropped for all four scalar fields (condim, group, priority, solmix), while the array paths use change_prim_property whose result is correctly accumulated via and. The docstring promises True if all authored attributes were written successfully, but a silent failure on a scalar write would still return True (or whatever the array writes produce). The inconsistency means callers that gate on the return value can't rely on it to detect partial failures on the scalar path.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +68 to +83
for attr_name, expected_length in (("solimp", 5), ("solref", 2)):
value = getattr(cfg, attr_name)
if value is None:
continue
if len(value) != expected_length:
raise ValueError(f"'{attr_name}' must contain exactly {expected_length} values. Received: {len(value)}.")
success = (
change_prim_property(
prop_path=f"{prim.GetPath()}.mjc:{attr_name}",
value=Vt.DoubleArray(value),
stage=stage,
type_to_create_if_not_exist=Sdf.ValueTypeNames.DoubleArray,
)
and success
)
return success

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 Array-length check fires mid-loop, allowing partial writes before ValueError

All scalar validations (condim, group, priority, solmix) run upfront and scalar attributes are fully written before the array loop begins. The length check for solimp/solref is then performed lazily inside the write loop. If both fields are provided and only solref has the wrong length, solimp is written to the prim and then the ValueError is raised — leaving the prim in a partially-authored state. Callers that catch the error and retry with a corrected solref would find the prim already has the solimp attribute, which may or may not be the desired behavior. Pre-validating all array lengths upfront (alongside the scalar checks) would prevent this.

@kellyguo11
kellyguo11 merged commit 855646d into isaac-sim:develop Jul 24, 2026
43 checks passed
matthewtrepte pushed a commit to matthewtrepte/IsaacLab that referenced this pull request Aug 4, 2026
# Description

Adds a public `MujocoCollisionCfg` schema fragment for the per-collider
custom attributes registered by Newton's MuJoCo solver: `condim`,
`group`, `priority`, `solimp`, `solmix`, and `solref`.

The custom applier writes scalar values under `mjc:*` and writes
`solimp`/`solref` as canonical USD `double[]` arrays matching Newton's
importer output. The PhysX-to-MJWarp migration guide and
asset-preparation skill now use this config instead of defining a
task-local collision fragment, document the other supported per-collider
fields, and route margin/gap and mesh-cooking settings to the existing
Newton configs.

Follow-up to isaac-sim#6684.

## Type of change

- New feature (non-breaking change which adds functionality)
- Documentation update

## Testing

- `isaaclab.bat -p -m pytest
source/isaaclab/test/sim/test_collision_fragments.py -q` (15 passed)
- `uv run --no-project python tools/skills/cli.py check` (19 skills
validated)
- Warning-as-error Sphinx dummy build for the changed API and migration
pages (passed)
- `uv run isaaclab -f` (passed before commit, before push, and after
rebasing onto current `develop`)

## Screenshots

Not applicable.

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants