Implementation:Google deepmind Mujoco CtrlNoise Pattern
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Benchmarking, Stochastic_Processes, Control |
| Last Updated | 2026-02-15 06:00 GMT |
Overview
Concrete pattern for generating Ornstein-Uhlenbeck control noise from the MuJoCo testspeed benchmark sample.
Description
The CtrlNoise function in sample/testspeed.cc pre-generates a full control sequence using the OU process driven by Halton quasi-random samples. It produces a flat array of nsteps * nu control values that are applied sequentially during the benchmark rollout.
Usage
Use as a pattern for generating benchmark control inputs. Customize noise amplitude (ctrl_noise_std) and rate (ctrl_noise_rate) for different model types.
Code Reference
Source Location
- Repository: mujoco
- File: sample/testspeed.cc
- Lines: 64-101
Signature
// Local helper function (not part of public API)
std::vector<mjtNum> CtrlNoise(
const mjModel* m,
int nsteps,
mjtNum ctrl_noise_std, // default 1.0
mjtNum ctrl_noise_rate, // default 0.01
int key // keyframe index for initialization
);
Import
// Not a library function - pattern from sample/testspeed.cc
#include <mujoco/mujoco.h>
#include <vector>
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| m | const mjModel* | Yes | Model (for nu actuator count and keyframes) |
| nsteps | int | Yes | Number of timesteps to generate |
| ctrl_noise_std | mjtNum | No | Noise amplitude (default 1.0) |
| ctrl_noise_rate | mjtNum | No | Mean-reversion rate (default 0.01) |
| key | int | No | Keyframe index for control initialization |
Outputs
| Name | Type | Description |
|---|---|---|
| return | std::vector<mjtNum> | Pre-generated control sequence of length nsteps * m->nu |
Usage Examples
#include <mujoco/mujoco.h>
#include <vector>
mjModel* m = mj_loadXML("humanoid.xml", NULL, error, 1000);
mjData* d = mj_makeData(m);
// Generate 10000 steps of control noise
std::vector<mjtNum> ctrl = CtrlNoise(m, 10000, 1.0, 0.01, -1);
// Apply during simulation
for (int i = 0; i < 10000; i++) {
mju_copy(d->ctrl, ctrl.data() + i * m->nu, m->nu);
mj_step(m, d);
}
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment