|
4 | 4 |
|
5 | 5 | namespace path_tracking_pid::details
|
6 | 6 | {
|
7 |
| -// Error tracker for the last 3 error and filtered error values. |
| 7 | +/** |
| 8 | + * @brief discrete time second order lowpass filter |
| 9 | + */ |
8 | 10 | class SecondOrderLowpass
|
9 | 11 | {
|
10 | 12 | public:
|
11 |
| - // Pushes the given value to the errors FIFO buffer. A corresponding filtered error value is calculated and pushed |
12 |
| - // to the filtered errors FIFO buffer. |
13 |
| - void push(double value); |
| 13 | + /** |
| 14 | + * @brief Construct a SecondOrderLowpass instance with NaNs |
| 15 | + */ |
| 16 | + SecondOrderLowpass(); |
14 | 17 |
|
15 |
| - // Resets both errors and filtered errors FIFO buffers. |
16 |
| - void reset(); |
| 18 | + /** |
| 19 | + * @brief Construct a SecondOrderLowpass instance |
| 20 | + * @param fden frequency in Hz |
| 21 | + * @param bden frequency in Hz |
| 22 | + */ |
| 23 | + SecondOrderLowpass(double fden, double bden); |
| 24 | + |
| 25 | + void configure(double fden, double bden); |
17 | 26 |
|
18 |
| - // Read-only access to the errors FIFO buffer. |
19 |
| - const FifoArray<double, 3> & errors() const; |
| 27 | + /** |
| 28 | + * @brief filter one sample of a signal |
| 29 | + * @param u signal to be filtered |
| 30 | + * @param step_size |
| 31 | + * @return lowpass-filtered signal |
| 32 | + */ |
| 33 | + double filter(double u, double step_size); |
20 | 34 |
|
21 |
| - // Read-only access to the filtered errors FIFO buffer. |
22 |
| - const FifoArray<double, 3> & filtered_errors() const; |
| 35 | + void reset(); |
23 | 36 |
|
24 | 37 | private:
|
25 |
| - FifoArray<double, 3> errors_; |
26 |
| - FifoArray<double, 3> filtered_errors_; |
| 38 | + FifoArray<double, 3> u_ = {}; |
| 39 | + FifoArray<double, 3> y_ = {}; |
| 40 | + double fden_; |
| 41 | + double bden_; |
27 | 42 | };
|
28 | 43 |
|
29 | 44 | } // namespace path_tracking_pid::details
|
0 commit comments