Contact: Pair and Exclude Overview
MuJoCo’s contact system automatically detects collisions between geoms and generates contact constraints during simulation. While default behavior is fully automatic, MuJoCo also provides two explicit mechanisms to control contact relationships:
contact pair — explicitly enabling or customizing contact between specific geom pairs
contact exclude — disabling contact between selected bodies or geoms
This section explains the structural role of these two mechanisms and how they shape contact behavior within the simulation.
1. Contact Detection in MuJoCo
By default, MuJoCo detects contacts automatically using:
geom type
geom group
collision filtering rules
However, complex models often require more control—either to ensure specific contacts are always checked, or to disable unwanted contacts for performance or modeling accuracy. This is where pair and exclude come into play.
2. Contact Pair
A contact pair explicitly defines a contact relationship between two geoms.
Purpose
Override the default collision rules
Explicitly enable contact between a chosen pair of geoms
Apply special contact parameters (e.g., softness, friction) specifically to a pair
Ensure important contacts are always evaluated, even if groups or defaults would normally suppress them
Behavior
A contact pair instructs MuJoCo to check collision between two geoms, regardless of global collision filters.
Contact is evaluated only when the two geoms are close enough to potentially collide.
Pairs can be used to fine-tune physical interaction between specific parts of a robot or mechanism.
Use Cases
Robot gripper touching soft objects
Hand–object or foot–ground fine-grained contact tuning
Ensuring contact for mechanisms where default geom grouping hides collisions
Pair is a precise, positive specification: 👉 “These two geoms should interact, and optionally with customized settings.”
3. Contact Exclude
A contact exclude disables contact between two bodies (and all their child geoms).
Purpose
Improve performance by removing unnecessary collision checks
Avoid unrealistic self-collisions
Prevent collisions for mechanically connected bodies
Explicitly turn off contact for geoms that should never touch
Behavior
Excluding two bodies means none of the geoms belonging to either body will generate contacts with each other.
Exclusions operate at the body level, not per-geom.
Useful for simplifying computation in models with many linked parts.
Typical Scenarios
Links in a robot arm that are adjacent and connected by joints
Mechanical components that are designed to move together without touching
Eliminating noisy or undesirable contacts in complex soft-body or multi-geom assemblies
Exclude is a negative specification: 👉 “These two bodies should never generate contact.”
4. Relationship Between Pair and Exclude
pairworks at geom-level, enabling or customizing contact.excludeworks at body-level, disabling all contact.
If both apply:
Exclude dominates by preventing contact (body-level suppression).
A pair cannot force contact between bodies explicitly excluded.
Thus, exclusions serve as a broad filter, and pairs serve as fine-grained overrides only when exclusion does not apply.
5. Contact System Benefits
Using pair and exclude allows fine control over collision behavior:
Better performance by reducing unnecessary collision checks
More realistic physical interactions by customizing key contact relationships
Cleaner simulations without undesired or unstable self-collisions
The ability to structure contact behavior based on model design intention
6. Summary
MuJoCo’s contact system supports two powerful mechanisms for controlling collision behavior:
Pair — Explicitly enable or fine-tune contact between two geoms
Exclude — Disable all contact between two bodies
Together, they give model designers precise control over collision detection, enabling:
High-performance simulations
Accurate contact modeling
Cleaner and more stable robot and mechanism behavior
These mechanisms are essential for complex robotic models, articulated structures, and soft–rigid interaction scenarios.
Last updated