Skip to content

Preserve MuJoCo collision filtering semantics #3713

Description

@eric-heiden

Summary

Newton does not yet preserve the full collision-selection semantics of MJCF models.

For automatically generated contacts, MuJoCo accepts a geom pair when:

(contype_a & conaffinity_b) != 0 or (contype_b & conaffinity_a) != 0

Newton currently handles the special case where both values are zero by assigning collision_group=0, but other contype / conaffinity combinations are flattened into Newton's existing collision-group representation. This can introduce unintended contacts or remove required selective self-collisions.

Explicit MJCF <contact><pair> entries are a separate selection path: they intentionally bypass the automatic mask and parent-child filters, can retain otherwise zero-mask geoms, and can override contact parameters. Their import, selection, and parameter precedence must remain separate from automatic mask filtering.

The goal of this epic is to preserve MJCF collision behavior across Newton collision pipelines and SolverMuJoCo without regressing the existing collision-group API or replicated-model scalability.

Goals

  • Preserve exact automatic pair eligibility from MJCF contype / conaffinity masks.
  • Preserve explicit <pair> inclusion and contact-parameter overrides, including default-class inheritance.
  • Preserve <exclude>, same-body, parent-child, world-parent, and articulation self-collision semantics.
  • Define coherent composition between collision_group, mask filtering, and shape_collision_filter_pairs.
  • Avoid imposing a 32-group limit or another breaking restriction on existing Newton collision groups.
  • Preserve or intentionally define SolverMuJoCo mask export and round-trip behavior.
  • Keep model construction and collision-filter storage scalable across replicated worlds.
  • Validate semantic pair equivalence instead of relying only on raw geom_contype / geom_conaffinity array equality.

Workstreams

1. Automatic mask filtering

  • Decide whether exact type/affinity masks are a public API, an internal runtime representation, or importer-compiled data.
  • Rebase or rework Fix MJCF collision mask filtering #3104 on current main after the newer importer, broad-phase, filter-storage, and explicit-pair changes.
  • Preserve the existing unbounded collision-group behavior; do not lower every existing group into a fixed 32-bit allocation without a compatible fallback.
  • Define mixed-model behavior when MJCF masks interact with Newton-authored shapes, global shapes, multiple imported assets, and existing collision groups.
  • Apply the mask predicate only to automatically generated pairs; explicit included pairs must retain MuJoCo's bypass semantics.
  • Export exact authored masks through SolverMuJoCo where possible, while retaining graph-coloring or another equivalent path for Newton-native collision groups.

2. Explicit contact pairs

  • Resolve <pair> default classes before collecting endpoints or parameters.
  • Apply pair-specific condim, friction, margin/gap, solref, solreffriction, and solimp to Newton-generated contacts.
  • Force explicit MuJoCo pairs into Newton's collision pipeline even when automatic collision groups, masks, parent-child filters, or sparse exclusions reject them.
  • Avoid duplicate candidate generation and preserve pair-specific precedence across multiple worlds.

3. Correctness coverage

Add semantic pair-matrix comparisons against compiled MuJoCo for:

  • asymmetric mask acceptance, including the floor/two-sphere reproduction;
  • multiple mask bits and zero-mask geoms;
  • selective self-collision within one articulation;
  • same-body, parent-child, fixed/world-parent, and welded-body cases;
  • <exclude> and explicit <pair> precedence;
  • explicit-pair default inheritance and zero-mask endpoints;
  • Explicit, NxN, and SAP broad phases;
  • native MuJoCo contacts and Newton-generated contacts;
  • multiple worlds and replicated models;
  • Newton models using more than 32 collision groups.

Fix the menagerie comparison path so unordered geom fields can be checked when appropriate, and compare effective pair eligibility when raw mask values are intentionally regenerated.

4. Performance and storage

  • Benchmark sparse and dense MJCF mask patterns at representative geom and world counts.
  • Measure import time, finalization time, collision-pipeline construction, filter-pair counts, and peak host memory.
  • If masks are compiled into sparse exclusions, provide a compact representation and prove that dense incompatibility matrices do not recreate the filter-pair memory failure addressed by Only emit collision filters between colliding shapes #3574.
  • Finish removal of unreachable filters involving non-colliding USD shapes so all importer paths follow the same storage invariants.

Active issues

Active pull requests

Landed groundwork

Completion criteria

  • The eligible automatic and explicit geom-pair sets match compiled MuJoCo for the regression matrix.
  • All Newton broad-phase modes and both SolverMuJoCo contact-generation paths agree on selection and precedence.
  • Existing Newton collision-group behavior remains backward compatible.
  • Replicated-model benchmarks show bounded construction time and memory for both sparse and dense filtering patterns.
  • Related menagerie skips and open issues are narrowed or closed with behavior-level evidence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status
    Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions