Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
low_pass_filter.cpp
Go to the documentation of this file.
2
3LowPassFilter::LowPassFilter(double alpha, double initial_value)
4 : alpha_(alpha), prev_value_(initial_value) {}
5
6double LowPassFilter::filter(double input) {
7 prev_value_ = alpha_ * input + (1.0 - alpha_) * prev_value_;
8 return prev_value_;
9}
10
11void LowPassFilter::reset(double value) { prev_value_ = value; }
LowPassFilter(double alpha, double initial_value=0.0)
Construct a new Low Pass Filter object.
double filter(double input) override
Apply the low pass filter to a new input.
double prev_value_
Previous filtered value.
double alpha_
Smoothing factor.
void reset(double value=0.0) override
Reset the filter to a specific value.