Implementation:Google deepmind Mujoco Engine Forward Header
| Knowledge Sources | |
|---|---|
| Domains | Physics Simulation, Forward Dynamics |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Header file declaring the top-level forward dynamics API and integration functions for the MuJoCo physics engine.
Description
This header declares the primary simulation stepping and forward dynamics interface. It includes the top-level mj_step function (single-step advancement with control callback), the two-phase stepping functions mj_step1 and mj_step2 (allowing external force injection between phases), mj_forward and mj_forwardSkip for forward dynamics computation with optional stage skipping, numerical integrators (Runge-Kutta, Euler semi-implicit, fully implicit), and the individual solver pipeline stages: mj_fwdKinematics, mj_fwdPosition, mj_fwdVelocity, mj_fwdActuation, mj_fwdAcceleration, and mj_fwdConstraint. State validation functions mj_checkPos, mj_checkVel, and mj_checkAcc are also declared for detecting and resetting invalid states.
Usage
Included by any code that needs to advance the simulation, compute forward dynamics, or invoke individual stages of the dynamics pipeline.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/engine/engine_forward.h
- Lines: 1-92
Key Functions
// State validation
MJAPI void mj_checkPos(const mjModel* m, mjData* d);
MJAPI void mj_checkVel(const mjModel* m, mjData* d);
MJAPI void mj_checkAcc(const mjModel* m, mjData* d);
// Top-level simulation stepping
MJAPI void mj_step(const mjModel* m, mjData* d);
MJAPI void mj_step1(const mjModel* m, mjData* d);
MJAPI void mj_step2(const mjModel* m, mjData* d);
MJAPI void mj_forward(const mjModel* m, mjData* d);
MJAPI void mj_forwardSkip(const mjModel* m, mjData* d, int skipstage, int skipsensor);
// Integrators
MJAPI void mj_RungeKutta(const mjModel* m, mjData* d, int N);
MJAPI void mj_Euler(const mjModel* m, mjData* d);
MJAPI void mj_implicit(const mjModel* m, mjData* d);
// Pipeline stages
MJAPI void mj_fwdKinematics(const mjModel* m, mjData* d);
MJAPI void mj_fwdPosition(const mjModel* m, mjData* d);
MJAPI void mj_fwdVelocity(const mjModel* m, mjData* d);
MJAPI void mj_fwdActuation(const mjModel* m, mjData* d);
MJAPI void mj_fwdAcceleration(const mjModel* m, mjData* d);
MJAPI void mj_fwdConstraint(const mjModel* m, mjData* d);
Import
#include "engine/engine_forward.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| m | const mjModel* | Yes | Model with physics parameters and structure |
| d | mjData* | Yes | Mutable simulation data (state, controls, forces) |
| skipstage | int | No | Pipeline stage to skip (mjtStage enum) |
| skipsensor | int | No | Flag to skip sensor computation |
| N | int | No | Order for Runge-Kutta integrator |
Outputs
| Name | Type | Description |
|---|---|---|
| d | mjData* | Updated simulation data with new state after stepping or forward computation |