Kalman Filter Visualizer
Watch a robot's uncertainty ellipse inflate as it moves blind and snap tight when a measurement lands — a Kalman filter you can see, and feel on your phone.
How to use
A robot is moving through fog along the faint green path. The filter only ever sees the scattered amber dots — noisy position fixes — and from those it has to guess where the robot really is. The translucent blue blob is its uncertainty: between fixes it has nothing but a motion model to go on, so the blob inflates; the instant a fix lands, the estimate jumps toward it and the blob snaps tight. That breathing is the whole story.
Three sliders let you feel each term. Process noise Q is how fast the filter loses confidence while running blind — crank it up and the ellipse balloons between fixes. Measurement noise R is how much it distrusts each fix — crank it up and even a fresh measurement barely tightens anything, so the ellipse stays fat. Fix every sets how often measurements arrive — stretch it out and watch the ellipse inflate further and further before each snap.
Pause freezes the sim; Step then runs exactly one predict/update so you can watch the two halves separately; Reset restarts. The Show toggles let you hide the ground truth or the raw measurements, and the sigma-rings slider draws the 1σ, 2σ, and 3σ contours so you can see how confidence falls off.
What the filter is doing
The state is four numbers: position and velocity in x and y. Each frame runs two steps.
Predict. It pushes the state forward with a constant-velocity model — “wherever you were going, keep going” — and inflates the covariance by the process noise Q. This is the honest admission that a constant-velocity model is wrong the moment the robot turns, so the longer it runs without a correction, the less it should trust itself. On screen, that is the ellipse growing.
Update. When a measurement arrives, the filter computes the Kalman gain — the optimal blend between what it predicted and what it just measured, weighted by their relative uncertainties. A confident prediction against a noisy fix barely moves; an uncertain prediction against a tight fix snaps almost all the way to the measurement. The estimate jumps along that blend and the covariance shrinks by exactly the information the fix carried. That is the snap.
The ellipse itself is just the geometry of the covariance. Take the 2×2 position block of the covariance matrix, find its eigenvalues and eigenvectors, and you have an ellipse: the axes point along the eigenvectors and their lengths are the square roots of the eigenvalues, scaled by the sigma you want to draw. A round ellipse means the filter is equally unsure in every direction; a long thin one means it is confident across the track but vague along it — which is exactly what you see right after a turn, when the velocity estimate is briefly stale.
Using your phone’s motion
On a phone, Use my phone’s motion switches to a one-dimensional version of the same idea, fused from your real device. The faint needle integrates the gyroscope open-loop — pure dead reckoning, which drifts, so its uncertainty wedge keeps widening. The bold needle is the filtered estimate, corrected by the absolute compass heading whenever a fix lands, which pulls the wedge tight again. It is the same predict/update loop the simulation runs, driven by sensors in your pocket instead of a scripted path. Everything stays on-device — no motion data is uploaded, and there is no network call.
This is the heart of inertial navigation and the orientation half of robot localization: a fast, drifting sensor kept honest by a slower, absolute one. The Kalman filter is what lets you trust the fused result more than either source alone.