Implementation:Google deepmind Mujoco Engine Inverse
| Knowledge Sources | |
|---|---|
| Domains | Physics Simulation, Inverse Dynamics, Rigid Body Dynamics |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Implements inverse dynamics computations that recover the forces required to produce a given motion trajectory.
Description
engine_inverse.c provides the inverse dynamics pipeline for MuJoCo, computing the generalized forces (qfrc_inverse) needed to produce observed accelerations. The pipeline mirrors the forward dynamics stages: position-dependent computations (kinematics, mass matrix, collision, constraints, transmission), velocity-dependent computations, and constraint force computation. It also handles conversion between discrete-time and continuous-time accelerations for different integrators (Euler, implicit, implicitfast) and provides a comparison function between forward and inverse dynamics results.
Usage
Invoked via mj_inverse() to perform full inverse dynamics, or via the individual stage functions (mj_invPosition, mj_invVelocity, mj_invConstraint) for selective computation. Called when the user needs to determine forces from observed motion.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/engine/engine_inverse.c
- Lines: 1-302
Key Functions
// position-dependent computations
void mj_invPosition(const mjModel* m, mjData* d);
// velocity-dependent computations
void mj_invVelocity(const mjModel* m, mjData* d);
// convert discrete-time qacc to continuous-time qacc
static void mj_discreteAcc(const mjModel* m, mjData* d);
// constraint force computation for inverse dynamics
void mj_invConstraint(const mjModel* m, mjData* d);
// inverse dynamics with skip options
void mj_inverseSkip(const mjModel* m, mjData* d,
int skipstage, int skipsensor);
// full inverse dynamics pipeline
void mj_inverse(const mjModel* m, mjData* d);
// compare forward and inverse dynamics results
void mj_compareFwdInv(const mjModel* m, mjData* d);
Import
#include "engine/engine_inverse.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| m | const mjModel* | Yes | Physics model specification |
| d | mjData* | Yes | Simulation state with qpos, qvel, qacc set |
| skipstage | int | No | Computation stage to skip (for mj_inverseSkip) |
| skipsensor | int | No | Whether to skip sensor computation (for mj_inverseSkip) |
Outputs
| Name | Type | Description |
|---|---|---|
| d->qfrc_inverse | mjtNum* | Generalized inverse dynamics forces in joint space |
| d->efc_force | mjtNum* | Constraint forces computed during inverse dynamics |
| d->fwdinv | mjtNum[2] | Forward-inverse comparison norms (position, velocity) |