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 MJWarp Constraint

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

Overview

MJWarp Constraint constructs the constraint Jacobian and constraint parameters from contacts, limits, and equalities for the GPU solver.

Description

This module generates all constraint rows (equality, friction, limit, and contact constraints) needed by the solver. It computes constraint Jacobians, reference accelerations, impedance parameters, and constraint bounds for each constraint type. The module handles equality constraints (connect, weld, joint, tendon, flex), joint friction, joint limits (slide, hinge, ball), tendon limits, and contact constraints in both pyramidal and elliptic friction cone formulations.

Usage

Called each simulation step via make_constraint after collision detection has generated contacts and before the solver runs. Populates the effective constraint (efc) arrays in Data.

Code Reference

Source Location

Key Functions

# Primary entry point
def make_constraint(m: Model, d: Data)

# Constraint row construction kernels
def _zero_constraint_counts(ne_out, nf_out, nl_out, nefc_out)
def _update_efc_row(worldid, timestep, refsafe, efcid, pos_aref, ...)

# Equality constraints
def _efc_equality_connect(...)
def _efc_equality_joint(...)
def _efc_equality_tendon(...)
def _efc_equality_flex(...)
def _efc_equality_weld(...)

# Friction and limit constraints
def _efc_friction_dof(...)
def _efc_friction_tendon(...)
def _efc_limit_slide_hinge(...)
def _efc_limit_ball(...)
def _efc_limit_tendon(...)

# Contact constraints
def _efc_contact_pyramidal(...)
def _efc_contact_elliptic(...)

Import

from mujoco.mjx.third_party.mujoco_warp._src.constraint import make_constraint

I/O Contract

Inputs

Name Type Required Description
m Model Yes Warp model with joint, tendon, equality, and solver parameters
d Data Yes Warp simulation data with contacts, positions, and velocities

Outputs

Name Type Description
d.efc.J wp.array3d Constraint Jacobian matrix
d.efc.type wp.array2d Constraint type per row
d.efc.pos wp.array2d Constraint position error
d.efc.aref wp.array2d Reference acceleration
d.efc.D wp.array2d Constraint impedance
d.ne wp.array Number of equality constraints
d.nf wp.array Number of friction constraints
d.nl wp.array Number of limit constraints
d.nefc wp.array Total number of effective constraints

Related Pages

Page Connections

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