Implementation:Google deepmind Mujoco Platform Step Control
| Knowledge Sources | |
|---|---|
| Domains | Simulation Control, Timing |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Controls simulation stepping rate, pause states (including viscous pause), speed measurement, timing synchronization, and control noise injection.
Description
step_control.cc implements StepControl, the central simulation timing controller for MuJoCo's platform layer. It installs a high-resolution std::chrono::steady_clock-based timer via mjcb_time, manages real-time synchronization with configurable speed (0.1x to 100x real-time), and supports three pause states: running, paused, and viscous-paused. Viscous pause is a special mode that zeroes gravity, increases viscosity to 10, and disables springs, allowing the simulation to gently settle rather than freeze. The class also manages control noise parameters (scale and rate) and provides a ForceSync method to reset timing after discontinuities. The Advance method determines when to step the simulation based on wall-clock timing.
Usage
Instantiated by Studio's App and used each frame to decide whether to advance the simulation. The step control manages the play/pause toggle, speed slider, and viscous pause mode from the Studio toolbar.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/experimental/platform/step_control.cc
- Lines: 1-227
Key Functions
static mjtNum Timer(); // steady_clock-based timer in milliseconds
StepControl::StepControl();
float StepControl::GetSpeedMeasured() const;
void StepControl::SetSpeed(float speed_percent_real_time);
void StepControl::SetPauseState(PauseState state, mjModel* m);
StepControl::Status StepControl::Advance(mjModel* m, mjData* d);
void StepControl::SetNoiseParameters(float ctrl_noise_scale, float ctrl_noise_rate);
Import
#include "experimental/platform/step_control.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| m | mjModel* | Yes | MuJoCo model (modified during viscous pause) |
| d | mjData* | Yes | MuJoCo data for simulation stepping |
| speed | float | No | Desired speed as percentage of real-time (0.1 to 100) |
| state | PauseState | No | Requested pause state (running, paused, viscous-paused) |
Outputs
| Name | Type | Description |
|---|---|---|
| Status | StepControl::Status | Whether the simulation should step this frame |
| speed_measured_ | float | Actual measured simulation speed |