forked from jarzebski/Arduino-KalmanFilter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKalmanFilter.h
46 lines (35 loc) · 1.08 KB
/
KalmanFilter.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
44
45
46
/*
KalmanFilter.h - Header file for the Kalman Filter
Version: 1.0.0
(c) 2014 Korneliusz Jarzebski
www.jarzebski.pl
This program is free software: you can redistribute it and/or modify
it under the terms of the version 3 GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KalmanFilter_h
#define KalmanFilter_h
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class KalmanFilter
{
public:
KalmanFilter(double angle = 0.001, double bias = 0.003, double measure = 0.03);
double update(double newValue, double newRate);
private:
double Q_angle, Q_bias, R_measure;
double K_angle, K_bias, K_rate;
double P[2][2], K[2];
double S, y;
double dt, kt;
};
#endif