|
quater_ikf
|
#include <Ikf.hpp>
Public Member Functions | |
| ~Ikf () | |
| void | Init (const Eigen::Matrix< _Scalar, Ikf::IKFSTATEVECTORSIZE, Ikf::IKFSTATEVECTORSIZE > &P_0, const Eigen::Matrix< _Scalar, 3, 3 > &Ra, const Eigen::Matrix< _Scalar, 3, 3 > &Rg, const Eigen::Matrix< _Scalar, 3, 3 > &Rm, const Eigen::Matrix< _Scalar, 3, 3 > &Ri, const Eigen::Matrix< _Scalar, 3, 3 > &Qbg, const Eigen::Matrix< _Scalar, 3, 3 > &Qba, const Eigen::Matrix< _Scalar, 3, 3 > &Qbi, double g, double alpha, unsigned int am1, unsigned int am2, double agamma, unsigned int im1, unsigned int im2, double igamma) |
| This function Initialize the vectors and matrix of the IKF. More... | |
| void | predict (Eigen::Matrix< _Scalar, 3, 1 > &u, double dt) |
| Performs the prediction step of the filter. More... | |
| void | update (const Eigen::Matrix< _Scalar, 3, 1 > &acc, bool acc_on) |
| void | update (const Eigen::Matrix< _Scalar, 3, 1 > &acc, bool acc_on, const Eigen::Matrix< _Scalar, 3, 1 > &measurement, bool measurement_on) |
| void | update (const Eigen::Matrix< _Scalar, 3, 1 > &measurement1, const Eigen::Matrix< _Scalar, 3, 1 > &measurement2) |
| void | update (const Eigen::Matrix< _Scalar, 3, 1 > &acc, bool acc_on, const Eigen::Matrix< _Scalar, 3, 1 > &incl, bool incl_on, const Eigen::Matrix< _Scalar, 3, 1 > &mag, bool magn_on) |
| Performs the measurement and correction steps of the filter. More... | |
| bool | setAttitude (const Eigen::Quaternion< double > &initq) |
| This function Initialize Attitude. More... | |
| void | setState (const Eigen::Matrix< double, IKFSTATEVECTORSIZE, 1 > &x_0) |
| This function Initialize the State vector. More... | |
| bool | setOmega (const Eigen::Matrix< _Scalar, 3, 1 > &u) |
| This function set the initial Omega matrix. More... | |
| void | setInitBias (const Eigen::Matrix< _Scalar, 3, 1 > &gbias, const Eigen::Matrix< _Scalar, 3, 1 > &abias, const Eigen::Matrix< _Scalar, 3, 1 > &ibias) |
| On/Off initial bias. More... | |
| void | setGravity (const double gravity) |
| Initial gravity. More... | |
| void | setCovariance (const Eigen::Matrix< double, Ikf::IKFSTATEVECTORSIZE, Ikf::IKFSTATEVECTORSIZE > &Pk) |
| Set the filter covariance. More... | |
| Eigen::Matrix< double, 3, 1 > | getGyroBias () |
| Gets the current gyroscopes bias. More... | |
| Eigen::Matrix< double, 3, 1 > | getAccBias () |
| Gets the current accelerometers bias. More... | |
| Eigen::Matrix< double, 3, 1 > | getInclBias () |
| Gets the current inclinometers bias. More... | |
| Eigen::Matrix< double, IKFSTATEVECTORSIZE, 1 > | getState () |
| Gets the current state vector of the filter. More... | |
| Eigen::Matrix< _Scalar, 3, 1 > | getGravityinBody () |
| Gets gravity in the IMU body frame. More... | |
| Eigen::Matrix< _Scalar, 3, 1 > | getGravity () const |
| Gets gravity in the local Geographic frame. More... | |
| Eigen::Quaternion< double > | getAttitude () |
| Gets the current orientation in Quaternion. More... | |
| Eigen::Matrix< double, IKFSTATEVECTORSIZE, IKFSTATEVECTORSIZE > | getCovariance () |
| Gets Noise covariance matrix. More... | |
| void | Quaternion2DCM (Eigen::Quaternion< _Scalar > *q, Eigen::Matrix< _Scalar, 3, 3 > *C) |
| Conversion Quaternion to DCM (Direct Cosine Matrix) (Alternative to Eigen) More... | |
Static Public Member Functions | |
| template<typename _MatrixType > | |
| static _MatrixType | guaranteeSPD (const _MatrixType &A) |
| Method to guarantee Semi-Positive Definite (SPD) matrix. More... | |
Static Public Attributes | |
| static const int | flagAcc = static_cast<int>(_Accelerometers) |
| static const int | flagIncl = static_cast<int>(_Inclinometers) |
| static const unsigned int | QUATERNION_SIZE = 4 |
| static const unsigned int | IKFSTATEVECTORSIZE = 6 + (flagAcc*3) + (flagIncl*3) |
Protected Member Functions | |
| void | initAdaptiveAttitude (const unsigned int accM1, const unsigned int accM2, const double accGamma, const unsigned int incM1, const unsigned int incM2, const double incGamma) |
|
inline |
Default Destructor
|
inline |
Gets the current accelerometers bias.
|
inline |
Gets the current orientation in Quaternion.
|
inline |
Gets Noise covariance matrix.
|
inline |
Gets gravity in the local Geographic frame.
|
inline |
Gets gravity in the IMU body frame.
|
inline |
Gets the current gyroscopes bias.
|
inline |
Gets the current inclinometers bias.
|
inline |
Gets the current state vector of the filter.
|
inlinestatic |
Method to guarantee Semi-Positive Definite (SPD) matrix.
Single Value Decomposition
eigenvalues
|
inline |
This function Initialize the vectors and matrix of the IKF.
This method receives the measurement noise matrix of the sensors The theoretical gravity value and the Dip angle of the location.
| [in] | P_0 | Initial state covariance matrix |
| [in] | Ra | measurement noise matrix of Accelerometers. |
| [in] | Rg | measurement noise matrix of Gyroscopes. |
| [in] | Rm | measurement noise matrix of Magnetometers. |
| [in] | Qbg | covariance noise matrix of the gyroscopes bias |
| [in] | Qba | covariance noise matrix of the accelerometers bias |
| [in] | g | local gravitational value. |
| [in] | alpha | Dip angle |
Gravitation acceleration
Dip angle (alpha is in rad)
Kalman filter state, error covariance and process noise covariance
Initial error covariance
Static part of the observation matrices
System matrix A
Initial bias
Default omega matrix
Initial quaternion in Init
Fill matrix Rg, Ra, Rm and Ri
Initialize adaptive object
Print filter information
|
inlineprotected |
|
inline |
Performs the prediction step of the filter.
It computes the discrete version of the matrix A to propagate forward the state vector x. It computes the Q and P matrix as well as the quaternion integration from the input vector u and the delta time.
| [in] | u | vector with the angular velocity |
| [in] | dt | delta time between samples |
< Vector 2 product matrix
< Vec 2 product matrix
< Quaternion integration matrix
< Quaternion integration matrix
< Discrete System matrix
< Discrete Q matrix
Compute the vector2product matrix with the angular velocity
Eliminate the Bias
Compute the dA Matrix
Propagate the vector through the system
Third-order gyroscopes integration accuracy
|
inline |
Conversion Quaternion to DCM (Direct Cosine Matrix) (Alternative to Eigen)
Conversion to a transformation matrix from a quaternion The quaternion is represented in Eigen convention: w+xi+yj+zk, first element the scalar and others three are the vectorial part.
| [in] | *q | pointer to a quaternion vector. |
| [out] | *C | pointer to a matrix. The three by three matrix |
Take the parameters of the quaternion
Create the DCM matrix from the actual quaternion
|
inline |
This function Initialize Attitude.
Initial orientation value beforeestart the IKF
| [in] | *initq | pointer to quaternion with the initial orientation |
Initial orientation
|
inline |
Set the filter covariance.
| [in] | Pk | covariance matrix of appropriate dimension |
|
inline |
Initial gravity.
Set initial gravity. If after initialization a new theoretical or measured gravity is available use this method. Note: always before start running the filter.
| [in] | gravity | initial gravity value |
|
inline |
On/Off initial bias.
Initial On/Off sensor bias. Otherwise the default in Init is set them to zero.
| [in] | gbias | vector with initial gyroscopes bias |
| [in] | abias | vector with initial accelerometers bias |
|
inline |
This function set the initial Omega matrix.
Initial Omega matrix with angular velocity for quaternion integration.
| [in] | *u | pointer to vector with the angular velocity |
Initialization for quaternion integration
|
inline |
This function Initialize the State vector.
The state vector is formed by 9 element. (0-2) -> the vector part of a error quaternion (3-5) -> gyroscope bias estimation (6-8) -> accelerometer bias estimation
| [in] | *x_0 | a initial/desired state vector |
|
inline |
|
inline |
|
inline |
|
inline |
Performs the measurement and correction steps of the filter.
The IKf is based on two measurement step:\
The first measurement step is dynamics. The noise covariamce matrix of the update is dynamic depending on external accelerations felt on the accelerometers. That means the variance noise increase or decrease depending on the external acceleration. Thas is the main different between normal EKF.
The second measurement step only affects the Yaw (heading) angle.
| [in] | acc | pointer to vector with accelerations |
| [in] | magn | pointer to vector with magnetometers |
| [in] | magn_on | boolean value to connect or disconnect the magnetometers correction |
< Vector 2 product matrix
< Measurement noise matrix from accelerometers matrix Ra
< Error covariance matrix for measurement 1
< Error covariance matrix for measurement 2
< Error covariance matrix for measurement 3
< Auxiliar matrix for computing Kalman gain in measurement
< Kalman Gain matrix for measurement 1
< Kalman Gain matrix for measurement 2
< Kalman Gain matrix for measurement 3
< Acceleration covariance matrix
< Inclinometers covariance matrix
< Attitude error quaternion
< Gravitation in the body frame
< Magnetic field in the body frame
< Measurement vector 1 Acc
< Measurement vector 2 Mag
< Measurement vector 3 Incl
< Auxiliar vector variable
Measurement step 1 Acc
First measurement step (Pitch and Roll correction from Acc)
Measurement
The adaptive algorithm
Compute the Kalman Gain Matrix
Update the state vector and the covariance matrix
Update the quaternion with the Indirect approach
This is necessary mainly because after(in the 2 measurement) C(q) is computed
Normalize quaternion
Reset the quaternion part of the state vector
Measurement step 2 Mag
It only updates Yaw angle
Second measurement step
Observation matrix
Measurement vector
Compute Kalman Gain
Update the state vector and the covariance matrix
Update the quaternion with the Indirect approach
Normalize quaternion
Reset the quaternion part of the state vector
Measurement step 3 Inclinometers
Measurement step (Pitch and Roll correction from Inclinometers)
Measurement
The adaptive algorithm
Compute the Kalman Gain Matrix
Update the state vector and the covariance matrix
Update the quaternion with the Indirect approach
This is necessary mainly because after(in the 2 measurement) C(q) is computed
Normalize quaternion
Reset the quaternion part of the state vector
Reset the rest of the state
Guarantee SPD Covariance matrix
|
static |
Convert bool to int is standard in C++
|
static |
|
static |
|
static |
Constants definitions
1.8.6