# Kalman Filter

This content aims to deliver a simple example of the use of the Kalman Filter without mentioning complex mathematics, further linking to the battery state estimation problems.

Imagine that we are pilots in a manual aircraft flying in a one-dimension direction, delivering a box of medicines to a tiny island in the middle of the sea.

Assume that we start at time T_init, from position X_init. You have an airspeed gauge, a relatively accurate stopwatch, and a localisation device accurate to 100ft and measures every 5 minutes.
Question: How could we accurately estimate our exact position during the travel so that we won’t miss the drop-off point and drop the box of medicines into the sea?

Solution 1: Airspeed Gauge Method (Figure 2a)
We could predict the aircraft’s relative position via the integral of the measured speed over travelling time, but the error also accumulates as time increases. In other words, the variance (average of the summed squares of errors) is high over time and the state predictions are prone to drift.

Solution 2: Localisation Method (Figure 2b)
Periodically measuring noisy locations, this method makes it difficult to define the exact point to drop-off.

Solution 3: Kalman filter method (Figure 2c)
Combining solution 1 and solution 2, calibrate the estimations at each localisation sampling point and start the further estimates from the latest point.

The information (including uncertainty) from the predictions and measurements are combined to provide the best possible estimate of the aircraft’s position. The general stage flow of the Kalman Filter is presented in Figure 3 below.

But how could the Kalman Filter cope with the uncertainties in the prediction and measurement?
Kalman Gain calculates a weighted average of the predicted state and the measurement and dynamically adapts to the systems based on the relative uncertainties. If the prediction is more certain (smaller variance), it gives more weight to the prediction; inversely, if the measurement is more reliable (smaller measurement noise), it relies more on the measurement.

How do the mentioned examples link to the state estimation problem (e.g. State of Charge estimation) in batteries?
We could form the state vector in the battery state estimation problem by initialising the battery SoC and related battery dynamic model parameters (e.g. Equivalent Circuit Model parameters). Next, we utilize a battery model and predict the next system state based on the current state predictions and system input (current).

The measurement of battery voltage (or OCV) and current was then taken, and the Kalman Gain struck a balance between the predicted state (from the model) and noisy measurements. By adjusting the weights, the Kalman Gain optimally combines both sources of information. Finally, an updated SOC was calculated where the error was minimised.

To be noticed, the general Kalman Filter requires the system dynamics and measurement models to be linear and witness poor performance in estimating nonlinear system states. By comparison, the Extended Kalman Filter linearizes the prediction step via partial derivatives (Jacobian matrix) to suit nonlinear systems. It provides robust state estimates even in the presence of uncertainties and nonlinearities.

#### References

1. Understanding the Basis of the Kalman Filter Via a Simple and Intuitive Derivation, IEEE Signal Processing Magazine ( Volume: 29, Issue: 5, September 2012), DOI: 10.1109/MSP.2012.2203621.

Categories BMS