6-State Kalman Filter: Observability of P, V, A#
This demo extends the 4-state filter from one block earlier with an explicit acceleration channel, modeled as a first-order Gauss-Markov process (recall Block 2). The resulting state has six components: 2D position, 2D velocity, 2D acceleration. The headline lesson here is observability: which states each measurement type can pin down, and which it cannot. With three sensor toggles (position, velocity, acceleration) you can compose any subset and watch the filter behave accordingly:
Position fixes everything “downhill”. A position update teaches the filter about velocity (through the same cross-covariance mechanism as the 4D demo) and about acceleration (through the second integration). All six states stay bounded.
Velocity fixes only velocity and acceleration. No matter how good the velocity sensor is, the filter has no way to determine absolute position from a velocity-only stream. Position drifts and its covariance grows without bound.
Acceleration fixes only acceleration. An acceleration fix cannot remove the initial velocity or position error (those are the constants of integration), so both still drift without bound. The fixes do slow that drift a great deal, because the filter no longer has to guess the acceleration it integrates.
The state and dynamics#
The state vector is
Per axis, the dynamics are constant-acceleration kinematics with a Gauss-Markov decay on the acceleration:
Stacked across both axes, \(\mathbf{F}\) is a 6×6 block matrix. Process noise enters only on the two acceleration channels (the kinematic chain itself is treated as exact at this scale), so \(\mathbf{Q}_d\) is essentially \(\mathrm{diag}(0,0,0,0, \sigma_a^2(1-\rho^2), \sigma_a^2(1-\rho^2))\). The off-diagonal coupling that lets a position measurement teach the filter about velocity and acceleration is carried entirely by \(\mathbf{F}\) and the way it propagates \(\mathbf{P}\) forward.
The three available measurements are linear in the state:
Interactive demo#
The layout follows the 4D demo. It opens paused at \(t = 0\) and starts playing when you scroll it into view (it stays paused if your system asks for reduced motion). Any parameter change re-runs the simulation and keeps the cursor where it is.
The live trajectory panel is a top-down view, auto-scrolled to keep the estimate centered in a ±200 m window. It shows the current 95% position ellipse (a circle, since the two axes are identical), and POS / VEL / ACC dots that flash when a fix arrives. Anything that leaves the window gets an edge arrow with its size.
Beside it (below it in a narrow window), a correlation heatmap shows the \(x\)-axis block of \(\mathbf{P}\) (\(p_x\), \(v_x\), \(a_x\)) at the cursor. Off-diagonal cells give the signed correlation \(\rho\), shaded by \(|\rho|\); diagonal cells give \(\sigma\). A caption says which correlations the current sensor set is using.
Three error panels below plot the \(x\) (blue) and \(y\) (orange) errors, estimate − truth, against the shared ±1.96σ bound: position ±150 m, velocity ±25 m/s, acceleration ±5 m/s². Each has a synchronized cursor and off-scale markers.
The cards give the live estimates, \(\sigma_p \cdot \sigma_v \cdot \sigma_a\) with \(\mathrm{tr}\,\mathbf{P}_\text{pos}\), and the bound coverage so far. The line under the play bar states what to notice at the current moment.
Three sensor toggles in the Filter model & sensors panel let you switch between sensor combinations to expose the observability story.
The two \(\sigma_a\) sliders are deliberately separate: \(\sigma_a\) (process) on the truth side and \(\sigma_a\) (model Q) on the filter side, the same Q-tuning split as the 4D demo. The shared \(\tau_a\) slider controls the acceleration correlation time for both truth and filter together.
Walkthrough#
The demo opens with the position sensor on (\(\sigma_\text{pos} = 10\) m every 10 s) and the others off, \(\tau_a = 60\) s, \(\sigma_a = 1\) m/s² for both truth and filter, \(T = 180\) s, speed 4×. The filter starts at \(\hat{\mathbf{x}}_0 = (0, 0, 5, 3, 0, 0)\) with \(\sigma = 10\) m, 10 m/s and 1 m/s²; the truth is drawn from that same \(\mathcal{N}(\hat{\mathbf{x}}_0, \mathbf{P}_0)\). Try the following:
Watch the default: position-only. Before the first fix \(\sigma_p\) grows to 110 m (\(t = 9.9\) s). The first fix pulls it to 9.96 m and, although velocity is never measured, pulls \(\sigma_v\) from 13.9 to 4.72 m/s. By 180 s the filter is in steady state: \(\sigma_p\) 9.84 m, \(\sigma_v\) 2.74 m/s, \(\sigma_a\) 0.52 m/s² (down from 1.0). At the default seed the errors stay inside their bounds (coverage card 100%; acceleration 99%). The trajectory circle breathes hard, from a 95% radius of 24 m after a fix to 133 m just before the next, because ten seconds without a fix let the velocity and acceleration errors integrate into position. The heatmap shows how a position fix reaches the states it does not measure: at 180 s, \(\rho(p,v) = 0.49\), \(\rho(p,a) = 0.16\) and \(\rho(v,a) = 0.78\). Position fixes everything downhill.
Toggle position OFF, velocity ON (\(\sigma_\text{vel} = 1\) m/s every 5 s). Velocity and acceleration stay bounded (\(\sigma_v\) 0.93 m/s, \(\sigma_a\) 0.33 m/s²), but nothing pins position. \(\sigma_p\) grows without bound: 25.2 m at 100 s and 32.2 m at 180 s, with \(\mathrm{tr}\,\mathbf{P}_\text{pos}\) climbing about 10 m²/s (the note line reports the rate). As in the 4D demo, that is the velocity-fix noise integrated as a random walk, \(2\,\sigma_\text{vel}^2\,\Delta t_\text{vel} = 2 \times 1 \times 5 = 10\) m²/s. The trajectory circle now grows steadily instead of breathing. The heatmap shows why: \(\rho(p,v)\) has fallen to 0.09, so a velocity fix has almost nothing to say about position. Velocity fixes only velocity and acceleration.
Toggle velocity OFF, acceleration ON (\(\sigma_\text{acc} = 0.2\) m/s² every 5 s). Only \(\sigma_a\) stays bounded (0.18 m/s²). \(\sigma_v\) climbs past its initial 10 m/s (12.2 m/s at 180 s), and \(\sigma_p\) reaches 254 m at 25 s, 1.05 km at 100 s and 1.95 km at 180 s. The ellipse and the truth soon leave the window, and the callouts report their size (at 100 s: “95% radius 2.57 km (off scale)”). The fixes still help a great deal: with every sensor off, \(\sigma_v\) reaches 122 m/s and \(\sigma_p\) 11.9 km by 180 s. What they cannot do is remove the initial velocity and position error. A record of acceleration says nothing about the starting velocity or position (they are the constants of integration), so that part of the error is never recovered. In the heatmap \(\rho(p,a)\) and \(\rho(v,a)\) are near zero (0.00 and 0.06 at 100 s), partly because the fixes have already used up those correlations; what remains in \(\sigma_p\) and \(\sigma_v\) is the part an acceleration fix cannot reach. Acceleration fixes only acceleration.
Try pos + vel together. Compared with position only, at 180 s \(\sigma_v\) drops from 2.74 to 0.90 m/s and \(\sigma_p\) from 9.84 to 6.93 m. The bigger change is between fixes: the largest prior \(\sigma_p\) falls from 54.5 m to 12.0 m, so the circle barely breathes (95% radius about 17 m to 29 m). Two complementary sensors make the same information go further.
Try pos + acc. Now acceleration is measured directly rather than inferred: \(\sigma_a\) drops from 0.52 to 0.18 m/s², \(\sigma_v\) from 2.74 to 1.33 m/s and \(\sigma_p\) from 9.84 to 9.11 m, and the largest prior \(\sigma_p\) falls from 54.5 m to 22.4 m. This is closer to a real INS+GPS architecture, where the IMU measures specific force directly and GPS pins absolute position.
Slide \(\tau_a\) up and down (position only). \(\tau_a\) sets how long the acceleration remembers itself, for truth and filter together.
Long \(\tau_a\) (300 s): acceleration is nearly constant over the run, \(\mathbf{Q}_d\) is small, and the fixes can learn it: \(\sigma_a\) 0.28 m/s², \(\sigma_v\) 1.97 m/s.
Short \(\tau_a\) (5 s): acceleration decorrelates between fixes, \(\mathbf{Q}_d\) is about 60 times larger, and the fixes cannot learn it: \(\sigma_a\) stays at 0.97 m/s² (of its 1.0 prior) and \(\sigma_v\) rises to 3.76 m/s.
The velocity and acceleration bounds change; position hardly does (9.66 m vs 9.89 m), because each fix resets it. Same \(\sigma_a\), different memory length.
Q-tuning experiment. Back at the defaults, slide \(\sigma_a\) (process) up to 3 m/s² and leave \(\sigma_a\) (model Q) at 1 m/s²: the world is now three times more turbulent than the filter believes. The bounds do not move at all (still \(\sigma_p\) 9.84 m, \(\sigma_v\) 2.74 m/s, \(\sigma_a\) 0.52 m/s² at 180 s), because \(\mathbf{P}\) never sees the truth. But the coverage card turns red: 68% at the default seed (position 78%, velocity 66%, acceleration 59%), and typically 50–73% across seeds. Lowering \(\sigma_a\) (model Q) to 0.2 m/s² with the process at 1 m/s² gives the same failure from the other side: the bounds tighten (\(\sigma_v\) 1.29 m/s, \(\sigma_a\) 0.13 m/s²) and coverage drops to 60% (typically 35–61%). A milder mismatch such as model 0.5 is hard to see in one run (87% at the default seed, typically 68–89%). Same overconfidence pattern as the 4D demo, one state-vector layer deeper.
Pause and scrub. Drag the time slider. The trajectory, the heatmap, all three error-panel cursors, the cards and the note line update in lockstep, so you can inspect filter state at any moment.
Key observations#
Observability runs downhill, not uphill. Position is the deepest integral in the chain. Information injected at any level reaches everything below it (downhill toward acceleration) but cannot reach anything above. This is a structural property of the constant-acceleration model, not of the Kalman filter: the filter just inherits whatever observability the dynamics allow.
The 95% bounds on the trajectory ellipse make divergence visible quickly. When you turn off the position sensor, the ellipse grows on every prediction step, and the remaining fixes barely re-tighten it. Once it outgrows the ±200 m window, an edge callout keeps reporting its size. That visible inflation is the structural failure of velocity-only or acceleration-only architectures for absolute positioning.
Bounds for x and y are identical by symmetry. The error panels overlay both channels so you can see the realizations differ (different random samples) but the dashed red bound is shared: \(P_{xx} = P_{yy}\) (and \(P_{xy} = 0\)) at every step because the model treats the two axes symmetrically. That is also why the trajectory ellipse is always a circle.
Why operational systems look the way they do. A standalone IMU (acceleration-only, essentially) cannot navigate forever: drift grows in both velocity and position. A GPS+IMU pair pins absolute position with rare GPS fixes while letting the IMU fill in fast attitude/velocity dynamics between fixes. This demo is the reduced-dimension prototype of that architecture.
Same recursion as 4D. The predict-update equations are unchanged from the 4-state demo; only the matrices grew. Every Kalman lesson in this course works the same way at any state-vector size.
Source#
MATLAB bundle · demos/KalmanFilter6D.m↓
With the 2D covariance ellipse helper in navutils/Draw2DErrorBounds.m and the Van Loan discretization helper in navutils/CalculateQdVanLoan.m. The MATLAB version uses the continuous-time formulation \(\dot{\mathbf{x}} = \mathbf{F}\mathbf{x} + \mathbf{G}\mathbf{w}\) with Van Loan to compute \(\mathbf{Q}_d\); the demo above takes the equivalent shortcut of writing the discrete-time matrices directly, which is exact for the Gauss-Markov component and an excellent approximation for the kinematic chain at \(\tau_a \gg \Delta t\).
The script otherwise matches the demo:
the same defaults (\(T = 180\) s, position sensor only, \(\tau_a = 60\) s, \(\sigma_a = 1\) m/s²) and the same initial-condition convention;
the same optional acceleration sensor (0.2 m/s² every 5 s);
errors plotted as estimate − truth.
It prints \(\sigma_p\), \(\sigma_v\), \(\sigma_a\), \(\mathrm{tr}\,\mathbf{P}_\text{pos}\), the \(x\)-axis correlations and the bound coverage at the end. At the defaults it gives 9.84 m, 2.74 m/s and 0.514 m/s² (demo: 0.516; the difference is the Van Loan \(\mathbf{Q}_d\)), and \(\rho(p,v) = 0.49\), \(\rho(p,a) = 0.16\), \(\rho(v,a) = 0.78\). Its random draws differ from the browser’s, so the error traces and coverage agree only statistically. The script uses rng(4), chosen because its bound coverage sits near the median of a 400-seed Monte Carlo:
Run |
Position |
Velocity |
Acceleration |
Overall |
|---|---|---|---|---|
Defaults |
88.9% |
87.4% |
95.9% |
91% |
\(\sigma_a\) process 3, model 1 |
70.2% |
61.2% |
54.1% |
62% |
\(\sigma_a\) model 0.2, process 1 |
61.9% |
39.6% |
36.5% |
46% |
As in the demo, the truth’s initial acceleration is drawn with \(\sigma_a\) (model), not \(\sigma_a\) (process).