18 #ifndef _GAZEBO_FILTER_HH_
19 #define _GAZEBO_FILTER_HH_
25 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
56 public:
virtual void SetFc(
double _fc,
double _fs)
85 this->SetFc(_fc, _fs);
89 public:
virtual void SetFc(
double _fc,
double _fs)
91 b1 = exp(-2.0 * M_PI * _fc / _fs);
98 public:
inline const T&
Process(
const T &_x)
100 this->y0 = a0 * _x + b1 * this->y0;
105 protected:
double a0;
108 protected:
double b1;
169 : a0(0), a1(0), a2(0), b0(0), b1(0), b2(0)
178 : a0(0), a1(0), a2(0), b0(0), b1(0), b2(0)
180 this->SetFc(_fc, _fs);
184 public:
inline void SetFc(
double _fc,
double _fs)
186 this->SetFc(_fc, _fs, 0.5);
193 public:
inline void SetFc(
double _fc,
double _fs,
double _q)
195 double k = tan(M_PI * _fc / _fs);
196 double kQuadDenom = k * k + k / _q + 1.0;
197 this->a0 = k * k/ kQuadDenom;
198 this->a1 = 2 * this->a0;
201 this->b1 = 2 * (k * k - 1.0) / kQuadDenom;
202 this->b2 = (k * k - k / _q + 1.0) / kQuadDenom;
209 this->y0 = this->y1 = this->y2 = this->x1 = this->x2 = _val;
215 public:
inline virtual const T&
process(
const T &_x)
217 this->y0 = this->a0 * _x +
218 this->a1 * this->x1 +
219 this->a2 * this->x2 -
220 this->b1 * this->y1 -
231 protected:
double a0, a1, a2, b0, b1,
b2;
234 protected: T x1, x2, y1,
y2;
262 #pragma GCC diagnostic pop
BiQuadVector3() GAZEBO_DEPRECATED(8.0)
Constructor.
Definition: Filter.hh:242
void SetFc(double _fc, double _fs, double _q)
Set the cutoff frequency, sample rate and Q coefficient.
Definition: Filter.hh:193
virtual void SetValue(const T &_val)
Set the current filter's output.
Definition: Filter.hh:207
BiQuad vector3 filter.
Definition: Filter.hh:239
One-pole quaternion filter.
Definition: Filter.hh:113
const math::Quaternion & Process(const math::Quaternion &_x)
Update the filter's output.
Definition: Filter.hh:133
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:44
double a0
Input gain control.
Definition: Filter.hh:105
OnePole(double _fc, double _fs) GAZEBO_DEPRECATED(8.0)
Constructor.
Definition: Filter.hh:82
static const double GAZEBO_DEPRECATED(8.0) MAX_D
Double maximum value. This value will be similar to 1.79769e+308.
Definition: Helpers.hh:140
OnePoleVector3() GAZEBO_DEPRECATED(8.0)
Constructor.
Definition: Filter.hh:145
T y0
Output.
Definition: Filter.hh:65
static Quaternion Slerp(double _fT, const Quaternion &_rkP, const Quaternion &_rkQ, bool _shortestPath=false) GAZEBO_DEPRECATED(8.0)
Spherical linear interpolation between 2 quaternions, given the ends and an interpolation parameter b...
virtual void SetValue(const T &_val) GAZEBO_DEPRECATED(8.0)
Set the output of the filter.
Definition: Filter.hh:50
BiQuad(double _fc, double _fs) GAZEBO_DEPRECATED(8.0)
Constructor.
Definition: Filter.hh:177
T y2
Definition: Filter.hh:234
double b1
Gain of the feedback.
Definition: Filter.hh:108
virtual const T & GetValue() GAZEBO_DEPRECATED(8.0)
Get the output of the filter.
Definition: Filter.hh:61
Bi-quad filter base class.
Definition: Filter.hh:164
virtual void SetFc(double _fc, double _fs)
Set the cutoff frequency and sample rate.
Definition: Filter.hh:89
A one-pole DSP filter.
Definition: Filter.hh:72
One-pole vector3 filter.
Definition: Filter.hh:142
double b2
Definition: Filter.hh:231
void SetFc(double _fc, double _fs)
Set the cutoff frequency and sample rate.
Definition: Filter.hh:184
OnePoleQuaternion() GAZEBO_DEPRECATED(8.0)
Constructor.
Definition: Filter.hh:116
A quaternion class.
Definition: Quaternion.hh:48
BiQuad() GAZEBO_DEPRECATED(8.0)
Constructor.
Definition: Filter.hh:168
OnePoleQuaternion(double _fc, double _fs) GAZEBO_DEPRECATED(8.0)
Constructor.
Definition: Filter.hh:124
virtual const T & process(const T &_x)
Update the filter's output.
Definition: Filter.hh:215
Filter base class.
Definition: Filter.hh:43
BiQuadVector3(double _fc, double _fs) GAZEBO_DEPRECATED(8.0)
Constructor.
Definition: Filter.hh:250
OnePole() GAZEBO_DEPRECATED(8.0)
Constructor.
Definition: Filter.hh:76
OnePoleVector3(double _fc, double _fs)
Constructor.
Definition: Filter.hh:153
const T & Process(const T &_x)
Update the filter's output.
Definition: Filter.hh:98
virtual ~Filter() GAZEBO_DEPRECATED(8.0)
Destructor.
Definition: Filter.hh:46