Kalman Filter

An algorithm uses a series of measurements observed over time

Kalman Filter is known as linear quadratic estimation. Simple put, this is a denoise filter.

please read this wiki document for details.

This library has simplified Kalman Filter and constrait to use on float, Vector2, Vector3 and Vector4.

In wiki document, it may be too complicated if you are not familiar to Mathmatics. Basically we use the following values to estimate the result (prediction). What you need is to know the following values:

Q

the covariance of the process noise, default 0.000001

R

the covariance of the observation noise, default 0.001

P

last prediction with R, default 1

K

last prediction

X

last result

Q, R, P should be set on creating a Kalman Filter for your case. You can get the latest result when call Update with current value every cycle. You can also change Q and R on Update, or Update with mulitple values.

private IKalmanFilter<float> _myKalmanFilter;

private void Start()
{
    _myKalmanFilter = KalmanFilter.Builder<float>()
        .WithQ(processNoise)     // optional
        .WithR(observationNoise) // optional
        .WithP(lastPrediction)   // optional
        .Build();
}

private void Update()
{
    var newValue = GetValue();
    var stableValue = myKalmanFilter.Update(newValue);
}            

Last updated