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