Last active
October 9, 2017 13:51
-
-
Save gusugusu1018/7e9d1c110bddec78d94f5cb09a07ad95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleKalman | |
{ | |
double P, K; | |
double X; | |
public: | |
double Q; | |
double R; | |
SimpleKalman() | |
:P(0.0), X(0.0) | |
{}; | |
double initialize(double first_value) | |
{ | |
X = first_value; | |
return first_value; | |
} | |
double update(double measurement) | |
{ | |
measurementUpdate(); | |
double result = X + (measurement - X) * K; | |
X = result; | |
return result; | |
} | |
private: | |
void measurementUpdate() | |
{ | |
K = (P + Q) / (P + Q + R); | |
P = R * (P + Q) / (R + P + Q); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment