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