RobotGuide

Robotics core · topic B7 · 40 hours

State estimation (Kalman filter family)

The robot never gets ground truth — only noisy, delayed measurements. State estimation is guessing the current state out of those.

Specialization stage · Hardcore
Algorithm · Proficient System software · Aware Embedded & controls · Aware

What to learn

The lesson · plain words

Every sensor lies (A2 covered the bell curve), and every model drifts. The Kalman filter does exactly one thing: from imperfect measurements and an imperfect model, produce an estimate better than either.

It has only two steps: predict, update. All the variants (EKF, UKF, particle filters) are those two steps bent to fit different situations.

Predict and update, each doing its own job

Predict: push the state forward through the model; uncertainty grows (the covariance inflates). Update: a measurement arrives and corrects the estimate by the Kalman gain K — K is the «whom do I trust» knob.

Drag Q and R below: large R (distrust measurements) gives a smooth but lagging estimate; large Q (distrust the model) hugs the measurements and lets their noise ride in. See those two extremes clearly and you understand filtering.

Interactive figure · drag it and see

What this figure shows: a one-dimensional Kalman filter — gray is truth, yellow the noisy measurement, the thick line the filter estimate, the blue band ±2σ; two sliders set process noise Q and measurement noise R. Takeaway: gain K near 1 tracks the measurements and rides their noise, K near 0 is smooth but lags the corners — the steady-state gain is set by the Q/R ratio, not by absolute values.

The Q/R ratio decides everything

R is measurement noise — measurable from static data on the real machine. Q is model imperfection — only tunable. Same conclusion as A2: the ratio drives behavior; absolute values do not matter.

The classic blunder is treating Q as «filter strength» and typing in a number. The right way is physical: the cruder the model and the wilder the maneuvering, the larger Q.

What about nonlinearity

EKF: linearize the nonlinear functions around the current estimate, then run plain Kalman. Cheap, adequate — the workhorse of several decades. Weakness: with strong nonlinearity or a bad initial guess, the linearization lies.

UKF: skip derivatives — push a set of carefully chosen sample points through the nonlinear function, approximate with their mean and covariance. Somewhat more accurate, somewhat more expensive.

The field failure checklist

Covariance not propagated: the filter grows ever more confident and finally refuses every correction. Timestamps unsynchronized: measurements pair with the wrong predictions and the gain is computed for nothing (echoes B1). Q/R never adapted across regimes: fine at rest, drifting the moment it moves.

Acceptance method: plot estimate minus truth and look at the tail. Structured drift means the model is wrong; unstructured white noise means R is too small.

Three questions — do you really get it?

1. Kalman gain K approaching 1 means?

  • ANearly full trust in the model prediction
  • BNearly full trust in the current measurement
  • CThe estimate is diverging
Show answer

B. K = P_pred/(P_pred+R); K→1 means R is tiny relative to prediction variance, so the estimate snaps onto the measurement.

2. The covariance keeps shrinking until the filter rejects every correction — what was forgotten?

  • AForgetting to inflate the covariance in the predict step (add Q)
  • BForgetting to update the gain
  • CForgetting to initialize the filter
Show answer

A. P += Q in the predict step re-injects uncertainty. Without it, P shrinks monotonically, the gain goes to zero, and the filter closes its mind.

3. The EKF's core operation is?

  • ALinearizing the nonlinear functions at the current estimate, then running standard Kalman
  • BAveraging measurements
  • CRaising the sampling rate
Show answer

A. EKF = linearization + standard Kalman. When the linearization point is wrong (large initial error, strong nonlinearity), it is unreliable.

Keep going deeper

Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.

How it fails in the field

You have learned enough when

You can hand-derive the two-step update of a one-dimensional Kalman filter, explain where the EKF's linearization error comes from, and name three typical causes of filter divergence.

The Chinese edition carries the full topic page for State estimation (Kalman filter family), including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/B7/.