Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:Google deepmind Mujoco MJX Derivative

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

Overview

Analytical derivative computation of smooth forces with respect to velocities, used by the implicit integrator for improved numerical stability.

Description

This module computes qDeriv, the analytical derivative of smooth (non-constraint) forces with respect to generalized velocities. It accounts for actuator velocity-dependent gains/biases (affine gain and affine bias models) and passive damping forces (joint-level and tendon-level damping). The derivative matrix is used by the implicitfast integrator in inverse.py to modify the effective mass matrix: M_eff = M - dt * qDeriv. Fluid drag derivatives are not yet implemented and will raise NotImplementedError if fluid parameters are present.

Usage

Called by inverse.discrete_acc() during the implicit fast integrator step within mjx.step(). Also used for implicit Euler integration where velocity-dependent force derivatives improve stability.

Code Reference

Source Location

Key Functions

def deriv_smooth_vel(m: Model, d: Data) -> Optional[jax.Array]

Import

from mujoco.mjx._src.derivative import deriv_smooth_vel

I/O Contract

Inputs

Name Type Required Description
m mjx.Model Yes JAX model with actuator parameters, dof_damping, tendon_damping
d mjx.Data Yes JAX simulation data with ctrl, act, and actuator_moment

Outputs

Name Type Description
qderiv jax.Array or None Derivative matrix d(qfrc_smooth)/d(qvel), shape (nv, nv); None if no velocity-dependent forces

Related Pages

Page Connections

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