|
ESP-IDF Firmware
Firmware architecture and call graph
|
#include <ekf.h>
Public Member Functions | |
| ekf (int x, int w) | |
| virtual | ~ekf () |
| virtual void | Process (float *u, float dt) |
| virtual void | Init ()=0 |
| void | RungeKutta (dspm::Mat &x, float *u, float dt) |
| virtual dspm::Mat | StateXdot (dspm::Mat &x, float *u) |
| virtual void | LinearizeFG (dspm::Mat &x, float *u)=0 |
| virtual void | CovariancePrediction (float dt) |
| virtual void | Update (dspm::Mat &H, float *measured, float *expected, float *R) |
| virtual void | UpdateRef (dspm::Mat &H, float *measured, float *expected, float *R) |
Static Public Member Functions | |
| static dspm::Mat | quat2rotm (float q[4]) |
| static dspm::Mat | rotm2quat (dspm::Mat &R) |
| static dspm::Mat | quat2eul (const float q[4]) |
| static dspm::Mat | eul2rotm (float xyz[3]) |
| static dspm::Mat | rotm2eul (dspm::Mat &rotm) |
| static dspm::Mat | dFdq (dspm::Mat &vector, dspm::Mat &quat) |
| static dspm::Mat | dFdq_inv (dspm::Mat &vector, dspm::Mat &quat) |
| static dspm::Mat | SkewSym4x4 (float *w) |
| static dspm::Mat | qProduct (float *q) |
Data Fields | |
| int | NUMX |
| int | NUMW |
| dspm::Mat & | X |
| dspm::Mat & | F |
| dspm::Mat & | G |
| dspm::Mat & | P |
| dspm::Mat & | Q |
| float * | HP |
| float * | Km |
The ekf is a base class for Extended Kalman Filter. It contains main matrix operations and define the processing flow.
| ekf::ekf | ( | int | x, |
| int | w ) |
Constructor of EKF. THe constructor allocate main memory for the matrixes.
| [in] | x | - amount of states in EKF. x[n] = F*x[n-1] + G*u + W. Size of matrix F |
| [in] | w | - amount of control measurements and noise inputs. Size of matrix G |
Definition at line 19 of file ekf.cpp.
References F, G, HP, Km, NUMW, NUMX, P, Q, X, and x.
Referenced by ekf_imu13states::ekf_imu13states().
|
virtual |
|
virtual |
Calculates covariance prediction matrux P. Update matrix P
| [in] | dt | time interval from last update |
Definition at line 139 of file ekf.cpp.
References dspm::Mat::eye(), F, G, NUMX, P, Q, and dspm::Mat::t().
Referenced by Process().
Df/dq: Derivative of vector by quaternion.
| [in] | vector | input vector |
| [in] | quat | quaternion |
Definition at line 367 of file ekf.cpp.
References dspm::Mat::data.
Df/dq: Derivative of vector by inverted quaternion.
| [in] | vector | input vector |
| [in] | quat | quaternion |
Definition at line 389 of file ekf.cpp.
References dspm::Mat::data.
Referenced by ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurement(), and ekf_imu13states::UpdateRefMeasurementMagn().
|
static |
Convert Euler angels to rotation matrix.
| [in] | xyz | Euler angels |
Definition at line 251 of file ekf.cpp.
Referenced by draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image(), ekf_imu13states::TestFull(), and update_rotation_matrix().
|
pure virtual |
Initialization of EKF. The method should be called befare the first use of the filter.
Implemented in ekf_imu13states.
|
pure virtual |
Calculation of system state matrices F and G
| [in] | x | state vector |
| [in] | u | control measurement |
Implemented in ekf_imu13states.
References x.
Referenced by Process().
|
virtual |
Main processing method of the EKF.
| [in] | u | - input measurements |
| [in] | dt | - time difference from the last call in seconds |
Definition at line 53 of file ekf.cpp.
References CovariancePrediction(), LinearizeFG(), RungeKutta(), and X.
Referenced by ekf_imu13states::TestFull().
|
static |
Make right quaternion-product matrices.
| [in] | q | source quaternion |
Definition at line 112 of file ekf.cpp.
References dspm::Mat::data.
Referenced by ekf_imu13states::LinearizeFG().
|
static |
Convert quaternion to Euler angels.
| [in] | q | quaternion |
Definition at line 230 of file ekf.cpp.
References dspm::Mat::data.
|
static |
Convert quaternion to rotation matrix.
| [in] | q | quaternion |
Definition at line 209 of file ekf.cpp.
Referenced by draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image_task(), draw_3d_image_task(), ekf_imu13states::LinearizeFG(), ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurement(), and ekf_imu13states::UpdateRefMeasurementMagn().
Convert rotation matrix to Euler angels.
| [in] | rotm | rotation matrix |
Definition at line 279 of file ekf.cpp.
References FLT_EPSILON, x, and y.
Referenced by draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image(), draw_3d_image_task(), and draw_3d_image_task().
Convert rotation matrix to quaternion.
| [in] | R | rotation matrix |
Definition at line 305 of file ekf.cpp.
References m, dspm::Mat::norm(), and SIGN().
Referenced by ekf_imu13states::TestFull().
| void ekf::RungeKutta | ( | dspm::Mat & | x, |
| float * | u, | ||
| float | dt ) |
Runge-Kutta state update method. The method calculates derivatives of input vector x and control measurements u
| [in] | x | state vector |
| [in] | u | control measurement |
| [in] | dt | time interval from last update in seconds |
Definition at line 60 of file ekf.cpp.
References StateXdot(), and x.
Referenced by Process().
|
static |
Make skew-symmetric matrix of vector.
| [in] | w | source vector |
Definition at line 81 of file ekf.cpp.
References dspm::Mat::data.
Referenced by ekf_imu13states::LinearizeFG(), and ekf_imu13states::StateXdot().
Derivative of state vector X The default calculation: xDot = F*x + G*u It's possible to implement optimized version
| [in] | x | state vector |
| [in] | u | control measurement |
Reimplemented in ekf_imu13states.
Definition at line 411 of file ekf.cpp.
Referenced by RungeKutta().
|
virtual |
Update of current state by measured values. Optimized method for non correlated values Calculate Kalman gain and update matrix P and vector X.
| [in] | H | derivative matrix |
| [in] | measured | array of measured values |
| [in] | expected | array of expected values |
| [in] | R | measurement noise covariance values |
Definition at line 149 of file ekf.cpp.
References HP, k, Km, m, NUMX, P, dspm::Mat::rows, and X.
Referenced by ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurement(), and ekf_imu13states::UpdateRefMeasurementMagn().
|
virtual |
Update of current state by measured values. This method just as a reference for research purpose. Not used in real calculations.
| [in] | H | derivative matrix |
| [in] | measured | array of measured values |
| [in] | expected | array of expected values |
| [in] | R | measurement noise covariance values |
Definition at line 189 of file ekf.cpp.
References dspm::Mat::eye(), K, NUMX, P, dspm::Mat::pinv(), dspm::Mat::rows, dspm::Mat::t(), and X.
| dspm::Mat& ekf::F |
Linearized system matrices F, where xDot[n] = F*x[n] + G*u + W
Definition at line 78 of file ekf.h.
Referenced by CovariancePrediction(), ekf(), ekf_imu13states::LinearizeFG(), StateXdot(), and ~ekf().
| dspm::Mat& ekf::G |
Linearized system matrices G, where xDot[n] = F*x[n] + G*u + W
Definition at line 82 of file ekf.h.
Referenced by CovariancePrediction(), ekf(), ekf_imu13states::LinearizeFG(), StateXdot(), and ~ekf().
| float* ekf::HP |
| float* ekf::Km |
| int ekf::NUMW |
| int ekf::NUMX |
xDot[n] = F*x[n] + G*u + W Number of states, X is the state vector (size of F matrix)
Definition at line 63 of file ekf.h.
Referenced by CovariancePrediction(), ekf(), ekf_imu13states::StateXdot(), Update(), UpdateRef(), ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurement(), and ekf_imu13states::UpdateRefMeasurementMagn().
| dspm::Mat& ekf::P |
Covariance matrix and state vector
Definition at line 87 of file ekf.h.
Referenced by CovariancePrediction(), ekf(), Update(), UpdateRef(), and ~ekf().
| dspm::Mat& ekf::Q |
Input noise and measurement noise variances
Definition at line 92 of file ekf.h.
Referenced by CovariancePrediction(), ekf(), ekf_imu13states::Init(), and ~ekf().
| dspm::Mat& ekf::X |
System state vector
Definition at line 73 of file ekf.h.
Referenced by ekf(), ekf_imu13states::Init(), Process(), ekf_imu13states::TestFull(), Update(), UpdateRef(), ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurement(), ekf_imu13states::UpdateRefMeasurementMagn(), and ~ekf().