Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Mujoco MJX Collision Convex

From Leeroopedia
Knowledge Sources
Domains Physics_Simulation, JAX, Collision_Detection
Last Updated 2026-02-15 04:00 GMT

Overview

JAX-based convex collision detection functions for MJX, implementing contact resolution between convex geom shapes including boxes, spheres, capsules, meshes, and height fields.

Description

This module provides the core convex collision algorithms used by MJX's collision pipeline. It implements the GJK/SAT-based approach for convex-convex intersections, manifold generation for box-box contacts, and specialized routines for plane-convex, sphere-convex, and capsule-convex pairs. Height field collision is also supported via subgrid decomposition into convex prisms. All functions are designed to be JAX-compatible and differentiable, operating on vectorized geom data.

Usage

These collision functions are called by the collision driver (collision_driver.py) during the contact detection phase of mjx.step(). The collider decorator wraps each function so that it can be dispatched by geom type and vmapped over geom pairs.

Code Reference

Source Location

Key Functions

def collider(ncon: int)
def plane_convex(plane: GeomInfo, convex: ConvexInfo) -> Collision
def sphere_convex(sphere: GeomInfo, convex: ConvexInfo) -> Collision
def capsule_convex(cap: GeomInfo, convex: ConvexInfo) -> Collision
def box_box(b1: ConvexInfo, b2: ConvexInfo) -> Collision
def convex_convex(c1: ConvexInfo, c2: ConvexInfo) -> Collision
def hfield_sphere(hfield: HFieldInfo, sphere: GeomInfo, ...) -> Collision
def hfield_capsule(hfield: HFieldInfo, cap: GeomInfo, ...) -> Collision
def hfield_convex(hfield: HFieldInfo, convex: ConvexInfo, ...) -> Collision

Import

from mujoco.mjx._src.collision_convex import plane_convex
from mujoco.mjx._src.collision_convex import convex_convex
from mujoco.mjx._src.collision_convex import box_box

I/O Contract

Inputs

Name Type Required Description
m mjx.Model Yes JAX model (used in collider wrapper)
d mjx.Data Yes JAX simulation data with geom positions/orientations
plane / sphere / cap / convex GeomInfo / ConvexInfo Yes Geom shape info including position, rotation matrix, and size
key FunctionKey Yes Collision function key specifying geom types and data IDs
geom jax.Array Yes Array of geom index pairs to check for collision

Outputs

Name Type Description
dist jax.Array Penetration distance (negative means overlap)
pos jax.Array Contact point position (midpoint between geoms)
frame jax.Array Contact frame (3x3); normal in row 0, tangents in rows 1-2

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment