Implementation:Google deepmind Mujoco MJWarp Collision Driver
| Knowledge Sources | |
|---|---|
| Domains | Physics_Simulation, GPU_Computing, NVIDIA_Warp |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
MJWarp Collision Driver orchestrates the full collision detection pipeline, dispatching broadphase and narrowphase stages for all geometry pair types.
Description
This module is the top-level collision driver that manages the complete collision detection pipeline. It defines the MJ_COLLISION_TABLE mapping geometry type pairs to collision algorithms (PRIMITIVE, CONVEX, or SDF), implements two broadphase strategies (N-by-N and Sweep-and-Prune with tile or segmented sort), and dispatches to the appropriate narrowphase routines. The module includes AABB and OBB filtering, broadphase pair generation, and collision context management.
Usage
Called each simulation step via collision(m, d) to detect all contacts between geometry pairs. The broadphase filters candidate pairs, and the narrowphase computes precise contact points for constraint generation.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: mjx/mujoco/mjx/third_party/mujoco_warp/_src/collision_driver.py
- Lines: 1-790
Key Functions
# Primary entry point for full collision pipeline
def collision(m: Model, d: Data)
# Broadphase strategies
def sap_broadphase(m: Model, d: Data, ctx: CollisionContext)
def nxn_broadphase(m: Model, d: Data, ctx: CollisionContext)
# Collision context factory
def create_collision_context(naconmax: int) -> CollisionContext
# Internal broadphase filters
def _plane_filter(...)
def _sphere_filter(size1, size2, margin1, margin2, xpos1, xpos2) -> bool
def _aabb_filter(...)
def _obb_filter(...)
def _broadphase_filter(opt_broadphase_filter, ngeom_aabb, ngeom_rbound, ngeom_margin)
Import
from mujoco.mjx.third_party.mujoco_warp._src.collision_driver import collision
from mujoco.mjx.third_party.mujoco_warp._src.collision_driver import sap_broadphase
from mujoco.mjx.third_party.mujoco_warp._src.collision_driver import nxn_broadphase
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| m | Model | Yes | Warp model with geometry data, broadphase settings, and collision table |
| d | Data | Yes | Warp simulation data with current geom positions and orientations |
| ctx | CollisionContext | No | Pre-allocated collision context (created internally if not provided) |
Outputs
| Name | Type | Description |
|---|---|---|
| d.contact | Contact | Generated contacts with positions, normals, depths, and friction |
| d.nacon | wp.array | Number of active contacts per world |
| d.ncollision | wp.array | Number of collision pairs detected |