-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrientation.h
45 lines (38 loc) · 1.9 KB
/
Orientation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Author: AndreasKel
//---------------------------------------------------------------------------------------------
//license: MIT
//file name: Orientation.h
//language: C++
//environment: Mingw-w64
//functionality: filters to estimate orientation using quaternions
//==============================================================================================
#include "MatrixAlgebra.h"
class cOrientation: public cMatrixAlgebra
{
public:
cOrientation(float cycleTime);
~cOrientation();
struct retQuatArray{//If we return address of a local variable (pointer to an array) is not advised as local variables may not exist in memory after function call is over.
float qw;
float qx;
float qy;
float qz;
};
void setQquaternion(float Q_quaternion);
void setQquatbias(float Q_quatBias);
void setR(float R);
void setElapsedTime(float elapsedTime);
retQuatArray KalmanFilter(float accX, float accY, float accZ, float gyroX, float gyroY, float gyroZ);
retQuatArray KalmanFilterBias(float accX, float accY, float accZ, float gyroX, float gyroY, float gyroZ);
retQuatArray ComplementaryFilter(float accX, float accY, float accZ, float gyroX, float gyroY, float gyroZ);
protected:
cMatrixAlgebra setRotationMatrix(float quatStates[]);
cMatrixAlgebra setJacobianMatrix(float quatStatesOLD[], float refState[]);
float* QuatMultiplication(float quaternion1[], float quaternion2[]);
private:
vector<vector<float> > Qxk; //states matrix
vector<vector<float> > Pkp; //error covariance matrix
float _R, _Q_quaternion, _Q_quatBias; //variances
float _elapsedTime; //Execution cycle in units of second
float _alpha; //ratio of how much we trust accelerometer in complementary filter only
};