01 · Sense · Free
Sensor fusion with a Kalman filter
Wheels are smooth but drift; GPS never drifts but jumps. Blend them into something better than either.
true pathwheels onlyGPS fixesKalman filterorange ring = uncertainty (2σ)
mean error · wheels only
0.0 m
mean error · GPS fixes
0.0 m
mean error · Kalman filter
0.0 m
What's going on
A robot knows where it is from two sources. Wheel odometry says how far it moved; a little slip adds up to drift. GPS gives a position every second, but each fix is metres off. A Kalman filter keeps one best guess and how sure it is, and decides moment by moment which source to trust more.
Picture it like this
Like walking through a mall counting steps and glancing at signs now and then. Right after a sign you're sure; after a long walk without one you start to doubt. When the next sign comes you adjust, but only a little if the sign is smudged.
On real robots
Every robot that moves does this: delivery robots, drones, humanoids blending an IMU with joint readings. The same idea fuses cameras with lidar. The hard part on real robots is knowing how wrong each sensor can be; set that wrong and the filter becomes overconfident.
For engineers: what this filter computes
State per axis x = [position, wheel bias]. Predict: p ← p + (v_odo − b)·dt and P ← F P Fᵀ + Q.
Update on a GPS fix: K = P Hᵀ (H P Hᵀ + R)⁻¹ with H = [1, 0]. K says how far to move toward the fix, and the same miss teaches the filter the wheels' bias.
“Trust” scales Q from 1/100 to 100×: small Q means trusting the motion model. R = (GPS error)², so a noisier GPS is trusted less.