9 #include "vulp/exceptions/FilterError.h"
13 using vulp::exceptions::FilterError;
25 double new_input,
double dt) {
27 if (cutoff_period <= 2.0 * dt) {
29 std::string(
"[low_pass_filter] Cutoff period ") +
30 std::to_string(cutoff_period) +
31 " s is less than 2 * dt = " + std::to_string(2.0 * dt) +
32 " s, causing information loss (Nyquist–Shannon sampling theorem)";
33 throw FilterError(message);
37 const double alpha = dt / cutoff_period;
38 return prev_output + alpha * (new_input - prev_output);
double low_pass_filter(double prev_output, double cutoff_period, double new_input, double dt)
Low-pass filter as an inline function.