control//state estimation//sensor fusion
Sensor fusion is the combination of several sensors with different defects into one estimate better than any of them alone, typically a fast sensor that drifts with a slow one that does not, and in practice it is almost always done by a Kalman filter, an extended Kalman filter or a complementary filter. A drone's position comes from an inertial unit that is fast and drifts, a GNSS receiver that is slow and noisy and never drifts, and a barometer for height; a car's driver assistance fuses a camera with a radar, a warehouse robot its wheel odometry with a lidar.
Sensor fusion is the combination of several sensors with different defects into one estimate better than any of them alone, typically a fast sensor that drifts with a slow one that does not, and in practice it is almost always done by a Kalman filter, an extended Kalman filter or a complementary filter. A drone's position comes from an inertial unit that is fast and drifts, a GNSS receiver that is slow and noisy and never drifts, and a barometer for height; a car's driver assistance fuses a camera with a radar, a warehouse robot its wheel odometry with a lidar.
The core is one weighted mean. Two independent altitude readings, a barometer with σ1=0.5\sigma_1=0.5σ1=0.5 m and a GPS with σ2=3\sigma_2=3σ2=3 m, combine best with weights inverse to their variances (inverse-variance weighting):
x^=σ22 y1+σ12 y2σ12+σ22,1σ2=1σ12+1σ22.\hat x=\frac{\sigma_2^2\,y_1+\sigma_1^2\,y_2}{\sigma_1^2+\sigma_2^2},\qquad \frac1{\sigma^2}=\frac1{\sigma_1^2}+\frac1{\sigma_2^2}.x^=σ12+σ22σ22y1+σ12y2,σ21=σ121+σ221.
Information, the inverse of a variance, adds, so the result is always better than the better sensor: here the GPS weighs 2.7 % and the fused altitude has σ=0.49\sigma=0.49σ=0.49 m. The GPS looks superfluous. A barometer drifts with the weather, several metres over a long flight, and the GPS does not; its value is anchoring that slow error, which the filter can only use once the barometer's bias is a state it estimates (state augmentation). A sensor with 2.7 % of the weight in the snapshot carries most of the information about the drift.
Fusing is not averaging.
The plain mean of those two altitudes has σ=120.52+32≈1.5\sigma=\tfrac12\sqrt{0.5^2+3^2}\approx1.5σ=210.52+32<path d="M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z"/>≈1.5 m, three times worse than the barometer alone: averaging a good sensor with a bad one at equal weights spoils the good one. The weights must follow the variances.
The formula assumes independent errors. Two sensors that share a vibration, a power supply, a clock or a correction stream err together, and fusing them as if independent makes the result believe it is more precise than it is (correlated measurements); the worst case is fusing the output of a filter that already used the first sensor.
Over time the same mean is repeated between a prediction and each reading, which is what the Kalman filter is: fusion in one line, run at every step with the prediction as one of the two sensors (Kalman gain).
Real sensors arrive at different rates (multi-rate fusion) and late (delayed measurements), and those two bookkeeping problems cause more errors in the field than the weights. In ROS 2 the usual starting point is the robot_localization package, an EKF or UKF node fed with odometry, IMU and GNSS (ROS 2).