Alexander Lüthard
/
Micromouse
Alle Prinf's auskommentiert
Fork of Micromouse by
LowpassFilter.h@1:2b5f79285a3e, 2018-04-19 (annotated)
- Committer:
- Helvis
- Date:
- Thu Apr 19 06:19:43 2018 +0000
- Revision:
- 1:2b5f79285a3e
Micromouse V0.9: Tresholds + Regler noch anpassen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Helvis | 1:2b5f79285a3e | 1 | /* |
Helvis | 1:2b5f79285a3e | 2 | * LowpassFilter.h |
Helvis | 1:2b5f79285a3e | 3 | * Copyright (c) 2018, ZHAW |
Helvis | 1:2b5f79285a3e | 4 | * All rights reserved. |
Helvis | 1:2b5f79285a3e | 5 | */ |
Helvis | 1:2b5f79285a3e | 6 | |
Helvis | 1:2b5f79285a3e | 7 | #ifndef LOWPASS_FILTER_H_ |
Helvis | 1:2b5f79285a3e | 8 | #define LOWPASS_FILTER_H_ |
Helvis | 1:2b5f79285a3e | 9 | |
Helvis | 1:2b5f79285a3e | 10 | #include <cstdlib> |
Helvis | 1:2b5f79285a3e | 11 | |
Helvis | 1:2b5f79285a3e | 12 | /** |
Helvis | 1:2b5f79285a3e | 13 | * This class implements a time-discrete 2nd order lowpass filter for a series of data values. |
Helvis | 1:2b5f79285a3e | 14 | * This filter can typically be used within a periodic task that takes measurements that need |
Helvis | 1:2b5f79285a3e | 15 | * to be filtered, like speed or position values. |
Helvis | 1:2b5f79285a3e | 16 | */ |
Helvis | 1:2b5f79285a3e | 17 | class LowpassFilter { |
Helvis | 1:2b5f79285a3e | 18 | |
Helvis | 1:2b5f79285a3e | 19 | public: |
Helvis | 1:2b5f79285a3e | 20 | |
Helvis | 1:2b5f79285a3e | 21 | LowpassFilter(); |
Helvis | 1:2b5f79285a3e | 22 | virtual ~LowpassFilter(); |
Helvis | 1:2b5f79285a3e | 23 | void reset(); |
Helvis | 1:2b5f79285a3e | 24 | void reset(float value); |
Helvis | 1:2b5f79285a3e | 25 | void setPeriod(float period); |
Helvis | 1:2b5f79285a3e | 26 | void setFrequency(float frequency); |
Helvis | 1:2b5f79285a3e | 27 | float getFrequency(); |
Helvis | 1:2b5f79285a3e | 28 | float filter(float value); |
Helvis | 1:2b5f79285a3e | 29 | |
Helvis | 1:2b5f79285a3e | 30 | private: |
Helvis | 1:2b5f79285a3e | 31 | |
Helvis | 1:2b5f79285a3e | 32 | float period; |
Helvis | 1:2b5f79285a3e | 33 | float frequency; |
Helvis | 1:2b5f79285a3e | 34 | float a11, a12, a21, a22, b1, b2; |
Helvis | 1:2b5f79285a3e | 35 | float x1, x2; |
Helvis | 1:2b5f79285a3e | 36 | }; |
Helvis | 1:2b5f79285a3e | 37 | |
Helvis | 1:2b5f79285a3e | 38 | #endif /* LOWPASS_FILTER_H_ */ |