Cheetah Software  1.0
filters.h
Go to the documentation of this file.
1 #ifndef FILTERS_
2 #define FILTERS_
3 
4 template <typename T>
5 class filter {
6  public:
7  filter(void) {}
8  virtual ~filter(void) {}
9  virtual void input(T input_value) = 0;
10  virtual T output(void) = 0;
11  virtual void clear(void) = 0;
12 };
13 
14 template <typename T>
15 class butterworth_filter : public filter<T> {
16  public:
17  butterworth_filter(int num_sample, T dt, T cutoff_frequency);
18  virtual ~butterworth_filter(void);
19  virtual void input(T input_value);
20  virtual T output(void);
21  virtual void clear(void);
22 
23  private:
25  int mCurIdx;
27  T mDt;
29  T mValue;
30 };
31 
32 template <typename T>
33 class digital_lp_filter : public filter<T> {
34  public:
35  digital_lp_filter(T w_c, T t_s);
36  virtual ~digital_lp_filter(void);
37  virtual void input(T input_value);
38  virtual T output(void);
39  virtual void clear(void);
40 
41  private:
42  T Lpf_in_prev[2];
43  T Lpf_out_prev[2];
44  T Lpf_in1, Lpf_in2, Lpf_in3, Lpf_out1, Lpf_out2;
46 };
47 
48 template <typename T>
49 class moving_average_filter : public filter<T> {
50  public:
51  moving_average_filter(int num_data);
52  virtual ~moving_average_filter();
53  virtual void input(T input_value);
54  virtual T output(void);
55  virtual void clear(void);
56 
57  private:
58  T *buffer_;
59  int num_data_;
60  int idx_;
61  T sum_;
62 };
63 
64 template <typename T>
65 class deriv_lp_filter : public filter<T> {
66  public:
67  deriv_lp_filter(T w_c, T t_s);
68  virtual ~deriv_lp_filter(void);
69  virtual void input(T input_value);
70  virtual T output(void);
71  virtual void clear(void);
72 
73  private:
74  T Lpf_in_prev[2];
75  T Lpf_out_prev[2];
76  T Lpf_in1, Lpf_in2, Lpf_in3, Lpf_out1, Lpf_out2;
78 };
79 
80 template <typename T>
81 class ff01_filter : public filter<T> {
82  public:
83  ff01_filter(float t_s, float w_c);
84  virtual ~ff01_filter(void);
85  virtual void input(T input_value);
86  virtual T output(void);
87  virtual void clear(void);
88 
89  private:
90  T Lpf_in_prev[2];
91  T Lpf_out_prev[2];
92  T Lpf_in1, Lpf_in2, Lpf_in3, Lpf_out1, Lpf_out2;
94 };
95 
96 template <typename T>
97 class ff02_filter : public filter<T> {
98  public:
99  ff02_filter(float t_s, float w_c);
100  virtual ~ff02_filter(void);
101  virtual void input(T input_value);
102  virtual T output(void);
103  virtual void clear(void);
104 
105  private:
106  T Lpf_in_prev[2];
107  T Lpf_out_prev[2];
108  T Lpf_in1, Lpf_in2, Lpf_in3, Lpf_out1, Lpf_out2;
110 };
111 
112 template <typename T>
113 class AverageFilter : public filter<T> {
114  public:
115  AverageFilter(T dt, T t_const, T limit);
116  virtual ~AverageFilter();
117  virtual void input(T input_value);
118  virtual T output(void);
119  virtual void clear(void);
120 
121  private:
123  T dt_;
126 };
127 #endif
T Lpf_out2
Definition: filters.h:92
Definition: filters.h:5
virtual ~filter(void)
Definition: filters.h:8
filter(void)
Definition: filters.h:7
virtual void input(T input_value)=0
virtual void clear(void)=0
virtual T output(void)=0