mj_step every physics frame. This is the primary hook for writing control logic.
Signature
Usage
Setting Actuator Controls
Applying Forces
PD Controller
Execution Order
Composability
MultipleuseBeforePhysicsStep hooks compose correctly. Each callback adds to the simulation state rather than overwriting:
qfrc_applied at the start, you should add to it (not assign).
Notes
- The callback receives the same model/data objects that
mj_stepwill use - If using IK (via
IkGizmo), your before-step runs first, then IK may overwritectrl. Disable IK withapi.setIkEnabled(false)when writing your own control. - The callback is called at physics rate, not render rate. Multiple physics steps may run per render frame.