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