kalman icon indicating copy to clipboard operation
kalman copied to clipboard

Kalman Filter included?

Open MattW86 opened this issue 6 years ago • 3 comments

Hi, Thanks very much for this great library. Just wondering if this library contains regular Kalman filter for linear systems? Cheers

MattW86 avatar Aug 12 '18 13:08 MattW86

There is no dedicated KF implementation, but you can of course use the more general EKF implementation also for linear systems. Just use your state transition matrix as jacobian. I hope this answers your question.

mherb avatar Aug 12 '18 13:08 mherb

Thanks very much for your reply. It would be best if you could give an example. I am pretty new to Kaman filter.

MattW86 avatar Aug 12 '18 22:08 MattW86

@MattW86 You can set up derived classes like the following:

template<...>
class YourSystemModel : public Kalman::LinearizedSystemModel<...>
{
    ...
    // do typedef assignments so that your state type is "S" and control type is "C"
   S f(const S& x, const C& u)
   {
       return this->F*x;
   }
};

template<...>
class YourMeasModel : public Kalman::LinearizedMeasurementModel<...>
{
    ...
    // do a typedef assignment so that your state type is "M"
   M h(const S& x)
   {
       return this->H*x;
   }
}

Note: I have omitted all of the template arguments. Follow the pattern in the examples/Robot1 folder and you should be ok.

You can then use the ExtendedKalmanFilter as a linear kalman filter.

You don't need to call the updateJacobians method inside of your f or h methods because these are called in the predict and update methods of the filters before the calls to f or h.

jwdinius avatar Jun 27 '19 17:06 jwdinius