#include <IIRFilter.h>
Public Member Functions | |
double | executeFilter (double input) |
Execute filtering, this method will be obsolated. | |
void | getParameter (int &dim, std::vector< double > &A, std::vector< double > &B) |
IIRFilter (const std::string &error_prefix="") | |
Constructor. | |
IIRFilter (unsigned int dim, std::vector< double > &fb_coeffs, std::vector< double > &ff_coeffs, const std::string &error_prefix="") | |
Constructor, this constructure will be obsolated. | |
double | passFilter (double input) |
passFilter | |
void | reset (double initial_input=0.0) |
bool | setParameter (int dim, std::vector< double > &A, std::vector< double > &B) |
Set parameters Y[n] = B[0] * X[n] + B[1] * X[n-1] + ... + B[dim] * X[n-dim] - A[1] * Y[n-1] ... - A[dim] * Y[n-dim] A[0] would be 1.0. | |
bool | setParameterAsBiquad (const double f_cutoff, const double Q, const double hz) |
Simple user interface of setParameter. | |
~IIRFilter () | |
Destructor. | |
Private Attributes | |
int | m_dimension |
std::string | m_error_prefix |
std::vector< double > | m_fb_coefficients |
std::vector< double > | m_ff_coefficients |
bool | m_initialized |
std::deque< double > | m_previous_values |
Infinite Impulse Filter y[n] = sum(0, dim, ff_coeffs[i] * x[n - i]) + sum(1, dim, fb_coeffs[i] * y[n - i])
Definition at line 24 of file TorqueFilter/IIRFilter.h.
IIRFilter::IIRFilter | ( | const std::string & | error_prefix = "" | ) |
Constructor.
Definition at line 28 of file TorqueFilter/IIRFilter.cpp.
IIRFilter::IIRFilter | ( | unsigned int | dim, |
std::vector< double > & | fb_coeffs, | ||
std::vector< double > & | ff_coeffs, | ||
const std::string & | error_prefix = "" |
||
) |
Constructor, this constructure will be obsolated.
dim | dimension of the filter |
fb_coeffs | coeeficients of feedback |
ff_coeffs | coefficients of feedforward |
Definition at line 4 of file TorqueFilter/IIRFilter.cpp.
IIRFilter::~IIRFilter | ( | ) | [inline] |
Destructor.
Definition at line 41 of file TorqueFilter/IIRFilter.h.
double IIRFilter::executeFilter | ( | double | input | ) | [inline] |
Execute filtering, this method will be obsolated.
Definition at line 73 of file TorqueFilter/IIRFilter.h.
void IIRFilter::getParameter | ( | int & | dim, |
std::vector< double > & | A, | ||
std::vector< double > & | B | ||
) |
Definition at line 84 of file TorqueFilter/IIRFilter.cpp.
double IIRFilter::passFilter | ( | double | input | ) |
passFilter
Definition at line 110 of file TorqueFilter/IIRFilter.cpp.
void IIRFilter::reset | ( | double | initial_input = 0.0 | ) |
Definition at line 100 of file TorqueFilter/IIRFilter.cpp.
bool IIRFilter::setParameter | ( | int | dim, |
std::vector< double > & | A, | ||
std::vector< double > & | B | ||
) |
Set parameters Y[n] = B[0] * X[n] + B[1] * X[n-1] + ... + B[dim] * X[n-dim] - A[1] * Y[n-1] ... - A[dim] * Y[n-dim] A[0] would be 1.0.
How to generete parameter by octave butterworth filter (dimension = 2, cutoff_freq = 8Hz) [B, A] = butter(2, 2 * 0.004 * 8) ;;; dimension=2, 2 * dt * cutoff_freq
Definition at line 33 of file TorqueFilter/IIRFilter.cpp.
bool IIRFilter::setParameterAsBiquad | ( | const double | f_cutoff, |
const double | Q, | ||
const double | hz | ||
) |
Simple user interface of setParameter.
f_cutoff | cut off frequency |
Q | quality factor: 1/2 = no overshoot, 1/sqrt(2) = Butterworth |
hz | sampling rate |
Definition at line 69 of file TorqueFilter/IIRFilter.cpp.
int IIRFilter::m_dimension [private] |
Definition at line 85 of file TorqueFilter/IIRFilter.h.
std::string IIRFilter::m_error_prefix [private] |
Definition at line 91 of file TorqueFilter/IIRFilter.h.
std::vector<double> IIRFilter::m_fb_coefficients [private] |
Definition at line 86 of file TorqueFilter/IIRFilter.h.
std::vector<double> IIRFilter::m_ff_coefficients [private] |
Definition at line 87 of file TorqueFilter/IIRFilter.h.
bool IIRFilter::m_initialized [private] |
Definition at line 90 of file TorqueFilter/IIRFilter.h.
std::deque<double> IIRFilter::m_previous_values [private] |
Definition at line 88 of file TorqueFilter/IIRFilter.h.