wbc
wbc::LowPassFilter Class Reference

#include <filter.hpp>

Public Member Functions

 LowPassFilter (double cutoff_freq, double sample_time)
const Eigen::VectorXd & apply (const Eigen::VectorXd &new_value)
void reset ()

Protected Attributes

double alpha_
bool initialized_
Eigen::VectorXd y_

Detailed Description

First order (exponential) low-pass filter for vector-valued signals:

\[ y_k = \alpha x_k + (1 - \alpha) y_{k-1}, \qquad \alpha = \frac{\Delta t}{\Delta t + \frac{1}{2\pi f_c}} \]

The filter state is initialized with the first input sample, so there is no transient from zero.

Constructor & Destructor Documentation

◆ LowPassFilter()

wbc::LowPassFilter::LowPassFilter ( double cutoff_freq,
double sample_time )
Parameters
cutoff_freqCutoff frequency \(f_c\) in Hz. Has to be > 0.
sample_timeTime \(\Delta t\) in seconds between two consecutive calls of apply(). Has to be > 0.

Member Function Documentation

◆ apply()

const Eigen::VectorXd & wbc::LowPassFilter::apply ( const Eigen::VectorXd & new_value)

Add a new sample and return the filtered signal

◆ reset()

void wbc::LowPassFilter::reset ( )
inline

Re-initialize the filter state with the next input sample

Member Data Documentation

◆ alpha_

double wbc::LowPassFilter::alpha_
protected

◆ initialized_

bool wbc::LowPassFilter::initialized_
protected

◆ y_

Eigen::VectorXd wbc::LowPassFilter::y_
protected

The documentation for this class was generated from the following files: