LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
ekfFilter.hpp
Go to the documentation of this file.
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6#pragma once
7
10
11namespace okapi {
12class EKFFilter : public Filter {
13 public:
35 explicit EKFFilter(double iQ = 0.0001, double iR = ipow(0.2, 2));
36
43 double filter(double ireading) override;
44
52 virtual double filter(double ireading, double icontrol);
53
59 double getOutput() const override;
60
61 protected:
62 const double Q, R;
63 double xHat = 0;
64 double xHatPrev = 0;
65 double xHatMinus = 0;
66 double P = 0;
67 double Pprev = 1;
68 double Pminus = 0;
69 double K = 0;
70};
71} // namespace okapi
double filter(double ireading) override
Filters a value, like a sensor reading.
EKFFilter(double iQ=0.0001, double iR=ipow(0.2, 2))
One dimensional extended Kalman filter.
double getOutput() const override
Returns the previous output from filter.
const double R
Definition ekfFilter.hpp:62
virtual double filter(double ireading, double icontrol)
Filters a reading with a control input.
const double Q
Definition ekfFilter.hpp:62
constexpr double ipow(const double base, const int expo)
Integer power function.
Definition mathUtil.hpp:122