Thomas Piacentini
← Workshop

03 / 15 · 60–90 min

Recover motion.

Where is the robot between two uncertain measurements?

Choose a laboratory
Check my intuition

01 · Predict

Before changing the settings.

Scalar correction: predicted position 2 m, variance P = 4 m². The measurement is 7 m with R = 1 m². With K = P / (P + R), what is the corrected position?

A hint

K = 4 / 5. The correction adds K times the measurement–prediction difference.

02 · Experiment and compare

Put the model to the test.

-5.00.0-1.51.52.03.05.54.59.06.0Position (m)Time (s)
Dots: measurements · dashed: true position · solid: Kalman · band: computed uncertainty.

6.0 s. True position: 7.20 m. Estimate: 6.41 ± 0.79 m (95 %). K = 0.08.

Measurement RMSE
1.53 m
Filter RMSE
0.75 m
Estimated velocity
1.37 m/s
Compare A and B →

Read values as a table
t (s)Measured (m)True (m)Estimated (m)
0.10-1.270.07-0.85
0.20-0.240.14-0.61
0.30-2.370.21-1.16
0.40-1.320.28-1.24
0.50-0.390.35-1.05
0.602.140.42-0.23
0.700.110.49-0.06
0.80-1.960.56-0.46
0.90-0.300.63-0.39
1.00-3.890.70-1.23
1.101.560.77-0.60
1.202.240.840.08
1.303.020.910.83
1.401.520.981.11
1.502.601.051.56
1.602.561.121.93
1.701.801.192.08
1.80-0.751.261.72
1.904.731.332.40
2.000.161.402.18
2.100.041.471.96
2.200.721.541.89
2.302.301.612.06
2.402.141.682.19
2.501.161.752.15
2.600.111.821.97
2.701.461.891.99
2.802.421.962.13
2.901.602.032.15
3.002.412.102.27
3.105.102.182.70
3.200.282.262.51
3.303.482.362.72
3.401.872.482.71
3.502.512.602.78
3.603.242.742.92
3.703.582.883.08
3.805.923.043.47
3.904.513.223.68
4.001.813.403.60
4.101.893.593.53
4.203.513.783.62
4.301.893.973.55
4.403.884.163.67
4.504.474.353.83
4.602.804.543.82
4.706.494.734.15
4.804.464.924.28
4.905.915.114.52
5.002.295.304.42
5.106.095.494.66
5.205.825.684.86
5.305.515.875.02
5.403.996.065.04
5.504.756.255.11
5.606.996.445.37
5.707.656.635.67
5.807.376.825.93
5.908.317.016.24
6.006.687.206.41
Understand the calculations

03 · Connect the diagram to calculations

The numbers behind motion.

The state contains position and velocity. The filter predicts constant velocity; the simulated robot accelerates between 3 and 4 s, then between 6 and 7.2 s. The filter does not know these accelerations.

x = [position, velocity]ᵀ ; Δt = 0.1 s
F = [[1, Δt], [0, 1]] ; H = [1, 0]
Q = q × [[Δt⁴/4, Δt³/2], [Δt³/2, Δt²]]
R = (assumed noise)²
K = P⁻Hᵀ / (H P⁻ Hᵀ + R)
x̂ = x̂⁻ + K(z − H x̂⁻)

Q represents random acceleration constant within each step and independent across steps. The ±1.96 σ band is model-predicted uncertainty, not a guarantee under unmodelled accelerations. RMSE is the square root of the mean squared error over displayed time steps.

A few lines to reconstruct
gain = predicted_variance / (predicted_variance + measurement_variance)
corrected = prediction + gain * (measurement - prediction)

The notebook provides one function per laboratory, hand-calculated examples and tests. Exercises isolate components; these pages run the complete simulations.

Keep an observation

04 · Record

What changed?

Compare two settings. Record the effect, your explanation and a case where the model might fail. Saving keeps the current settings and seed, not a certification of competence.

Open my notebook →

atomsh / lab