saveState()
Capture a snapshot of the current simulation state.StateSnapshot
restoreState(snapshot)
Restore a previously saved state.StateSnapshot
required
Snapshot from a previous
saveState() call.setQpos(values)
Set all generalized positions.Float64Array | number[]
required
Array of length
model.nq.getQpos()
Get all generalized positions.Float64Array
setQvel(values)
Set all generalized velocities.Float64Array | number[]
required
Array of length
model.nv.getQvel()
Get all generalized velocities.Float64Array
applyKeyframe(nameOrIndex)
Apply a named or indexed keyframe from the model.string | number
required
Keyframe name or index. Keyframes are defined in MJCF with
<key> elements.getKeyframeNames()
Get all keyframe names.string[]
getKeyframeCount()
Get the number of keyframes.number
Example: Checkpoint System
mjSTATE_INTEGRATION vector: mocap poses, external
forces, solver warmstart, history, equality activation, and plugin state. Restore
requires the same loaded model; snapshots are in-memory objects, not portable
serialized assets. Legacy fields remain editable and are applied after the packed
state. Legacy snapshots without integration restore only their explicit fields.
MuJoCo’s experimental IPC flex contact retains additional private state, so exact
replay of IPC contact is unsupported.