hahaha

Dependencies:   mbed

Committer:
arthicha
Date:
Tue Dec 06 06:11:54 2016 +0000
Revision:
1:d8ce226c8c2e
;UUpdate;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arthicha 1:d8ce226c8c2e 1 #ifndef _kalman_H
arthicha 1:d8ce226c8c2e 2 #define _kalman_H
arthicha 1:d8ce226c8c2e 3 // derived from http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it/
arthicha 1:d8ce226c8c2e 4 class kalman
arthicha 1:d8ce226c8c2e 5 {
arthicha 1:d8ce226c8c2e 6 public:
arthicha 1:d8ce226c8c2e 7 kalman(void);
arthicha 1:d8ce226c8c2e 8 double getAngle(double newAngle, double newRate, double dt);
arthicha 1:d8ce226c8c2e 9
arthicha 1:d8ce226c8c2e 10 void setAngle(double newAngle);
arthicha 1:d8ce226c8c2e 11 void setQangle(double newQ_angle);
arthicha 1:d8ce226c8c2e 12 void setQgyroBias(double newQ_gyroBias);
arthicha 1:d8ce226c8c2e 13 void setRangle(double newR_angle);
arthicha 1:d8ce226c8c2e 14
arthicha 1:d8ce226c8c2e 15 double getRate(void);
arthicha 1:d8ce226c8c2e 16 double getQangle(void);
arthicha 1:d8ce226c8c2e 17 double getQbias(void);
arthicha 1:d8ce226c8c2e 18 double getRangle(void);
arthicha 1:d8ce226c8c2e 19
arthicha 1:d8ce226c8c2e 20
arthicha 1:d8ce226c8c2e 21 private:
arthicha 1:d8ce226c8c2e 22 double P[2][2]; //error covariance matrix
arthicha 1:d8ce226c8c2e 23 double K[2]; //kalman gain
arthicha 1:d8ce226c8c2e 24 double y; //angle difference
arthicha 1:d8ce226c8c2e 25 double S; //estimation error
arthicha 1:d8ce226c8c2e 26
arthicha 1:d8ce226c8c2e 27 double rate; //rate in deg/s
arthicha 1:d8ce226c8c2e 28 double angle; //kalman angle
arthicha 1:d8ce226c8c2e 29 double bias; //kalman gyro bias
arthicha 1:d8ce226c8c2e 30
arthicha 1:d8ce226c8c2e 31 double Q_angle; //process noise variance for the angle of the accelerometer
arthicha 1:d8ce226c8c2e 32 double Q_gyroBias; //process noise variance for the gyroscope bias
arthicha 1:d8ce226c8c2e 33 double R_angle; //measurement noise variance
arthicha 1:d8ce226c8c2e 34 };
arthicha 1:d8ce226c8c2e 35
arthicha 1:d8ce226c8c2e 36 #endif