TECHNOLOGY

After mj_step: MuJoCo state and derived observations can describe different boundaries

In this article
THE QUICK TAKE

A completed step advances integration state without automatically recomputing every derived field at that new state; exported observations need an explicit boundary.

One object does not imply one observation instant

A twin exporter calls mj_step, then stores qpos beside a position-dependent sensor reading and an end-effector Jacobian. The file writer gives the whole row the current simulation time. No network delay is involved, yet the row can combine different computation boundaries. The issue is the simulator’s imperative pipeline. Decide whether the dataset represents the transition just computed or an observation of the newly integrated state before assigning a common timestamp to every field.

Follow the final integration boundary

The MuJoCo computation reference explains that mj_step finishes by updating the integration state. Position-dependent fields computed earlier in the pipeline are not automatically refreshed afterward. Consequently, newly stored generalized positions and an already computed kinematic Jacobian need not describe the same configuration. The documentation explicitly calls out this consistency issue. A successful return from stepping establishes completion of that stepping operation, not automatic synchronization of every derived array at the new position.

Choose recomputation with known side effects

The function reference distinguishes mj_forward, which performs forward computations without integrating time, from mj_step. A sufficiently complete forward pass can refresh derived observations at the current state. It can also invoke an installed control callback, so this is not necessarily an inert read-only accessor for application-owned state. Select the required computation stage deliberately and account for callbacks. A position-only query and an acceleration-dependent sensor do not necessarily need the same work.

Propose a moving-state diagnostic

Use a small synthetic model whose selected body changes pose during a step. Record state and derived body pose immediately before the step, immediately afterward and after the chosen refresh. Retain simulation time at each boundary. Compare the body pose implied by the stored generalized positions with the derived pose, rather than relying on a static model where stale and current values coincide. This is a proposed diagnostic; no simulation benchmark or experiment is claimed here.

Make exported rows explain their boundary

Acceptance evidence should name the engine revision, integrator, selected arrays and observation convention. If transition forces are retained alongside a next-state observation, label their roles explicitly rather than pretending every field is instantaneous at the row time. Ensure any refresh occurs before the consumer copies the relevant arrays. A later refresh cannot retroactively change a previously copied sensor vector, and merely storing more decimal places does not repair a temporal mismatch.

Keep simulator consistency separate from physical fidelity

Correctly aligned simulator fields can still come from an inaccurate model. The Quest geometry guide addresses observation-time context in another setting; software reproducibility supports retaining pipeline configuration. For this interface, the claim is precise: exported fields refer to declared integration or computation boundaries in the examined version. It is not a claim that the simulated sensors reproduce real sensor latency, noise or physical motion.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles