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 Passive

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

Overview

Passive force computation for MJX, applying joint-level spring and damping forces, gravity compensation, and fluid drag to the simulation.

Description

This module computes all passive (non-actuated) forces in the simulation. _spring_damper() applies joint-level spring forces (pulling toward a reference position) and damping forces (proportional to velocity) for all joint types (free, ball, slide, hinge). _gravcomp() applies gravity compensation forces for bodies with the gravcomp flag set. _fluid() computes fluid drag forces based on the model's fluid parameters. The main entry point passive() aggregates all passive force contributions and also adds tendon-level spring and damping forces into qfrc_passive on the Data object.

Usage

Called during mjx.step() after kinematics and before the constraint solver. The resulting qfrc_passive is combined with actuator forces and applied forces to compute the total generalized force.

Code Reference

Source Location

Key Functions

def _spring_damper(m: Model, d: Data) -> jax.Array
def _gravcomp(m: Model, d: Data) -> jax.Array
def _fluid(m: Model, d: Data) -> jax.Array
def passive(m: Model, d: Data) -> Data
def _inertia_box_fluid_model(m: Model, ...) -> Tuple

Import

from mujoco.mjx._src.passive import passive

I/O Contract

Inputs

Name Type Required Description
m mjx.Model Yes JAX model with joint stiffness, damping, gravity, and fluid parameters
d mjx.Data Yes JAX simulation data with qpos, qvel, and body transforms

Outputs

Name Type Description
d mjx.Data Updated data with populated qfrc_passive array (nv,)

Related Pages

Page Connections

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