Skip to content
Physical AI
All experiments

Real sensor data versus ideal simulation data

How noise, constant bias, bias drift, quantization, a finite sampling frequency and latency each change the signal a controller receives, compared with the perfect value a simulator can provide.

Loading simulation…

What it demonstrates

How noise, constant bias, bias drift, quantization, a finite sampling frequency and latency each change the signal a controller receives, compared with the perfect value a simulator can provide.

How it works

An ideal gyro signal (a sum of sinusoids plus an occasional step) is generated at 1 kHz. A sensor model samples it at the chosen frequency, adds bias, a bias random walk and white noise, and rounds the result to a quantization step (one least-significant bit). Each sample then waits in a delivery queue for the chosen latency.

Between deliveries the software keeps seeing the last delivered value (zero-order hold), which produces the staircase. The RMS error over the last 2 s summarises the combined effect. The presets are illustrative orders of magnitude, not values from any datasheet.

Adjustable parameters

  • Sampling frequency (25, 50, 100, 200, 1000 Hz)
  • White noise σ (0–0.2 rad/s)
  • Constant bias (−0.2 to 0.2 rad/s)
  • Bias random walk (0–0.05 rad/s/√s)
  • Quantization step (0–0.1 rad/s)
  • Latency (0–100 ms)

Known limitations

  • Latency is a constant delay. Real buses add jitter and occasionally drop or reorder packets (see Chapter 5).
  • No anti-aliasing filter, so high-frequency content aliases at low sampling rates, as it would without one.
  • Noise is white and Gaussian. Real sensors also show flicker noise, vibration pickup and temperature effects.

Equations

yk=Q(x(tk)+b+β(tk)+nk),tk=k/fsy_k = Q\big(x(t_k) + b + \beta(t_k) + n_k\big), \quad t_k = k / f_s
β(t+Δt)=β(t)+σβΔt w,w∼N(0,1)\beta(t + \Delta t) = \beta(t) + \sigma_\beta \sqrt{\Delta t}\, w, \quad w \sim \mathcal N(0,1)
software sees yk for t∈[tk+τ, tk+1+τ)\text{software sees } y_k \text{ for } t \in [t_k + \tau,\ t_{k+1} + \tau)
Q(x)=Δ⋅round⁡(x/Δ)Q(x) = \Delta \cdot \operatorname{round}(x / \Delta)

Core update rule

// lib/sim/ch04-sensors.ts
driftBias += biasWalk * Math.sqrt(dt) * gaussian(rng);
if (t >= nextSample) {                                 // ADC sample at rateHz
  const v = quantize(ideal + bias + driftBias + noise * gaussian(rng), lsb);
  pipeline.push({ t, v });
  nextSample += 1 / rateHz;
}
while (pipeline[0]?.t <= t - latency) output = pipeline.shift().v;  // delivery

Explained in Chapter 4: Sensors & Data