I have a fuel sensor installed in a lorry fuel tank. The sensor measures the current fuel level (in percentage) of the tank. However, due to the fact that the fuel is sloshing in the tank, the fuel level fluctuates wildly — sometimes more than 10%.
I decided to use Kalman filter to predict the actual fuel level, using the following model:
F(k+1) = F(k) - C C = fuel consumed between k and k+1, which is estimated using the distance travelled between k and k+1 (measured using GPS), and the average fuel efficiency (fixed) of the lorry (e.g. 35 L/100km).
So far, Kalman filter works perfectly when the lorry is moving and consuming its fuel. However, it fails when 2 events happened that are not captured by the model:
- refuel (large increase in fuel level in a short span of time)
- fuel theft (large decrease in fuel level in a short span of time)
You can see an example below, on the left side of the graph, where a huge drop in fuel level (most probably due to fuel theft) and a huge increase in fuel level (due to refuel) are smoothed out by Kalman filter, thus the information are lost. On the right side of the graph, where the lorry is moving and consuming fuel, the prediction works well.
So my question is, how do I smooth the fluctuations of the fuel level, and at the same time, capture refuel and fuel theft events? Any ideas? Maybe use something else other than Kalman filter?