LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
okapi::EKFFilter Class Reference

#include <ekfFilter.hpp>

Inheritance diagram for okapi::EKFFilter:
okapi::Filter

Public Member Functions

 EKFFilter (double iQ=0.0001, double iR=ipow(0.2, 2))
 One dimensional extended Kalman filter.
 
double filter (double ireading) override
 Filters a value, like a sensor reading.
 
virtual double filter (double ireading, double icontrol)
 Filters a reading with a control input.
 
double getOutput () const override
 Returns the previous output from filter.
 
- Public Member Functions inherited from okapi::Filter
virtual ~Filter ()
 

Protected Attributes

const double Q
 
const double R
 
double xHat = 0
 
double xHatPrev = 0
 
double xHatMinus = 0
 
double P = 0
 
double Pprev = 1
 
double Pminus = 0
 
double K = 0
 

Detailed Description

Definition at line 12 of file ekfFilter.hpp.

Constructor & Destructor Documentation

◆ EKFFilter()

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

One dimensional extended Kalman filter.

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.

Parameters
iQprocess noise covariance
iRmeasurement noise covariance

Member Function Documentation

◆ filter() [1/2]

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

Filters a value, like a sensor reading.

Assumes the control input is zero.

Parameters
ireadingnew measurement
Returns
filtered result

Implements okapi::Filter.

◆ filter() [2/2]

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

Filters a reading with a control input.

Parameters
ireadingnew measurement
icontrolcontrol input
Returns
filtered result

◆ getOutput()

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

Returns the previous output from filter.

Returns
the previous output from filter

Implements okapi::Filter.

Member Data Documentation

◆ K

double okapi::EKFFilter::K = 0
protected

Definition at line 69 of file ekfFilter.hpp.

◆ P

double okapi::EKFFilter::P = 0
protected

Definition at line 66 of file ekfFilter.hpp.

◆ Pminus

double okapi::EKFFilter::Pminus = 0
protected

Definition at line 68 of file ekfFilter.hpp.

◆ Pprev

double okapi::EKFFilter::Pprev = 1
protected

Definition at line 67 of file ekfFilter.hpp.

◆ Q

const double okapi::EKFFilter::Q
protected

Definition at line 62 of file ekfFilter.hpp.

◆ R

const double okapi::EKFFilter::R
protected

Definition at line 62 of file ekfFilter.hpp.

◆ xHat

double okapi::EKFFilter::xHat = 0
protected

Definition at line 63 of file ekfFilter.hpp.

◆ xHatMinus

double okapi::EKFFilter::xHatMinus = 0
protected

Definition at line 65 of file ekfFilter.hpp.

◆ xHatPrev

double okapi::EKFFilter::xHatPrev = 0
protected

Definition at line 64 of file ekfFilter.hpp.


The documentation for this class was generated from the following file: