- The rocket's state has four numbers: two positions and two velocities.
- F is two constant-velocity blocks, one for x and one for y. They are interleaved, because the state lists x, y first and vₓ, vᵧ after.
- H keeps the two positions, because GPS sees where the rocket is, not how fast it goes.
- Q says how much the motion model can be wrong (bigger Q, less trust in the model). In the lab Q = q·I, so one number q sets it. R says how noisy the GPS is (bigger R, less trust in the GPS). They are the two knobs to tune.
- The covariance ellipse grows on every predict and shrinks on every correct.
Four numbers for a rocket
The rocket moves in a plane. To predict where it will be next second, we need where it is and how fast it is going, in both directions. So the state is s = (x, y, vₓ, vᵧ) and P is a 4 by 4 matrix. (We call the state s here, so that x can mean the first position.)
The rocket coasts: no engine, so velocity stays the same from tick to tick, and each position grows by its velocity times Δt. That is the moving mass of slide 4, once for x and once for y:
Row 1 of F says x + vₓΔt. Row 2 says y + vᵧΔt. Rows 3 and 4 keep the velocities. H has two rows, one for each GPS coordinate.
Where are the "two copies" of 1Δt01? The state s is ordered (x, y, vₓ, vᵧ), so the copies are interleaved. Rows 1 and 3, read at columns 1 and 3, are the x copy: they link x with vₓ. Rows 2 and 4, at columns 2 and 4, are the y copy.
Q and R: the two knobs
R is the GPS noise. Distances here are in map units (one grid step on the Earth-to-Mars map), and so are all the errors below. Our GPS has σ = 3 map units in each direction, independent, so R = 9·I, a 2 by 2 matrix with 9 on the diagonal. This one you can usually read off a datasheet.
Q is harder. It says how wrong one tick of the model can be. Our rocket is not quite coasting: gravity bends its path, so its velocity drifts. In the lab Q = q·I, and q is the knob. A big q says "my model is poor", so the filter leans on the GPS and the estimate gets jumpy. A small q says "my model is good", so the filter smooths the GPS out. Too small, and it trusts a straight-line model so much that it misses the bend.
To compare settings we use the RMS error (root-mean-square error): square every error, average the squares, take the square root. It is the typical size of the error, and smaller is better.
The two pictures below run the same flight with the same GPS readings. Only q changes. They show the rocket's y position over time, the coordinate that gravity bends.
Lowering q helps, down to a point: q = 1 just misses the lab's goal of 65%, and q = 0.1 passes. q = 0 is the trap. The filter believes the straight-line model is perfect, so after a few seconds it stops listening to the GPS, and it sails straight past the bend. Its error ends up worse than the raw GPS.
The ellipse on the map
In 1D the uncertainty was a band. Here it is the 2σ ellipse of the position part of P, the top-left 2 by 2 block. After each predict it grows, because the rocket moved without looking. After each GPS fix it shrinks. After a few seconds the two balance, and the ellipse settles to a steady size.
The ellipse is round here because x and y have the same noise and do not interact. Give the GPS a worse east–west accuracy (a bigger first entry of R) and it stretches sideways.
Keep reading with the full course
Finish lesson 3 and you will be able to: track position and velocity in 2D with the matrix Kalman filter.
Still locked here:
- The rest of this explanation
- 3 more examples with step-by-step solutions
- Five extra members-only problems with worked solutions
$20 once, lifetime access. Lessons 1 and 2 stay free.
Examples
Example 1 · Predict and measure one tick
Δt = 1 s. The rocket's state is s = (10, 4, 2, 1): at (10, 4), moving 2 per second in x and 1 in y.
Show solutionHide solution
A reading of (13, 4) would give the innovation (1, −1).
Example 2 · How the uncertainty grows
Start from P = I (4 by 4) and predict one tick with Δt = 1 and Q = 0.
Show solutionHide solution
Each position variance doubled, from 1 to 2, because an unsure velocity added its own uncertainty. Each position became linked to its own velocity (the 1s), but x and y stay unlinked (the 0s). The map ellipse is the top-left block, 2·I: a circle with σ = √2.
Questions and comments
Stuck on something, or found a mistake? Ask here and I'll answer. You sign in with GitHub.