okapi::EKFFilter class

Base classes

class Filter

Constructors, destructors, conversion operators

EKFFilter(double iQ = 0.0001, double iR = ipow(0.2, 2)) explicit
One dimensional extended Kalman filter.

Public functions

auto filter(double ireading) -> double override
Filters a value, like a sensor reading.
auto filter(double ireading, double icontrol) -> double virtual
Filters a reading with a control input.
auto getOutput() const -> double override
Returns the previous output from filter.

Protected variables

const double Q
const double R
double xHat
double xHatPrev
double xHatMinus
double P
double Pprev
double Pminus
double K

Function documentation

okapi::EKFFilter::EKFFilter(double iQ = 0.0001, double iR = ipow(0.2, 2)) explicit

One dimensional extended Kalman filter.

Parameters
iQ process noise covariance
iR measurement noise covariance

The default arguments should work fine for most signal filtering. It won't hurt to graph your signal and the filtered result, and check if the filter is doing its job.

Q is the covariance of the process noise and R is the covariance of the observation noise. The default values for Q and R should be a modest balance between trust in the sensor and FIR filtering.

Think of R as how noisy your sensor is. Its value can be found mathematically by computing the standard deviation of your sensor reading vs. "truth" (of course, "truth" is still an estimate; try to calibrate your robot in a controlled setting where you can minimize the error in what "truth" is).

Think of Q as how noisy your model is. It decides how much "smoothing" the filter does and how far it lags behind the true signal. This parameter is most often used as a "tuning" parameter to adjust the response of the filter.

double okapi::EKFFilter::filter(double ireading) override

Filters a value, like a sensor reading.

Parameters
ireading new measurement
Returns filtered result

Assumes the control input is zero.

double okapi::EKFFilter::filter(double ireading, double icontrol) virtual

Filters a reading with a control input.

Parameters
ireading new measurement
icontrol control input
Returns filtered result

double okapi::EKFFilter::getOutput() const override

Returns the previous output from filter.

Returns the previous output from filter