SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
lowpass_filter.h
Go to the documentation of this file.
1#ifndef LOWPASS_FILTER_H
2#define LOWPASS_FILTER_H
3
4
5#include "time_utils.h"
6#include "foc_utils.h"
7
8/**
9 * Low pass filter class
10 */
12{
13public:
14 /**
15 * @param Tf - Low pass filter time constant
16 * @param Ts - Filter sampling time
17 *
18 * @note If sampling time Ts is not set the filter will measure the
19 * elapsed time between each call.
20 * @note Ts can be changed dynamically as well by modifying the
21 * variable in runtime.
22 */
23 LowPassFilter(float Tf, float Ts = NOT_SET);
24 ~LowPassFilter() = default;
25
26 float operator() (float x);
27 float Tf; //!< Low pass filter time constant
28 float Ts; //!< Fixed sampling time (optional default NOT_SET)
29
30protected:
31 unsigned long timestamp_prev; //!< Last execution timestamp
32 float y_prev; //!< filtered value in previous execution step
33};
34
35#endif // LOWPASS_FILTER_H
float operator()(float x)
float y_prev
filtered value in previous execution step
float Ts
Fixed sampling time (optional default NOT_SET)
~LowPassFilter()=default
float Tf
Low pass filter time constant.
unsigned long timestamp_prev
Last execution timestamp.
float x
Definition foc_utils.cpp:54
#define NOT_SET
Definition foc_utils.h:34