![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
These are the core files for the Robot at Team conception.
LowpassFilter.h@2:644553c019c5, 2017-05-26 (annotated)
- Committer:
- Paulhd182
- Date:
- Fri May 26 08:34:21 2017 +0000
- Revision:
- 2:644553c019c5
Added encodercounter and lowpassfilter classes; PHD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Paulhd182 | 2:644553c019c5 | 1 | /* |
Paulhd182 | 2:644553c019c5 | 2 | * LowpassFilter.h |
Paulhd182 | 2:644553c019c5 | 3 | * Copyright (c) 2016, ZHAW honr |
Paulhd182 | 2:644553c019c5 | 4 | * All rights reserved. |
Paulhd182 | 2:644553c019c5 | 5 | */ |
Paulhd182 | 2:644553c019c5 | 6 | |
Paulhd182 | 2:644553c019c5 | 7 | #ifndef LOWPASS_FILTER_H_ |
Paulhd182 | 2:644553c019c5 | 8 | #define LOWPASS_FILTER_H_ |
Paulhd182 | 2:644553c019c5 | 9 | |
Paulhd182 | 2:644553c019c5 | 10 | #include <cstdlib> |
Paulhd182 | 2:644553c019c5 | 11 | #include <cmath> |
Paulhd182 | 2:644553c019c5 | 12 | |
Paulhd182 | 2:644553c019c5 | 13 | /** |
Paulhd182 | 2:644553c019c5 | 14 | * This class implements a time-discrete 2nd order low-pass filter for a series of data values. |
Paulhd182 | 2:644553c019c5 | 15 | * This filter can typically be used within a periodic task that takes measurements that need |
Paulhd182 | 2:644553c019c5 | 16 | * to be filtered, like speed or position values. |
Paulhd182 | 2:644553c019c5 | 17 | */ |
Paulhd182 | 2:644553c019c5 | 18 | class LowpassFilter { |
Paulhd182 | 2:644553c019c5 | 19 | |
Paulhd182 | 2:644553c019c5 | 20 | public: |
Paulhd182 | 2:644553c019c5 | 21 | |
Paulhd182 | 2:644553c019c5 | 22 | LowpassFilter(); |
Paulhd182 | 2:644553c019c5 | 23 | virtual ~LowpassFilter(); |
Paulhd182 | 2:644553c019c5 | 24 | void reset(); |
Paulhd182 | 2:644553c019c5 | 25 | void reset(float value); |
Paulhd182 | 2:644553c019c5 | 26 | void setPeriod(float period); |
Paulhd182 | 2:644553c019c5 | 27 | void setFrequency(float frequency); |
Paulhd182 | 2:644553c019c5 | 28 | float getFrequency(); |
Paulhd182 | 2:644553c019c5 | 29 | float filter(float value); |
Paulhd182 | 2:644553c019c5 | 30 | |
Paulhd182 | 2:644553c019c5 | 31 | private: |
Paulhd182 | 2:644553c019c5 | 32 | |
Paulhd182 | 2:644553c019c5 | 33 | float period; |
Paulhd182 | 2:644553c019c5 | 34 | float frequency; |
Paulhd182 | 2:644553c019c5 | 35 | float a11, a12, a21, a22, b1, b2; |
Paulhd182 | 2:644553c019c5 | 36 | float x1, x2; |
Paulhd182 | 2:644553c019c5 | 37 | }; |
Paulhd182 | 2:644553c019c5 | 38 | |
Paulhd182 | 2:644553c019c5 | 39 | #endif /* LOWPASS_FILTER_H_ */ |