HoloLib
High-performance holonomic (X-Drive) control library for VEX V5
Loading...
Searching...
No Matches
encoder_filter.h
Go to the documentation of this file.
1#pragma once
2
3#include "Eigen/Core"
4#include "Eigen/Dense"
5
6/**
7 * @brief Standard 1D Kalman filter for smoothing raw motor encoder values.
8 */
10public:
11 /**
12 * @brief Construct an Encoder Kalman Filter.
13 *
14 * @param process_noise Estimated variability of the process.
15 * @param measurement_noise Noise characteristics of the encoder.
16 */
17 EncoderKalmanFilter(float process_noise = 0.077f,
18 float measurement_noise = 7.2f);
19
20 /**
21 * @brief Updates the filter with a new measurement.
22 *
23 * @param measured_position The raw encoder position.
24 * @param dt Time elapsed since last update.
25 * @return float The filtered/smoothed position.
26 */
27 float update(float measured_position, float dt);
28
29private:
30 Eigen::Vector2f x;
31 Eigen::Matrix2f P, Q;
32 Eigen::RowVector2f H;
33 float R;
34};
Standard 1D Kalman filter for smoothing raw motor encoder values.
float update(float measured_position, float dt)
Updates the filter with a new measurement.
EncoderKalmanFilter(float process_noise=0.077f, float measurement_noise=7.2f)
Construct an Encoder Kalman Filter.