5-State EKF: Tight-Coupled GPS Pseudoranges

5-State EKF: Tight-Coupled GPS Pseudoranges#

This demo runs a tightly-coupled 2D Extended Kalman Filter that consumes raw GPS pseudoranges directly, one satellite at a time. It is the structural extension of the 4D linear KF from Block 5: same predict-update rhythm, same per-state error panels, same animated trajectory with a 95% covariance ellipse. The only new ingredient is that the measurement Jacobian is recomputed at every pseudorange update from the current receiver-to-satellite geometry.

The headline contrast with the GPS demo from Block 6 is that the receiver here is not a black box. There, an NLLS solver pre-processed all the pseudoranges into a single position estimate, which a downstream filter would then ingest as a position measurement (loose coupling). Here, every individual pseudorange is its own scalar measurement and the filter processes them one at a time. The advantages are operational, not just theoretical:

  • The filter still works with 1–3 satellites. The Block 6 black-box solver collapses below 4 satellites in 3D (3 in 2D); the EKF degrades gracefully.

  • Each pseudorange brings its own innovation \(\nu_i = z_i - h_i(\hat{\mathbf{x}}^-)\), with \(z_i = \tilde{\rho}_i\). That residual is a per-sat indicator the filter can monitor, the foundation of fault detection in Block 8.

  • The receiver clock bias becomes a state, learned over time alongside position and velocity instead of re-solved from scratch every update.

  • Sensor cadences mix freely. Each satellite can deliver pseudoranges at its own rate; the filter handles them in the order they arrive.

The 5-state model#

The state vector adds the receiver clock bias \(b\), the “+1” of tight coupling, to the constant-velocity 4D model (4 → 5 here; the operational INS/GPS filter goes 15 → 16 the same way):

\[ \mathbf{x} = \begin{bmatrix} p_x & p_y & v_x & v_y & b \end{bmatrix}^{\top}. \]

The transition matrix is the constant-velocity block plus a random-walk row for \(b\):

\[\begin{split} \mathbf{F} = \begin{bmatrix} 1 & 0 & \Delta t & 0 & 0 \\ 0 & 1 & 0 & \Delta t & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \end{bmatrix}, \qquad \mathbf{Q}_d = \begin{bmatrix} \mathbf{Q}_{\text{nav}} & \mathbf{0} \\ \mathbf{0}^{\top} & \sigma_b^2\,\Delta t \end{bmatrix}. \end{split}\]

\(\mathbf{Q}_{\text{nav}}\) is the 4D constant-velocity process-noise matrix from Block 5; the clock-bias channel evolves as a random walk with rate \(\sigma_b\).

The pseudorange measurement function for satellite \(i\) is the same nonlinear \(h_i\) from the Block 6 reading:

\[ h_i(\mathbf{x}) = \lVert \mathbf{p} - \mathbf{s}^{(i)} \rVert + b. \]

Linearizing at the current prior \(\hat{\mathbf{x}}^-\) gives the \(1 \times 5\) Jacobian

\[ \mathbf{H}_i = \begin{bmatrix} \hat{e}_x & \hat{e}_y & 0 & 0 & 1 \end{bmatrix}, \qquad \hat{e} = \frac{\hat{\mathbf{p}}^- - \mathbf{s}^{(i)}}{\lVert \hat{\mathbf{p}}^- - \mathbf{s}^{(i)} \rVert}. \]

Three things to read off this row:

  • Position entries are the unit vector from satellite \(i\) to the receiver (the negative of the receiver-to-satellite line of sight), computed over the geometric range \(\rho_i = \lVert \hat{\mathbf{p}}^- - \mathbf{s}^{(i)} \rVert\) (never \(\rho_i + b\)).

  • Velocity entries are zero. Pseudoranges don’t depend instantaneously on velocity, so a single pseudorange update touches velocity only through the cross-covariance.

  • Clock-bias entry is exactly 1. \(b\) adds linearly to every pseudorange, so a unit change in \(b\) produces a unit change in the predicted measurement.

Interactive demo#

Open in full screen

The layout matches the multi-state KF demos: live 2D trajectory with the 95% position-covariance ellipse, error panels for position (\(x\) and \(y\) overlaid), velocity and clock bias with \(\pm 95\%\) bounds, an animation control bar with scrubber, and synchronized “now” cursors across all panels. The demo starts paused at \(t = 0\) and plays once it scrolls into view. Three elements are new:

  • The sky compass in the top-right fieldset shows each satellite’s direction from the receiver. Drag a satellite (or focus it and use the arrow keys) to change the geometry. Each satellite has its own color, on/off toggle, and update-interval slider, so you can mix sensor cadences freely.

  • The Last scalar update card shows, for the most recent pseudorange (or the satellite you pick), the unit vector \(\hat{\mathbf{e}}_i\), the Jacobian row \(\mathbf{H}_i\), the innovation \(\nu_i\), its variance \(S_i\), the 5-element gain \(\mathbf{K}_i\) and the state change \(\Delta\mathbf{x} = \mathbf{K}_i\nu_i\), with a sentence on which states moved and why. It is the Block 7 reading’s Quick Exercise, running live.

  • The card’s Geometry line gives the HDOP of the satellites that are on, computed from their stacked rows \([\hat{e}_x\ \hat{e}_y\ 1]\) (the position and clock columns of \(\mathbf{H}\)), the same DOP as Block 6.

Walkthrough#

The demo opens at a default scenario: 4 satellites evenly spread, \(\sigma_\rho = 10\) m, all satellites updating at 1 Hz, \(\sigma_a = 2\) m/s², clock random-walk rate \(\sigma_b = 3\) m/√s, \(T = 300\) s. The filter starts at the nominal state \(\hat{\mathbf{x}}_0 = (0, 0, 5, 3, 0)\) with \(\sigma = 10\) m in position, \(10\) m/s in velocity and \(\sigma_{b,0} = 50\) m in clock bias; truth is drawn from that prior. (The numbers below are for the default seed; Reseed changes the random draws, not the \(\sigma\)’s.) Try the following:

  1. Read the headline metrics. At the end of the run the position \(\sigma_p\) is 4.15 m and the 95% ellipse is a circle of 10.2 m radius. The velocity uncertainty, which started at 10 m/s, has fallen to 1.31 m/s, and the clock-bias error is 3.05 m against a \(1\sigma\) of 3.34 m. The error traces stay mostly inside their 95% bounds: \(p_x\) 89%, \(p_y\) 97%, \(v_x\) 92%, \(v_y\) 95% and \(b\) 96% of samples. About 1 sample in 20 outside is expected. Neighboring samples are correlated, so a single run can land several points either side of 95%. The filter has learned the clock bias as a state, alongside position and velocity, from purely scalar pseudorange measurements. The Geometry line puts this beside Block 6: HDOP 1.00, so a one-epoch snapshot fix would be good to about \(\mathrm{HDOP}\cdot\sigma_\rho/\sqrt{2} = 7.1\) m per axis. The filter’s 4.15 m is better because it carries information forward in time.

  2. Watch one update at a time. The four S1–S4 dots in the top-left of the trajectory panel light up when their satellite’s pseudorange is processed. Pause and read the Last scalar update card. At 1 Hz all four satellites update in the same 0.1 s step, one after another; the card says which one you are looking at (“update 4 of 4 at this epoch”), so you can see that each prior \(\hat{\mathbf{x}}^-\) already includes the earlier satellites. Click SAT 1: it sits due east of the receiver, so \(\hat{\mathbf{e}} = [-1, 0]\) and \(\mathbf{H} = [-1\ 0\ 0\ 0\ 1]\), the same pattern as the reading’s Quick Exercise (unit vector under position, 0 under velocity, 1 under \(b\)). A negative \(\nu\) moves \(\hat{\mathbf{p}}\) toward the satellite and lowers \(\hat{b}\); a positive \(\nu\) does the opposite. Velocity moves too, through \(\mathbf{P}^-\)‘s cross-covariance, even though \(\mathbf{H}\) has zeros there.

  3. Toggle off SAT 2, 3 and 4, leaving only SAT 1. One pseudorange constrains a single combination of \(b\) and the position along SAT 1’s line of sight, so position diverges. \(\sigma_p\) is 73 m at 10 s, 441 m at 60 s, 1.16 km at 150 s and 2.51 km at 300 s. Almost all of it lies across the line of sight: \(\sigma_y\) grows from 101 m to 3.55 km, and the 95% ellipse leaves the window (the off-scale callout gives 8.69 km × 131 m semi-axes at 300 s). That cross-track growth is exactly the zero-satellite run’s: SAT 1 tells the filter nothing about \(p_y\). Along the line of sight, SAT 1 measures only \(b - p_x\), so the \(p_x\) and \(b\) errors lock together and grow at the clock’s random-walk rate. \(\sigma_x\) climbs from 17.7 m to 53.7 m and tracks the clock’s \(1\sigma\), 53.36 m on the clock-bias card at 300 s. The filter never breaks and its bounds stay honest, but position is no longer observable. Block 6’s snapshot solver would produce nothing at all.

  4. Re-enable SAT 2 (90° from SAT 1). Two pseudoranges and three unknowns (\(p_x\), \(p_y\), \(b\)) still leave one null direction: shifting the receiver along 45° and the clock by the matching amount changes neither range. The ellipse is a thin cigar along 45° (minor semi-axis 13.4 m) whose major axis keeps growing. \(\sigma_p\) is 15.1 m at 10 s, 25.6 m at 60 s, 38.3 m at 150 s and 53.1 m at 300 s (\(\sigma_x = \sigma_y\); the worst axis is 75 m). Now slide \(\sigma_b\) down to 0.1 m/√s. The growth stops: \(\sigma_p\) is 11.2 m at 10 s and 10.1 m at 300 s. That is not a fix. The null direction never changes, and a steady clock only stops process noise from feeding it. The filter then holds what it already knew along that direction: here, the 10 m position prior it started with. In practice that knowledge would come from an earlier full fix, with the clock coasting on it. Two ranges cannot create a fix. Put \(\sigma_b\) back to 3 and turn SAT 3 on: three directions give a firm fix, \(\sigma_x = 4.2\) m and \(\sigma_y = 6.3\) m (HDOP 1.41). A 2D fix needs three satellites; a steady clock can only preserve, for a while, what an earlier fix established. (If the two satellites share a line of sight instead, e.g. SAT 1 and SAT 3 at 0° and 180°, the null direction is pure cross-track position and \(\sigma_y\) grows whatever \(\sigma_b\) is.)

  5. Slide individual satellite intervals. Pull SAT 1 to 0.1 s and SAT 2–4 to 5 s. Between the 5 s epochs the ellipse stretches across SAT 1’s east–west line of sight: just before a 5 s epoch it is 28.6 m × 16.1 m (semi-axes, at \(t = 299.5\) s), and each epoch pulls it back to 15.1 m × 10.0 m. It stays narrowest along SAT 1’s line of sight. Even ten pseudoranges a second from SAT 1 cannot hold \(\sigma_x\) down. It is 4.1 m just after each 5 s epoch and climbs to about 6.9 m before the next (6.6 m at 299.5 s), because SAT 1 alone sees just the combination \(b - p_x\) and the 3 m/√s clock walks between the 5 s epochs. Drop \(\sigma_b\) to 0.1 m/√s and \(\sigma_x\) stays between 2.55 and 2.66 m. Tight coupling lets sensors at different cadences each contribute what they can, without any pre-aggregation step.

  6. Click the “Clustered (bad)” preset. All four satellites collapse into a 30° arc, 60°–90° (the demo measures angles counterclockwise from east, for satellites and ellipse alike). The Geometry line reads HDOP 33.1. The ellipse stretches along the cluster’s mean line of sight, 75°: 77.8 m × 28.2 m semi-axes, \(\sigma_p = 23.9\) m. This is the same anisotropic stretch as the Block 6 GPS demo; geometry still matters in the EKF. Drag SAT 1 to the opposite side of the sky (240°, or focus it and press ← 36 times): HDOP drops to 4.18 and \(\sigma_p\) to 11.7 m.

  7. Slide \(\sigma_\rho\) up to 30 m. Bounds widen across all states (\(\sigma_p\) 4.15 → 9.87 m, \(\sigma_v\) 1.31 → 1.76 m/s), and every scalar gain shrinks: for SAT 4 at 300 s, \(K_{p_y}\) goes from 0.172 to 0.108 and \(K_b\) from 0.112 to 0.045. The filter trusts the prior more when the measurement is noisy. The ellipse stays a circle; geometry is structurally separate from per-satellite noise.

  8. Slide \(\sigma_b\) up to 10 m/√s. The clock-bias bounds widen (\(1\sigma\) 3.34 → 4.55 m at 300 s) because the filter expects more drift between updates; \(\sigma_p\) stays 4.15 m with this symmetric geometry. The clock-bias state’s \(\mathbf{Q}\) entry is a tuning knob just like any other process noise.

  9. Pause and scrub. Drag the time slider. The ellipse, the error-panel cursors, the Last-update card and the stats all snap to that time, so you can inspect the filter state at any moment.

Key observations#

  • Same recursion as the linear KF. The predict-update equations are unchanged from Block 5; only the measurement model gets re-linearized at every update. Predict moves the state forward; update fuses the measurement with the prior using inverse-variance weighting; covariance shrinks under each update and grows under each predict.

  • The 1×5 Jacobian carries everything. Position entries are the satellite-to-receiver unit vector (the negative of the line of sight); velocity entries are zero (no instantaneous velocity sensitivity in pseudoranges); clock-bias entry is unity. The Jacobian re-evaluates as \(\hat{\mathbf{x}}^-\) moves, but its structure stays the same.

  • Cross-covariance picks up velocity. Pseudorange Jacobians have zero velocity entries, but the filter still produces a velocity estimate because \(\mathbf{P}\) has non-zero \(p\)-\(v\) off-diagonals from \(\mathbf{F}\)’s \(\Delta t\) couplings. Watch the velocity bounds: \(\sigma_v\) starts at 10 m/s and falls to 7.8 m/s after the first epoch (1 s), 3.5 m/s at 3 s, 2.0 m/s at 5 s and 1.3 m/s by 10 s, even though no measurement observes velocity directly.

  • Observability needs three directions in 2D. One satellite leaves position unobservable across its line of sight; two leave a null direction shared with the clock; three spread directions give a bounded ellipse. A steady clock (small \(\sigma_b\)) stops the growth along a position-and-clock null direction. It only preserves what the filter already knew there; it cannot stand in for the missing third range.

  • Tight coupling separates sensor cadence from filter cadence. The filter runs at \(\Delta t = 0.1\) s; each satellite delivers its measurement on its own schedule (1 Hz, 5 Hz, 10 s, whatever). The filter handles them as they arrive without any pre-aggregation.

  • Geometry still controls observability. Cluster the satellites and the cov ellipse balloons along the cluster’s LoS, exactly as in the Block 6 black-box demo. The EKF formulation does not magic away DOP; it just makes every other operational property of the receiver more graceful.

  • Per-satellite innovations are now available. Each scalar update produces an innovation \(\nu_i\) that the filter could test for outliers (does it exceed some multiple of its expected \(\sigma\)?). Block 8 builds exactly that test, and the per-sat structure of the EKF is the reason it can be done at all.

Source#

MATLAB bundle · demos/ExtendedKalmanFilter5D.m↓

With the 2D covariance ellipse helper in navutils/Draw2DErrorBounds.m. The MATLAB script uses the same parameters, the same initial-condition convention (filter at the nominal \(\hat{\mathbf{x}}_0\), truth drawn from \(\mathbf{P}_0\)) and plots errors as estimate − truth. Its random draws differ (MATLAB rng(1) vs. the demo’s seeded generator), so its traces differ, but its deterministic numbers match the demo at the default settings: HDOP 1.00, and at 300 s \(\sigma_p = 4.15\) m, \(\sigma_v = 1.31\) m/s, clock \(1\sigma\) = 3.34 m, \(S = 139.7\) m² for SAT 4. It prints these, plus its last scalar update, to the Command Window.