How a robot combines imperfect sensors and a model of its motion to know where it is, and how sure it is. From covariance and confidence ellipses to the Kalman filter, its extended version (EKF), UWB localisation and multimodal fusion, with labs in 3D.
How to use this course
Every lesson starts with one sentence that says the idea without maths, then explains it step by step, then gives the formulas and a lab. Beginners can read the sentences and play with the labs; Master students will find the proofs and the exercises of the tutorials (DC motor, room temperature, pendulum, multilateration, multimodal fusion). Prerequisites: matrices and a little probability (see the links at the end of each lesson).
1
Why fuse data? Sensors for autonomous navigation
15 min
You will learn
what data fusion is for, the sensors of drones, mobile robots and cars, why no sensor is enough alone, the families of estimation methods, and the practical problems (calibration, biases, rates, faults).
In one sentence
Data fusion combines several imperfect sensors and a model of motion to get one estimate of the state of a robot that is better than any sensor alone — and it also says how sure it is.
1.1 The problem: autonomous navigation
A drone (UAV), an autonomous mobile robot (AMR) or a self-driving car must know at every instant its state: position, speed, orientation (up to 6D). Safety requires redundancy: several sensors measure the same thing in different ways, so that one failure does not blind the robot.
Sensor
What it measures
Weak point
IMU: accelerometers, gyroscopes, magnetometers
acceleration (gravity + own acceleration), rotation speed, Earth magnetic field, in the body frame
integration drifts; magnetic disturbances
GNSS (GPS, Galileo, GLONASS, BeiDou)
position from pseudo-ranges (multilateration)
outdoors only, multipath, a few metres without corrections
Barometer, Pitot tube
altitude, air speed
weather, wind
Lidar (time of flight)
distances to landmarks and obstacles
glass, rain, cost
UWB radio (ultra wide band)
distance by time of flight (TOF), angle of arrival (AOA), differences of time or phase (TDOA, PDOA)
needs installed anchors, multipath
Wheel encoders
wheel rotation → odometry
slip, drift
Cameras (RGB, depth, event)
images, depth by IR, time of flight or stereo, visual SLAM
light, texture, heavy computing
1.2 Three families of methods
Filtering: Kalman filter (linear), extended Kalman filter (EKF), complementary filter, unscented Kalman filter (UKF), invariant Kalman filter, particle filter. Recursive and fast: the subject of this course.
Nonlinear optimisation: maximum a posteriori over a window of past states (Bayesian networks, factor graphs, iSAM with incremental updates): the standard of visual-inertial and GNSS-inertial-vision fusion.
Learning: model-free, data-driven (deep networks, LSTM), for example to estimate depth or to correct the drift of an IMU.
1.3 What makes it hard in practice
Calibration: biases that change with time and temperature, misalignment between IMU and camera.
Observability: can the sensors really tell us every component of the state? (a compass alone never gives the position).
Asynchronous sampling: an IMU at 400 Hz, a GNSS at 5 Hz, a camera at 30 Hz with a delay.
Resilience: detect a faulty sensor, switch, keep running (fault tolerance).
Try the sensors first
The sensor test bench shows the drift of a gyro, the noise of an accelerometer and the errors of a GNSS receiver live: the same imperfections this course will fuse away.
Key terms
data fusion
state estimation
redundancy
IMU
UWB: TOF, AOA, TDOA
observability
asynchronous sampling
The essentials
Fusion = several imperfect sensors + a model of motion → one estimate and its uncertainty.
Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.
Level 1 · Beginner1
An IMU runs at 400 Hz, a GNSS at 5 Hz. How many IMU samples between two GNSS fixes?
Solution
400 / 5 = 80: the filter predicts 80 times between two corrections.
Level 1 · Beginner2
Which sensor measures gravity plus the own acceleration?
The accelerometer
The gyroscope
The magnetometer
Solution
The accelerometer: that is why it gives the tilt when the robot is still.
Level 2 · Intermediate3
A gyro bias of 0.1 °/s is integrated for 10 minutes. Heading error (°)?
Solution
0.1 × 600 = 60°: why a gyro must be fused with an absolute heading.
Check yourself
Why does a robot need several sensors for the same quantity?
Each one has weak points (drift, noise, blind spots); combined they are better and one failure does not blind the robot (redundancy).
The projection of gravity plus the own acceleration on its axes, in the body frame.
2
Random vectors, covariance and confidence ellipses
25 min
You will learn
mean and covariance of random vectors, whiteness, the properties of covariance matrices, the confidence ellipse and the χ² law, and how a linear map transforms a covariance: Γy = A Γx Aᵀ + Γα.
In one sentence
A covariance matrix says how much each component of an uncertain vector varies, and how the components vary together; it draws an ellipse of uncertainty.
2.1 Mean, variations, covariance
For random vectors x ∈ ℝⁿ and y ∈ ℝᵐ, the means are x̄ = E(x), ȳ = E(y) and the variations x̃ = x − x̄, ỹ = y − ȳ. The covariance matrix is the mean of the products of the variations:
On the diagonal of Γx: the variances σᵢ² of each component. Off the diagonal: the covariances, which say if two components tend to move together. A vector is white if its components are independent: Γx is then diagonal. In Matlab or Python: subtract the mean of the samples, then average the products (G_xy = mean(xtilde .* ytilde)).
Uncorrelated is not independent
Points on a ring (x = ρ sin θ, y = ρ cos θ) have a zero covariance, yet x and y are strongly linked: knowing x gives two possible y. The covariance only sees linear links.
2.2 Properties of a covariance matrix
It is symmetric and positive: its eigenvalues are real and ≥ 0.
Decomposition: Γ = R D Rᵀ, R a rotation (the eigenvectors), D diagonal (the eigenvalues).
Square root: Γ½ = R D½ Rᵀ, itself a covariance matrix.
Order: Γ₁ ≤ Γ₂ means Γ₂ − Γ₁ is positive: Γ₁ is “more precise” in every direction.
2.3 The confidence ellipse
For a Gaussian vector w of mean w̄ and covariance Γw, the set (w − w̄)ᵀ Γw⁻¹ (w − w̄) ≤ a² is an ellipse: the image of the unit disk by w = w̄ + a Γw½ s. The quantity sᵀs follows a χ² law with 2 degrees of freedom, so the probability to be inside is η = 1 − e−a²/2, hence:
a = √(−2 ln(1 − η)) η = 90 % → a = 2.15 η = 95 % → a = 2.45 η = 99 % → a = 3.03
2.4 How a linear map moves the uncertainty
If y = A x + α + b, with A and b known, x and α independent and α centred, then:
ȳ = A x̄ + b Γy = A Γx Aᵀ + Γα
This single line is the heart of the prediction step of the Kalman filter. It also tells how to generate any Gaussian vector: take a white unit vector s (x̄ = 0, Γ = I), then y = Γy½ s + ȳ has the mean ȳ and the covariance Γy.
Worked example
x has Γx = I (σ = 1 on each axis) and y = A x with A = [2 0 ; 0 1]. Then Γy = A I Aᵀ = [4 0 ; 0 1]: the standard deviation of y₁ is 2. With A a rotation of 45°, Γy = I: a circle stays a circle when it turns.
Dashed: the uncertainty of x (σ = 1 in every direction). In colour: the uncertainty of y = A x, Γy = A Γx Aᵀ. A matrix stretches, turns and tilts the uncertainty exactly as it moves the points.
Key terms
random vector
covariance matrix
white vector
eigenvalues, eigenvectors
confidence ellipse
χ² law
Γy = A Γx Aᵀ + Γα
The essentials
Γx = E((x − x̄)(x − x̄)ᵀ): symmetric, positive; Γ = R D Rᵀ (eigenvectors, eigenvalues).
Confidence ellipse: half-axes a√λᵢ along the eigenvectors, a = √(−2 ln(1 − η)) in 2D.
y = A x + α + b ⇒ ȳ = A x̄ + b, Γy = A Γx Aᵀ + Γα.
Worked exercises
Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.
Level 1 · Beginner1
Value of a for a 95 % ellipse in 2D?
Solution
a = √(−2 ln 0.05) ≈ 2.45.
Level 2 · Intermediate2
Γ = [4 0 ; 0 1], η = 90 % (a = 2.15). Length of the long half-axis?
Solution
a √λ₁ = 2.15 × √4 = 4.3.
Level 3 · Professional3
y = A x + α with A = [1 1 ; 0 1], Γx = I, Γα = 0.5 I. First diagonal term of Γy?
Hint
A Aᵀ = [2 1 ; 1 1].
Solution
A I Aᵀ = [2 1 ; 1 1], plus 0.5 I: 2.5.
Check yourself
What does a zero covariance between two components mean, and what does it not mean?
No linear link; it does not mean independence (the ring example).
Which a gives a 99 % ellipse in 2D?
a = √(−2 ln 0.01) ≈ 3.03.
y = 3x + α with Γx = 2 and Γα = 1. Γy?
3 × 2 × 3 + 1 = 19.
3
The best linear estimator: unbiased and orthogonal
25 min
You will learn
what an unbiased orthogonal estimator is, why it is unique and the best of all linear estimators, the five formulas for y = C x + β, and two worked examples: a DC motor and an over-determined linear system.
In one sentence
Knowing y, the best linear guess of x moves the prior guess x̄ in the direction of the surprise y − ȳ, with a gain K = Γxy Γy⁻¹ that weighs how much y really tells about x.
3.1 Unbiased and orthogonal
A linear estimator of x from y is x̂ = K y + b. Its error is ε = x̂ − x. It is unbiased if E(ε) = 0 (no systematic error), orthogonal if E(ε ỹᵀ) = 0 (the error has nothing left in common with the measurement: everything y could tell has been used).
x̂ = x̄ + K (y − ȳ) K = Γxy Γy⁻¹ Γε = Γx − K Γyx
Proof in three lines: unbiased ⇒ b = x̄ − K ȳ, so ε = K ỹ − x̃; orthogonal ⇒ E((K ỹ − x̃) ỹᵀ) = K Γy − Γxy = 0 ⇒ K = Γxy Γy⁻¹. And it is the best: any other gain K₀ + Δ adds the positive term Δ Γy Δᵀ to the error covariance.
3.2 The case y = C x + β
When the measurement is a linear function of x plus a centred noise β uncorrelated with x, Γxy = Γx Cᵀ and Γy = C Γx Cᵀ + Γβ. The five formulas to remember:
Formula
Name
(i)
x̂ = x̄ + K ỹ
estimate
(ii)
Γε = Γx − K C Γx
error covariance
(iii)
ỹ = y − C x̄
innovation
(iv)
Γy = C Γx Cᵀ + Γβ
innovation covariance
(v)
K = Γx Cᵀ Γy⁻¹
Kalman gain
Worked example: the DC motor
The speed obeys Ω = x₁ U + x₂ Tr (U voltage, Tr load torque). Five tests give (U, Tr, Ω) = (4, 0, 5), (10, 1, 10), (10, 5, 8), (13, 5, 14), (15, 3, 17); measurement variance 9; a priori x ≈ (1, −1) with variance 4. Each row of C is (U, Tr). The formulas give x̂ = (1.21, −0.58) and Γε = [0.061 −0.166 ; −0.166 0.598]: x₁ is known within ±0.25, x₂ only within ±0.77 (the tests vary Tr little).
Worked example: three equations, two unknowns
2x₁ + 3x₂ = 8, 3x₁ + 2x₂ = 7, x₁ − x₂ = 0, the first one twice as accurate (Γβ = diag(1, 4, 4)), and a vague prior x̄ = 0, Γx = 1000 I. The estimator makes a weighted compromise: x̂ = (1.311, 1.755), Γε = [0.728 −0.515 ; −0.515 0.462]. It is weighted least squares, with an uncertainty.
Key terms
linear estimator
unbiased
orthogonal
innovation
Kalman gain
error covariance
weighted least squares
The essentials
x̂ = x̄ + K (y − ȳ), K = Γxy Γy⁻¹, Γε = Γx − K Γyx: unique, unbiased, orthogonal, the best linear estimator.
For y = C x + β: ỹ = y − C x̄, Γy = C Γx Cᵀ + Γβ, K = Γx Cᵀ Γy⁻¹, Γε = Γx − K C Γx.
Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.
Level 1 · Beginner1
Scalar: prior x̄ = 10, Γx = 9, measurement y = 16 of x with Γβ = 9 (C = 1). Estimate x̂?
Solution
K = 9 / 18 = 0.5, x̂ = 10 + 0.5 × 6 = 13.
Level 2 · Intermediate2
Same, with Γβ = 1 (a precise sensor). Estimate x̂?
Solution
K = 9 / 10 = 0.9, x̂ = 10 + 0.9 × 6 = 15.4: closer to the precise measurement.
Level 3 · Professional3
In the DC motor example, why is x₂ less precise than x₁?
The load torque varies little in the tests, so the data say little about x₂
x₂ is negative
The prior on x₂ is better
Solution
Tr ∈ [0, 5] while U ∈ [4, 15]: the columns of C weigh x₁ much more.
Check yourself
What does “orthogonal” mean for an estimator?
The error is uncorrelated with the measurement: E(ε ỹᵀ) = 0, all the information of y has been used.
Write the Kalman gain for y = C x + β.
K = Γx Cᵀ (C Γx Cᵀ + Γβ)⁻¹.
Scalar case: Γx = 4, C = 1, Γβ = 4. K and Γε?
K = 4 / 8 = 0.5, Γε = 4 − 0.5 × 4 = 2: halfway between prior and measurement, half the variance.
4
The Kalman filter: predict, then correct
25 min
You will learn
the state model, the two steps of the filter and their seven equations, what the filter stores, its code in a few lines, and why it gives the same result as the batch estimator on the DC motor.
In one sentence
The Kalman filter applies the best linear estimator again and again: the model predicts where the state goes (and the uncertainty grows), then each measurement corrects it (and the uncertainty shrinks).
4.1 The model
xk+1 = Ak xk + uk + αk yk = Ck xk + βk
αk (process noise, covariance Γα: what the model ignores) and βk (measurement noise, Γβ) are Gaussian, independent of each other and white in time (independent from one instant to the next). x̂k|k−1 reads “the estimate of x at time k knowing the measurements up to k − 1”.
Step
Equation
Name
Correction
ỹₖ = yₖ − Cₖ x̂ₖ|ₖ₋₁
innovation
Sₖ = Cₖ Γₖ|ₖ₋₁ Cₖᵀ + Γβ
innovation covariance
Kₖ = Γₖ|ₖ₋₁ Cₖᵀ Sₖ⁻¹
Kalman gain
x̂ₖ|ₖ = x̂ₖ|ₖ₋₁ + Kₖ ỹₖ
corrected estimate
Γₖ|ₖ = (I − Kₖ Cₖ) Γₖ|ₖ₋₁
corrected covariance
Prediction
x̂ₖ₊₁|ₖ = Aₖ x̂ₖ|ₖ + uₖ
predicted estimate
Γₖ₊₁|ₖ = Aₖ Γₖ|ₖ Aₖᵀ + Γα
predicted covariance
4.2 The code
The filter only stores x̂k+1|k and Γk+1|k; everything else is computed on the fly. The same function in Matlab (as in the course) and in Python:
function [x1,G1]=kalman(x0,G0,u,y,G_alpha,G_beta,A,C)
S=C*G0*C'+G_beta; K=G0*C'*inv(S); y_tilde=y-C*x0;
xup=x0+K*y_tilde; Gup=G0-K*C*G0; % correction
x1=A*xup+u; G1=A*Gup*A'+G_alpha; % prediction
end
import numpy as np
def kalman(x0, G0, u, y, Ga, Gb, A, C):
S = C @ G0 @ C.T + Gb
K = G0 @ C.T @ np.linalg.inv(S)
xup = x0 + K @ (y - C @ x0)
Gup = (np.eye(len(x0)) - K @ C) @ G0
return A @ xup + u, A @ Gup @ A.T + Ga
The DC motor, one measurement at a time
Take A = I, u = 0, Γα = 0 (the parameters do not change) and Ck = (U(k), Tr(k)): feeding the five tests one by one gives exactly the result of the batch estimator of lesson 3. With Γα = 0 and A = I, the Kalman filter is the recursive form of the linear estimator. Use the lab of lesson 3, button “Add the next measurement”, to see it.
A numerical safeguard
With rounding errors Γk|k can lose its positivity. A more robust form (Joseph form) is Γk|k = (I − K C) Γ (I − K C)ᵀ + K Γβ Kᵀ, always symmetric positive.
Key terms
state model
process noise Γα
measurement noise Γβ
prediction, correction
innovation covariance
white in time
Joseph form
The essentials
Model: xk+1 = A xk + u + α, y = C x + β, noises white, Gaussian, independent.
Correction: ỹ, S, K, x̂ ← x̂ + K ỹ, Γ ← (I − K C) Γ. Prediction: x̂ ← A x̂ + u, Γ ← A Γ Aᵀ + Γα.
With A = I, Γα = 0 the filter is the recursive form of the batch estimator.
Worked exercises
Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.
A position-speed state x = (p, v), step Δt = 0.1 s. Matrix A?
[1 0.1 ; 0 1]
[1 0 ; 0.1 1]
[0.1 1 ; 0 1]
Solution
p⁺ = p + Δt v, v⁺ = v: A = [1 Δt ; 0 1].
Check yourself
What happens to the uncertainty in the prediction step, and why?
It grows: Γ = A Γ Aᵀ + Γα adds what the model ignores.
What does the filter keep from one step to the next?
Only the predicted estimate x̂ₖ₊₁|ₖ and its covariance Γₖ₊₁|ₖ.
Scalar filter: predicted variance 3, measurement variance 1. Gain and corrected variance?
K = 3 / 4 = 0.75; Γ = (1 − 0.75) × 3 = 0.75.
5
The asymptotic filter: tuning Γα and Γβ
20 min
You will learn
the steady state of the Kalman filter on the temperature of a room, the formulas of Γ∞ and K∞, what happens when Γα or Γβ goes to zero, how to tune a filter, the whiteness of the innovation and the 99 % confidence ellipsoid.
In one sentence
After a while the gain of a Kalman filter stops changing: it settles on a value that only depends on the ratio between how fast the state moves (Γα) and how noisy the sensor is (Γβ).
5.1 The temperature of a room
xk+1 = xk + αk yk = xk + βk
Here A = C = 1. One step of the filter (correction then prediction) gives the recursion of the predicted variance:
the temperature does not move: the filter ends up ignoring new measurements and averages all of them
Γβ → 0
Γ∞ → Γα, K∞ → 1
the thermometer is perfect: the filter copies the measurement
Γα = Γβ
Γ∞ = 1.618 Γα, K∞ = 0.618
a balanced compromise… and the golden ratio!
5.2 Tuning a filter in practice
Γβ comes from the datasheet or from a test: leave the sensor still and compute the variance of its readings.
Γα is the honest price of the simplifications of the model; it is the real tuning knob: too small → the filter is slow and can diverge if the model is wrong; too large → it follows the noise.
Check: the innovation ỹk of a well-tuned filter is white (no correlation in time) with covariance Sk; the normalised innovation ỹᵀ S⁻¹ ỹ should average the size of y.
A 99 % confidence ellipsoid
At time k the state is inside {x : (x − x̂k|k)ᵀ Γk|k⁻¹ (x − x̂k|k) ≤ a²} with a² the 99 % quantile of the χ² law with n degrees of freedom: 9.21 for n = 2, 11.34 for n = 3. In 2D, a = √(−2 ln 0.01) = 3.03.
Γα → 0: K → 0 (average); Γβ → 0: K → 1 (copy); Γα = Γβ: K = 0.618.
Tune Γβ from the sensor, Γα as the price of the model; check that the innovation is white.
Worked exercises
Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.
Level 2 · Intermediate1
Γα = 2, Γβ = 4. Γ∞?
Solution
(2 + √(4 + 32)) / 2 = (2 + 6) / 2 = 4.
Level 2 · Intermediate2
Same case: K∞?
Solution
4 / (4 + 4) = 0.5.
Level 3 · Professional3
Γα = Γβ = 1. Precision of the corrected estimate Γ∞Γβ / (Γ∞ + Γβ)?
Solution
Γ∞ = 1.618: 1.618 / 2.618 = 0.618 (the golden ratio again).
Check yourself
Γα = 1, Γβ = 2. Γ∞ and K∞?
Γ∞ = (1 + √(1 + 8)) / 2 = 2, K∞ = 2 / 4 = 0.5.
Your filter follows every jump of a noisy sensor. Which knob, and which way?
Lower Γα (or raise Γβ): the gain drops, the filter trusts the model more.
How can you check that a filter is well tuned?
Its innovation must be white with the covariance S predicted by the filter.
6
The extended Kalman filter (EKF)
25 min
You will learn
how to apply Kalman to a nonlinear model by linearising it around the estimate, the equations of the EKF, the example of the simple pendulum seen by a gyrometer, and why the EKF is no longer optimal.
In one sentence
Real models are curved; the EKF replaces the curve by its tangent at the current estimate and runs the ordinary Kalman filter on it, step after step.
6.1 Linearise around the estimate
xk+1 = f(xk, uk) + αk yk = g(xk) + βk
Near x̂, f(x) ≈ f(x̂) + A (x − x̂) and g(x) ≈ g(x̂) + C (x − x̂), with the Jacobians Ak = ∂f/∂x at (x̂k|k, uk) and Ck = ∂g/∂x at x̂k|k−1. The linear filter applied to this tangent model simplifies into:
Notice: the estimate uses the true nonlinear functions f and g; only the covariances use the Jacobians.
6.2 Example: the simple pendulum
In normalised form, x₁ is the angle and x₂ the rotation speed: ẋ₁ = x₂, ẋ₂ = −sin x₁ + u (u known). A gyrometer measures x₂ every 0.01 s with a noise σ = 0.1 rad/s. Euler’s method (δ = 0.01 s) gives the discrete model and its Jacobian:
x₁⁺ = x₁ + δ x₂ x₂⁺ = x₂ + δ(−sin x₁ + u) A = [1 δ ; −δ cos x̂₁ 1] C = [0 1] Γβ = 0.01
The gyrometer never measures the angle, yet the filter finds it: the dynamics link them (the acceleration −sin x₁ depends on the angle). We say the angle is observable through the model.
Is the EKF still the best unbiased orthogonal estimator?
No. The linearisation is an approximation: the estimate can be biased, the covariance can be too optimistic, and if the initial error is large (outside the zone where the tangent is a good copy), the filter can diverge. Remedies: a good initialisation, a larger Γα, the unscented filter (UKF) or a particle filter for strong nonlinearities.
Key terms
extended Kalman filter (EKF)
linearisation
Jacobian
Euler discretisation
observable state
divergence
UKF, particle filter
The essentials
EKF: predict with f, correct with g; covariances with the Jacobians A = ∂f/∂x, C = ∂g/∂x at the estimate.
Pendulum: A = [1 δ ; −δ cos x̂₁ 1], C = [0 1]: the angle is found from the gyro through the dynamics.
Not optimal any more: bias, optimistic covariance, divergence if the initial error is large.
Worked exercises
Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.
Level 2 · Intermediate1
Pendulum, δ = 0.01, x̂₁ = 0. Lower-left term of A?
Solution
−δ cos 0 = −0.01.
Level 2 · Intermediate2
g(x) = x² measured near x̂ = 3. Jacobian C?
Solution
dg/dx = 2x = 6.
Level 3 · Professional3
What does the EKF use to compute the predicted estimate?
The true nonlinear f(x̂, u)
A x̂ only
The measurement
Solution
x̂ₖ₊₁|ₖ = f(x̂ₖ|ₖ, uₖ); A is only used for the covariance.
Check yourself
In the EKF, where are the Jacobians used, and where the true functions?
True f and g for the estimate and the innovation; Jacobians A and C for the covariances and the gain.
Pendulum: derivative of x₂ + δ(−sin x₁ + u) with respect to x₁?
−δ cos x₁.
Why can an EKF diverge?
If the error is too large, the tangent is a bad copy of the model: the gain and covariance are wrong and the error grows.
7
Localising a robot by multilateration (UWB)
25 min
You will learn
the kinematic model of a mobile robot in discrete time, the distance measurement to a beacon and its Jacobian, the data needed to run the EKF, and why the heading becomes observable when the robot moves.
In one sentence
Beacons at known places measure their distance to the robot; the EKF mixes these distances with the wheel speeds to know the position and the heading at every instant.
7.1 The model
The robot (x, y, θ) moves with a known translation speed u and rotation speed ω: ẋ = u cos θ, ẏ = u sin θ, θ̇ = ω. With Euler’s method and the step Δt:
xk+1 = xk + Δt uk cos θk yk+1 = yk + Δt uk sin θk θk+1 = θk + Δt ωk
Ak = [1 0 −Δt u sin θ̂ ; 0 1 Δt u cos θ̂ ; 0 0 1]
7.2 The measurement
A UWB anchor Bi = (xbi, ybi) measures the time of flight, hence the distance, every 20 ms with a variance of 25·10⁻⁴ m² (σ = 5 cm):
di = √((x − xbi)² + (y − ybi)²) Ci = [ (x̂ − xbi)/d̂i (ŷ − ybi)/d̂i 0 ]
The row Ci is the unit vector from the beacon to the robot: a distance only corrects the position along this line. Its last term is 0: a distance says nothing directly about θ. Yet θ is observable through the motion: if θ is wrong, the predicted positions drift sideways and the distances correct them, which corrects θ through the correlations of Γ.
Data needed to run the EKF
Here
positions of the beacons
measured once, precisely
inputs u, ω and their noise
from the wheel encoders → Γα
measurement variance
Γβ = 25·10⁻⁴ m² per distance
step Δt
20 ms
initial x̂₀ and Γ₀
a rough guess with a large Γ₀
Process the distances one by one
When the noises of the beacons are independent, the three distances can be used as three successive scalar corrections: no matrix inversion, and a beacon that drops out is simply skipped. It is how the lab works.
Key terms
multilateration
time of flight (TOF)
UWB anchor
unicycle model
measurement Jacobian
sequential correction
The essentials
Unicycle: x⁺ = x + Δt u cos θ, y⁺ = y + Δt u sin θ, θ⁺ = θ + Δt ω.
Distance to beacon i: C = ((x̂ − xᵢ)/d̂, (ŷ − yᵢ)/d̂, 0): corrects along the line beacon → robot.
θ is observable through the motion; 3 non-aligned beacons fix the position.
Worked exercises
Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.
Level 1 · Beginner1
UWB at 20 ms. Measurements per second per beacon?
Solution
1 / 0.02 = 50.
Level 2 · Intermediate2
Variance 25·10⁻⁴ m². Standard deviation in cm?
Solution
√(25·10⁻⁴) = 0.05 m = 5 cm.
Level 2 · Intermediate3
Robot estimated at (6, 8), beacon at (0, 0). First term of the row C?
Solution
d̂ = 10, (6 − 0) / 10 = 0.6.
Check yourself
How many distances do you need to fix a position in the plane, and why?
Three (not aligned): one gives a circle, two give two points, three remove the ambiguity.
Robot at (3, 4), beacon at (0, 0). Row C of this distance?
d = 5, C = (0.6, 0.8, 0).
Distances do not contain θ. How does the filter find the heading?
Through the motion: a wrong θ makes the predicted path drift; the distance corrections propagate to θ through the covariance.
8
Multimodal fusion: several sensors, several rates
25 min
You will learn
how to fuse a compass, angulation, TDOA and odometry, the measurement equations and Jacobians of each, which modality sees which part of the state, how to handle sensors that do not work at the same rate, and centralised against distributed fusion.
In one sentence
Each sensor gives a partial view; the filter predicts at the rate of the fastest source and adds every measurement at the moment it arrives, so that together they see the whole state.
8.1 The three modalities
The robot follows xk+1 = xk + u cos θ, yk+1 = yk + u sin θ, θk+1 = θk + v (u, v from the odometry every 200 ms, not perfectly known: add a process noise). Four beacons: B₁ (−10, −10), B₂ (10, −10), B₃ (10, 10), B₄ (−10, 10) m.
Modality
Measures
Every
Variance
Row of C
Sees
M · compass (IMU)
θ
200 ms
4·10⁻⁴ rad²
(0, 0, 1)
the heading only
B · angulation
bearing of beacon l: γ = atan2(yl − y, xl − x) − θ
600 ms
3.8·10⁻² rad²
(Δy/q, −Δx/q, −1)
position and heading (≥ 2 beacons)
T · TDOA
Δd(i, j) = d(M, Bᵢ) − d(M, Bⱼ)
400 ms
10⁻² m²
difference of the two unit vectors, 0
the position only (≥ 3 beacons)
(Δx, Δy = beacon − robot, q = Δx² + Δy². TDOA needs no clock on the robot: only the difference of the times of arrival counts, which is why it is used with UWB and GNSS.)
8.2 Different rates: predict at the base rate, correct when it arrives
Choose a base step (here 200 ms, the rate of the odometry) and predict at every step.
At each step, correct with every measurement that arrived during the step (compass every step, TDOA every 2 steps, angulation every 3 steps), one after the other.
If a measurement arrives late (a camera with 100 ms of processing), correct the state of the moment it was taken (keep a short history), or at least add its delay to its noise.
8.3 Centralised or distributed
In a centralised filter (the lab), every raw measurement enters one filter: optimal, but everything depends on one computer. In a distributed implementation, each modality runs its own local filter; a fusion centre combines the local estimates. For two independent estimates (x₁, Γ₁) and (x₂, Γ₂) of the same state:
Γ = (Γ₁⁻¹ + Γ₂⁻¹)⁻¹ x̂ = Γ (Γ₁⁻¹ x₁ + Γ₂⁻¹ x₂)
Beware of the common information
The local filters share the same odometry, so their errors are correlated: the formula above would then be too optimistic. Fusion centres use the information form with the common prediction removed, or the covariance intersection, which stays safe when the correlation is unknown.
Key terms
multimodal fusion
angulation (angle of arrival)
TDOA
asynchronous measurements
centralised, distributed fusion
covariance intersection
The essentials
Compass sees θ; angulation sees x, y, θ; TDOA sees x, y; odometry predicts.
Different rates: predict at the base rate, correct with each measurement when it arrives.
Distributed fusion: Γ = (Γ₁⁻¹ + Γ₂⁻¹)⁻¹ if independent; otherwise remove the common part or use covariance intersection.
Worked exercises
Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.
Level 1 · Beginner1
Base step 200 ms, angulation every 600 ms. One angulation every how many steps?
Solution
600 / 200 = 3.
Level 2 · Intermediate2
Fuse two independent estimates: x₁ = 10 (variance 1) and x₂ = 13 (variance 2). Fused x̂?
Only the compass is on. What happens to the position uncertainty?
It grows without limit: the position is not observed
It stays constant
It goes to zero
Solution
The compass corrects θ only; the position integrates the odometry errors.
Check yourself
Which modality alone recovers the whole state (x, y, θ)?
Angulation (bearings relative to the robot, at least 2 beacons); the compass gives θ only, TDOA the position only.
Odometry every 200 ms, TDOA every 400 ms: when do you correct with the TDOA?
Every second prediction step, right after the prediction of that step.
Two independent estimates of the same quantity, variances 4 and 4. Fused variance?
(1/4 + 1/4)⁻¹ = 2.
Glossary
All the words of the course in one place.
Term
Meaning
Data fusion
Combining several sources (sensors, models) into one better estimate.
Covariance matrix
Γ = E((x − x̄)(x − x̄)ᵀ): the variances on the diagonal, the joint variations off it.
Confidence ellipse
The region that contains the state with a given probability; axes = eigenvectors of Γ.
Unbiased orthogonal estimator
x̂ = x̄ + Γxy Γy⁻¹ (y − ȳ): the best linear estimator.
Innovation
The surprise of a measurement: ỹ = y − C x̂.
Kalman gain K
K = Γ Cᵀ S⁻¹: how much of the innovation is used to correct the estimate.
Process noise Γα
What the model of motion ignores; the main tuning knob.
Measurement noise Γβ
The variance of the sensor errors.
Asymptotic Kalman filter
The filter once its gain and covariance have stopped changing.
Extended Kalman filter (EKF)
The Kalman filter applied to a nonlinear model linearised around the estimate.
Observability
Whether the measurements, through the model, allow every component of the state to be found.
Multilateration
Finding a position from distances to known points.
TDOA
Time difference of arrival: a difference of distances to two beacons.
Covariance intersection
A safe way to fuse two estimates whose correlation is unknown.
Sources and references
This course was written from these books, papers, standards and documentation. They are also the best way to go further.
Course materials
N. Ramdani, Data fusion for autonomous navigation, parts A and B and tutorials, Master MARS, Université d’Orléans.
Part B is based on the course of L. Jaulin, ENSTA Bretagne (KalMOOC).
References
R. E. Kalman, “A new approach to linear filtering and prediction problems”, Journal of Basic Engineering, 82(1), 1960.used for:the Kalman filter
L. Jaulin, Mobile Robotics, 2nd ed., ISTE / Wiley, 2019 (French: La robotique mobile, ISTE, 2015).used for:the course follows its notations and its labs (covariance, best estimator, EKF)
S. Thrun, W. Burgard, D. Fox, Probabilistic Robotics, MIT Press, 2005.used for:probabilistic estimation and the EKF
You can now build the estimator of a real robot!
Next: robot_localization in ROS 2 (an EKF and a UKF ready to use), the book Probabilistic Robotics (Thrun, Burgard, Fox), and the SLAM lesson of the perception course.