P2 halbfertig
Fork of Library by
LowpassFilter.h@2:6dd39662e6e5, 2018-03-10 (annotated)
- Committer:
- kueenste
- Date:
- Sat Mar 10 13:47:28 2018 +0000
- Revision:
- 2:6dd39662e6e5
- Parent:
- 0:bb408887ab78
funktioniert soso
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kueenste | 0:bb408887ab78 | 1 | /* |
kueenste | 0:bb408887ab78 | 2 | * LowpassFilter.h |
kueenste | 0:bb408887ab78 | 3 | * Copyright (c) 2018, ZHAW |
kueenste | 0:bb408887ab78 | 4 | * All rights reserved. |
kueenste | 0:bb408887ab78 | 5 | */ |
kueenste | 0:bb408887ab78 | 6 | |
kueenste | 0:bb408887ab78 | 7 | #ifndef LOWPASS_FILTER_H_ |
kueenste | 0:bb408887ab78 | 8 | #define LOWPASS_FILTER_H_ |
kueenste | 0:bb408887ab78 | 9 | |
kueenste | 0:bb408887ab78 | 10 | #include <cstdlib> |
kueenste | 0:bb408887ab78 | 11 | |
kueenste | 0:bb408887ab78 | 12 | /** |
kueenste | 0:bb408887ab78 | 13 | * This class implements a time-discrete 2nd order lowpass filter for a series of data values. |
kueenste | 0:bb408887ab78 | 14 | * This filter can typically be used within a periodic task that takes measurements that need |
kueenste | 0:bb408887ab78 | 15 | * to be filtered, like speed or position values. |
kueenste | 0:bb408887ab78 | 16 | */ |
kueenste | 0:bb408887ab78 | 17 | class LowpassFilter { |
kueenste | 0:bb408887ab78 | 18 | |
kueenste | 0:bb408887ab78 | 19 | public: |
kueenste | 0:bb408887ab78 | 20 | |
kueenste | 0:bb408887ab78 | 21 | LowpassFilter(); |
kueenste | 0:bb408887ab78 | 22 | virtual ~LowpassFilter(); |
kueenste | 0:bb408887ab78 | 23 | void reset(); |
kueenste | 0:bb408887ab78 | 24 | void reset(float value); |
kueenste | 0:bb408887ab78 | 25 | void setPeriod(float period); |
kueenste | 0:bb408887ab78 | 26 | void setFrequency(float frequency); |
kueenste | 0:bb408887ab78 | 27 | float getFrequency(); |
kueenste | 0:bb408887ab78 | 28 | float filter(float value); |
kueenste | 0:bb408887ab78 | 29 | |
kueenste | 0:bb408887ab78 | 30 | private: |
kueenste | 0:bb408887ab78 | 31 | |
kueenste | 0:bb408887ab78 | 32 | float period; |
kueenste | 0:bb408887ab78 | 33 | float frequency; |
kueenste | 0:bb408887ab78 | 34 | float a11, a12, a21, a22, b1, b2; |
kueenste | 0:bb408887ab78 | 35 | float x1, x2; |
kueenste | 0:bb408887ab78 | 36 | }; |
kueenste | 0:bb408887ab78 | 37 | |
kueenste | 0:bb408887ab78 | 38 | #endif /* LOWPASS_FILTER_H_ */ |
kueenste | 0:bb408887ab78 | 39 |