Robot State Estimation and Sensor Fusion
Robots never directly observe their true physical state; they infer it by fusing noisy, asynchronous, and biased sensor streams through dynamic models. Sensor fusion combines fast, drifting odometry with slower, absolute corrections to bound uncertainty.
Why Does This Exist?
If you ask a robot where it is, no single sensor can tell the truth. Wheel encoders measure wheel rotations with microsecond precision, but when the wheels slip on dusty concrete, the encoders claim the robot moved forward while it remained stationary. An inertial measurement unit (IMU) reports accelerations at , but integrating raw accelerometer signals twice to compute position drifts into kilometers of error within seconds due to temperature bias. A camera or LiDAR can recognize landmarks accurately, but operates at only to and suffers from motion blur.
State estimation is the mathematical machinery that turns these flawed, asynchronous, and noisy observations into an optimal, continuous estimate of physical state (such as 3D position, velocity, orientation, and sensor bias).
The core insight is Bayesian sensor fusion: instead of trusting any single instrument, the robot maintains a probability distribution over its state. It uses high-frequency motion models to predict state evolution, then uses incoming measurements to pull the estimate toward reality while shrinking its uncertainty.
Basics first: the general mathematical derivation of optimal linear filtering lives in kalman-filters. Building dense 3D geometry from camera depth lives in robot-perception-geometry. Using state estimates to track paths lives in robot-feedback-control.
Think of It Like This
Navigating a sailboat in dense fog with a knotmeter and a lighthouse
Imagine helming a sailboat through a thick fog bank toward a harbor entrance. You have two sources of information:
- A water knotmeter and compass on your helm that measure boat speed through the water and heading continuously.
- An occasional brief flash from a distant coastal lighthouse through the fog.
If you rely only on the knotmeter, ocean cross-currents and rudder drift slowly push you off course. Every minute without an external reference expands your circle of uncertainty on the chart.
Suddenly, the lighthouse flashes through the fog. That single bearing measurement has some optical uncertainty, but it provides an absolute anchor to the physical earth. You combine your running dead-reckoning estimate with the lighthouse flash: you adjust your helm position toward the lighthouse line of sight, and your circle of uncertainty snaps back down to a tight, confident radius.
Where it stops: a human navigator uses judgment and sea charts. A robotic state estimator executes rigorous matrix algebra at hundreds of Hertz, simultaneously tracking physical position while continuously estimating the sensor's own internal drift and bias parameters.
How It Actually Works
The predict-update cycle
State estimation models physical reality as a discrete stochastic state-space system:
- State vector : The true physical state (e.g. ).
- Process model: , where is process noise with covariance .
- Measurement model: , where is measurement noise with covariance .
The filter alternates between two steps:
-
Predict (Time Propagation): High-frequency IMU and wheel odometry propagate the state forward in time. Because process noise is added at every step, the covariance (uncertainty) grows:
-
Update (Measurement Correction): When an exteroceptive measurement arrives (e.g. a camera landmark or LiDAR scan), the filter computes the Kalman Gain , which balances prior uncertainty against measurement noise :
The state is corrected using the innovation residual :
The uncertainty shrinks:
Worked example: 1D sensor fusion of odometry and external fix
Consider a mobile delivery base moving along a 1D corridor:
- Prior estimate from wheel odometry: .
- Prior variance: (standard deviation ).
- External landmark measurement from LiDAR: .
- Measurement noise variance: (standard deviation ).
Compute the Kalman gain :
Compute the corrected posterior state estimate :
Compute the updated posterior variance :
Compute the new standard deviation :
Because the external measurement is four times more precise than the prior ( versus ), the Kalman gain weights the measurement heavily (). The resulting posterior estimate () has an uncertainty () that is strictly smaller than either the odometry prior () or the raw measurement alone ().
Code
This Python snippet implements the 1D Kalman update equations, verifies the numerical result, and demonstrates how unmodeled wheel slip degrades state estimation.
def kalman_update_1d( x_prior: float, var_prior: float, measurement: float, var_meas: float,) -> tuple[float, float, float, float]: """Perform 1D scalar Bayesian update of state and variance.""" k_gain: float = var_prior / (var_prior + var_meas) x_post: float = x_prior + k_gain * (measurement - x_prior) var_post: float = (1.0 - k_gain) * var_prior std_post: float = var_post ** 0.5 return round(k_gain, 3), round(x_post, 3), round(var_post, 4), round(std_post, 4)
k, x_fused, var_fused, std_fused = kalman_update_1d( x_prior=1.00, var_prior=0.04, measurement=1.10, var_meas=0.01,)
print(k) # -> 0.8print(x_fused) # -> 1.08print(var_fused) # -> 0.008print(std_fused) # -> 0.0894Watch Out For
Overconfident process noise tuning leading to filter divergence
If you tune the filter's process noise covariance too small, you are mathematically telling the estimator that the motion model is nearly perfect. Over time, the calculated covariance shrinks toward zero.
Once is infinitesimally small, the Kalman Gain drops to zero: the filter stops listening to real incoming measurements. If the robot hits a slick patch of floor or collides with an obstacle, the filter stubbornly reports smooth motion along the planned path while the physical hardware sits stalled against a wall. Fix it by keeping realistically conservative and injecting noise during wheel slip.
Ignoring sensor timestamp latency and asynchronous arrival
In real robot middleware (such as ROS 2), sensor packets arrive over Ethernet or USB with variable delay: an IMU message from ago might arrive after a camera frame captured ago.
If an estimator naively applies measurement updates in the order packets arrive at the CPU, it updates current state with past observations, corrupting the covariance matrix and inducing severe ringing. Fix it by maintaining a fixed-lag buffer of historical states, rolling the filter state back to the measurement's timestamp, applying the update, and re-propagating forward.
The Quick Version
- Robots infer internal and external physical state by fusing noisy, multi-rate, and drifting sensors through dynamic models.
- The predict-update cycle propagates state forward with high-rate odometry and IMU, then corrects state and shrinks uncertainty with external fixes.
- Kalman gain automatically weights the measurement relative to the prior: higher sensor precision yields a higher gain and larger state correction.
- Fusing a prior at (variance ) with a landmark fix at (variance ) produces a posterior at with variance .
- Estimators must explicitly estimate sensor biases (such as gyro drift) and manage asynchronous packet arrival times to avoid filter divergence.