A Kalman filter combines predictions from a model and measurements to give an estimate of the true system state.
More...
|
| SteadyStateKalmanFilter (LinearSystem< States, Inputs, Outputs > &plant, const StateArray &stateStdDevs, const OutputArray &measurementStdDevs, units::second_t dt) |
| Constructs a steady-state Kalman filter with the given plant.
|
|
| SteadyStateKalmanFilter (SteadyStateKalmanFilter &&)=default |
|
SteadyStateKalmanFilter & | operator= (SteadyStateKalmanFilter &&)=default |
|
const Matrixd< States, Outputs > & | K () const |
| Returns the steady-state Kalman gain matrix K.
|
|
double | K (int i, int j) const |
| Returns an element of the steady-state Kalman gain matrix K.
|
|
const StateVector & | Xhat () const |
| Returns the state estimate x-hat.
|
|
double | Xhat (int i) const |
| Returns an element of the state estimate x-hat.
|
|
void | SetXhat (const StateVector &xHat) |
| Set initial state estimate x-hat.
|
|
void | SetXhat (int i, double value) |
| Set an element of the initial state estimate x-hat.
|
|
void | Reset () |
| Resets the observer.
|
|
void | Predict (const InputVector &u, units::second_t dt) |
| Project the model into the future with a new control input u.
|
|
void | Correct (const InputVector &u, const OutputVector &y) |
| Correct the state estimate x-hat using the measurements in y.
|
|
template<int States, int Inputs, int Outputs>
class frc::SteadyStateKalmanFilter< States, Inputs, Outputs >
A Kalman filter combines predictions from a model and measurements to give an estimate of the true system state.
This is useful because many states cannot be measured directly as a result of sensor noise, or because the state is "hidden".
Kalman filters use a K gain matrix to determine whether to trust the model or measurements more. Kalman filter theory uses statistics to compute an optimal K gain which minimizes the sum of squares error in the state estimate. This K gain is used to correct the state estimate by some amount of the difference between the actual measurements and the measurements predicted by the model.
This class assumes predict() and correct() are called in pairs, so the Kalman gain converges to a steady-state value. If they aren't, use KalmanFilter instead.
For more on the underlying math, read https://file.tavsys.net/control/controls-engineering-in-frc.pdf chapter 9 "Stochastic control theory".
- Template Parameters
-
States | Number of states. |
Inputs | Number of inputs. |
Outputs | Number of outputs. |