18 #ifndef _IGNITION_FILTER_HH_
19 #define _IGNITION_FILTER_HH_
39 public:
virtual void Set(
const T &_val)
47 public:
virtual void Fc(
double _fc,
double _fs) = 0;
51 public:
virtual const T &
Value()
const
78 public:
virtual void Fc(
double _fc,
double _fs)
94 protected:
double a0 = 0;
97 protected:
double b1 = 0;
157 public:
BiQuad() =
default;
168 public:
void Fc(
double _fc,
double _fs)
170 this->
Fc(_fc, _fs, 0.5);
177 public:
void Fc(
double _fc,
double _fs,
double _q)
179 double k = tan(
IGN_PI * _fc / _fs);
180 double kQuadDenom = k * k + k / _q + 1.0;
181 this->
a0 = k * k/ kQuadDenom;
182 this->
a1 = 2 * this->
a0;
185 this->
b1 = 2 * (k * k - 1.0) / kQuadDenom;
186 this->
b2 = (k * k - k / _q + 1.0) / kQuadDenom;
191 public:
virtual void Set(
const T &_val)
193 this->
y0 = this->
y1 = this->
y2 = this->
x1 = this->
x2 = _val;
201 this->
y0 = this->
a0 * _x +
202 this->
a1 * this->
x1 +
203 this->
a2 * this->
x2 -
204 this->
b1 * this->
y1 -
215 protected:
double a0 = 0,
double b2
Definition: Filter.hh:220
void Fc(double _fc, double _fs)
Set the cutoff frequency and sample rate.
Definition: Filter.hh:168
T x1
Gain of the feedback coefficients.
Definition: Filter.hh:223
Bi-quad filter base class.
Definition: Filter.hh:154
virtual void Set(const T &_val)
Set the current filter's output.
Definition: Filter.hh:191
BiQuad()=default
Constructor.
double b1
Definition: Filter.hh:219
T y1
Definition: Filter.hh:223
BiQuad(double _fc, double _fs)
Constructor.
Definition: Filter.hh:162
BiQuad vector3 filter.
Definition: Filter.hh:228
virtual void Fc(double _fc, double _fs)
Set the cutoff frequency and sample rate.
Definition: Filter.hh:78
T y0
Output.
Definition: Filter.hh:57
const T & Process(const T &_x)
Update the filter's output.
Definition: Filter.hh:87
OnePoleQuaternion()
Constructor.
Definition: Filter.hh:105
double a0
Input gain control coefficients.
Definition: Filter.hh:215
virtual const T & Value() const
Get the output of the filter.
Definition: Filter.hh:51
T x2
Definition: Filter.hh:223
virtual ~Filter()
Destructor.
Definition: Filter.hh:35
static Quaternion< T > Slerp(T _fT, const Quaternion< T > &_rkP, const Quaternion< T > &_rkQ, bool _shortestPath=false)
Spherical linear interpolation between 2 quaternions, given the ends and an interpolation parameter b...
Definition: Quaternion.hh:688
double a2
Definition: Filter.hh:217
void Fc(double _fc, double _fs, double _q)
Set the cutoff frequency, sample rate and Q coefficient.
Definition: Filter.hh:177
BiQuadVector3(double _fc, double _fs)
Constructor.
Definition: Filter.hh:239
OnePoleVector3(double _fc, double _fs)
Constructor.
Definition: Filter.hh:143
OnePole(double _fc, double _fs)
Constructor.
Definition: Filter.hh:72
double a1
Definition: Filter.hh:216
double b0
Definition: Filter.hh:218
OnePoleQuaternion(double _fc, double _fs)
Constructor.
Definition: Filter.hh:113
OnePole()=default
Constructor.
OnePoleVector3()
Constructor.
Definition: Filter.hh:135
T y2
Definition: Filter.hh:223
double b1
Gain of the feedback.
Definition: Filter.hh:97
One-pole quaternion filter.
Definition: Filter.hh:102
virtual void Set(const T &_val)
Set the output of the filter.
Definition: Filter.hh:39
Filter base class.
Definition: Filter.hh:32
A one-pole DSP filter.
Definition: Filter.hh:64
A quaternion class.
Definition: Quaternion.hh:31
virtual void Fc(double _fc, double _fs)=0
Set the cutoff frequency and sample rate.
#define IGN_PI
Define IGN_PI, IGN_PI_2, and IGN_PI_4.
Definition: Helpers.hh:59
BiQuadVector3()
Constructor.
Definition: Filter.hh:231
One-pole vector3 filter.
Definition: Filter.hh:132
const math::Quaterniond & Process(const math::Quaterniond &_x)
Update the filter's output.
Definition: Filter.hh:122
virtual const T & Process(const T &_x)
Update the filter's output.
Definition: Filter.hh:199
double a0
Input gain control.
Definition: Filter.hh:94