test

Dependencies:   mbed

Committer:
siwakon
Date:
Mon Dec 05 14:47:17 2016 +0000
Revision:
0:dd400e4fe461
asdasdasd

Who changed what in which revision?

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