[Advanced] — Estimating the state you can’t measure, why the separation principle makes this tractable, and the filter that took Apollo to the moon.

The problem

State feedback needs . You have — fewer measurements than states.

So build a model that runs alongside the real system and corrects itself using the measurements.

The Luenberger observer

The naive version: simulate the plant.

This doesn’t work. If the initial estimate is wrong, the error never corrects — and if is unstable, the estimate diverges from reality exponentially. It’s open-loop estimation, with all the failings of open-loop control.

The fix is feedback, applied to the estimator:

The innovation is the difference between what you measured and what your estimate predicted you’d measure. Nonzero innovation means the estimate is wrong, and decides how hard to correct.

        u ──┬──────────────→[ PLANT ]────→ y
            │                                │
            └──→[ MODEL ]──→ŷ ──→(−)←───────┤
                    ▲                │       │
                    └──[ L ]←────────┘ innovation

Error dynamics

Define . Subtract the observer equation from the plant equation, and the terms cancel:

The estimation error has its own dynamics, governed by , and it’s independent of the input entirely.

And by duality with note 09: if is observable, you can place the eigenvalues of anywhere. Same algorithm, applied to .

How fast? Rule of thumb: observer poles 2–5× faster than the controller poles. The estimate must converge before the controller needs it. Faster than that and you amplify measurement noise — which is precisely the trade-off the Kalman filter formalises.

The separation principle

The result that makes this practical.

Design the controller assuming perfect state knowledge. Design the observer ignoring the controller. Put them together. The closed-loop eigenvalues are:

The controller poles and observer poles do not interact. You can design them separately and the combination behaves exactly as designed.

This is genuinely surprising — feedback loops normally interact strongly — and it’s what makes the whole state-space approach usable. Without it you’d have to design a -dimensional system all at once.

Two caveats that matter in practice:

It holds exactly only for the linear model. With nonlinearity, model error, or saturation, controller and observer do interact, and an aggressive observer with a fast controller can misbehave together in ways neither does alone.

Separation is about pole locations, not robustness. An observer-based controller can have much worse stability margins than the state-feedback design it was built from — the famous result is that LQG has no guaranteed margins at all, unlike LQR. → LQR

The Kalman filter

The observer above is fine when you choose by intuition. The Kalman filter chooses it optimally, given a statistical description of the noise.

  • — process noise, covariance . “My model isn’t perfect”
  • — measurement noise, covariance . “My sensors aren’t perfect”

Both assumed zero-mean, white, and Gaussian.

The Kalman filter is the minimum-variance estimator for a linear system with Gaussian noise. No estimator does better. That’s a theorem, not a claim about tuning.

The discrete algorithm

The form you’d actually implement. Two steps per sample:

Predict — run the model forward:


Update — fold in the measurement:



is the estimate error covariance — the filter’s own statement of how uncertain it is. Prediction increases it (the model drifts); measurement decreases it (data informs).

The Kalman gain is the whole story:

  • large (noisy sensor) → small → trust the model, smooth heavily
  • large (poor model) → large → trust the measurement, respond fast

That’s the entire intuition, and it’s a weighted average of two noisy sources of information, weighted by their reliability. The same logic as inverse-variance weighting in statistics, or a Bayesian posterior combining prior and likelihood — which is exactly what it is. → Probability and Statistics

Tuning it

and are the knobs, and in practice they’re tuned rather than derived.

you can usually measure. Hold the sensor still and compute the variance of its output. That’s a real number you can obtain in ten minutes.

is a fudge factor. It nominally represents process noise, but in practice it absorbs all your unmodelled dynamics. Larger means “I trust my model less”, which makes the filter more responsive and noisier.

Only the ratio matters for the steady-state gain — which halves the tuning problem.

Symptoms:

  • Estimate lags the truth, too smooth → increase (or decrease )
  • Estimate is noisy and jumpy → decrease (or increase )

Check the innovation. For a correctly tuned filter, the innovation sequence should be zero-mean white noise with covariance . If it’s correlated, or biased, or its magnitude doesn’t match, your model or your tuning is wrong. This is the diagnostic worth building in — it’s a self-check the filter gives you free, and most implementations never look at it.

Steady state. For a time-invariant system, and converge. You can precompute the steady-state gain (solve the algebraic Riccati equation offline) and run a fixed-gain filter — much cheaper, and standard on embedded hardware. The transient benefit of the time-varying gain only matters at startup.

Nonlinear variants

Real systems aren’t linear, and the standard extensions:

Extended Kalman Filter (EKF) — linearise about the current estimate at every step, using Jacobians of and .

Overwhelmingly the most used, and the one in most GPS/INS units, robot localisation stacks, and flight controllers. But: it requires Jacobians (analytical or numerical), it can diverge if the linearisation is poor or the initial estimate is far off, and it has no optimality guarantee at all. A diverged EKF is a common and frustrating failure — and the usual cause is an initial estimate outside the region where linearisation holds.

Unscented Kalman Filter (UKF) — propagate a deliberately chosen set of sigma points through the true nonlinear function and reconstruct the mean and covariance.

No Jacobians needed, accurate to higher order, and more robust to strong nonlinearity. Costs a bit more computation. If your EKF is diverging, try the UKF before adding more tuning.

Particle filter — represent the distribution with weighted samples. Handles arbitrary nonlinearity and non-Gaussian, multi-modal distributions. Expensive, and suffers from particle depletion in high dimensions, but it’s the only option when the posterior is genuinely multi-modal — which is why it’s used for robot kidnapping/global localisation, where “I might be in one of four identical corridors” is a real belief state. → Robotics

Sensor fusion

The most common real use, and the one worth understanding concretely.

An IMU integrates to give attitude, and drifts. Accurate over milliseconds, useless over minutes. A magnetometer or GPS gives an absolute reference that is noisy but doesn’t drift.

The Kalman filter combines them optimally: high-frequency information from the gyro, low-frequency correction from the absolute sensor. It’s a complementary filter with the crossover chosen by the noise statistics rather than by hand.

Standard combinations:

  • IMU + GPS — position and attitude for aircraft, cars, drones
  • Gyro + accelerometer — attitude; the accelerometer gives absolute tilt from gravity, the gyro gives fast rotation
  • Wheel odometry + lidar — robot localisation
  • Estimating a disturbance as an extra state — a “disturbance observer”, used to cancel load torque in motor drives

Estimating a bias as a state is the trick worth remembering. Gyro bias drifts slowly; add it to the state vector and the filter estimates and removes it continuously. Almost every real IMU filter does this, and it’s the difference between an attitude estimate that drifts and one that doesn’t.

Practical notes

Initialise well. A bad initial estimate with an overconfident can take a long time to recover, and can diverge an EKF entirely. When unsure, set large — that tells the filter to trust early measurements heavily.

Watch numerical conditioning. The covariance update can lose symmetry and positive-definiteness through rounding. Use the Joseph form update, or a square-root/UD-factorised filter, on anything long-running or embedded.

Reject outliers. A single bad measurement (GPS multipath, a dropped packet) can corrupt the estimate badly. Gate on the normalised innovation — if it’s more than ~3σ from expected, discard the measurement. Most field failures of a Kalman filter are outliers, not tuning.

Handle missing measurements properly. If a sensor doesn’t report this cycle, just skip the update step and keep predicting. The filter handles it naturally, and this is a real advantage over a fixed complementary filter.

Different rates are fine. IMU at 1 kHz, GPS at 10 Hz — predict every IMU sample, update whenever GPS arrives. One of the filter’s most useful practical properties.


↑ Back to Control Theory