A recursive linear FIR or IIR filter. Filters are of the form: y[n] = (b0*x[n] + b1*x[n-1] + ... + bN*x[n-N]) - (a0*y[n-1] + a2*y[n-2] + ... + aM*y[n-M]) y[n] is the sample of the output signal at time n x[n] is the sample of the input signal at time n y[n-1] is the output from the last time step x[n-1] is the input from the last time step b0 to bN are the feedforward gains a0 to aM are the feedback gains.
More...
#include <LinearFilter.h>
|
| LinearFilter (std::vector< double > ffGains, std::vector< double > fbGains) |
| Creates a linear filter.
|
|
double | Update (double input) |
| Calculates the next value of the filter output. Must be called periodically.
|
|
void | Reset () |
| Resets the values of the filter.
|
|
A recursive linear FIR or IIR filter. Filters are of the form: y[n] = (b0*x[n] + b1*x[n-1] + ... + bN*x[n-N]) - (a0*y[n-1] + a2*y[n-2] + ... + aM*y[n-M]) y[n] is the sample of the output signal at time n x[n] is the sample of the input signal at time n y[n-1] is the output from the last time step x[n-1] is the input from the last time step b0 to bN are the feedforward gains a0 to aM are the feedback gains.
LinearFilter::LinearFilter |
( |
std::vector< double > |
ffGains, |
|
|
std::vector< double > |
fbGains |
|
) |
| |
Creates a linear filter.
- Parameters
-
ffGains | the feedforward gains |
fbGains | the feedback gains |
LinearFilter * LinearFilter::MovingAverageFilter |
( |
int |
samples | ) |
|
|
static |
Creates a moving average FIR filter.
- Parameters
-
samples | the number of samples to average |
- Returns
- the created filter
LinearFilter * LinearFilter::PIDController |
( |
double |
Kp, |
|
|
double |
Ki, |
|
|
double |
Kd |
|
) |
| |
|
static |
Creates a PID controller filter of the form y[n] = y[n-1] + (Kp+Ki+Kd)*x[n] + (-Kp-2*Kd)*x[n-1] + Kd*x[n-2].
- Parameters
-
Kp | the proportional gain |
Ki | the integral gain |
Kd | the derivative gain |
- Returns
- the created filter
LinearFilter * LinearFilter::SinglePoleIIRHighPassFilter |
( |
double |
decay | ) |
|
|
static |
Creates a single pole IIR high-pass filter.
- Parameters
-
decay | the gain of the filter, between 0 and 1 (decay constant) |
- Returns
- the created filter
LinearFilter * LinearFilter::SinglePoleIIRLowPassFilter |
( |
double |
decay | ) |
|
|
static |
Creates a single pole IIR low-pass filter.
- Parameters
-
decay | the gain of the filter, between 0 and 1 (decay constant) |
- Returns
- the created filter
double LinearFilter::Update |
( |
double |
input | ) |
|
Calculates the next value of the filter output. Must be called periodically.
- Parameters
-
input | the next value of the input signal (error if PID filter) |
- Returns
- the next value of the output signal
The documentation for this class was generated from the following files: