2022-06-18 11:33:56 +02:00
|
|
|
#pragma once
|
|
|
|
|
2022-06-19 13:05:58 +02:00
|
|
|
template <class T>
|
|
|
|
struct Pt1
|
|
|
|
{
|
2022-06-19 12:33:59 +02:00
|
|
|
T y_n1;
|
|
|
|
T K;
|
|
|
|
T T1;
|
2022-06-18 11:33:56 +02:00
|
|
|
|
2022-06-19 12:33:59 +02:00
|
|
|
/* PT1: y = y_(n-1) + (Ku - y_(n-1)) * dt/T1 */
|
2022-06-19 13:05:58 +02:00
|
|
|
Pt1(T K, T T1) : T1(T1), K(K){};
|
2022-06-26 23:06:21 +02:00
|
|
|
Pt1() = default;
|
2022-06-19 12:33:59 +02:00
|
|
|
T update(T u, T dt)
|
|
|
|
{
|
|
|
|
T y = this->y_n1 + (this->K * u - this->y_n1) * dt / this->T1;
|
|
|
|
this->y_n1 = y;
|
|
|
|
return y;
|
|
|
|
}
|
2022-06-19 15:15:24 +02:00
|
|
|
|
|
|
|
void reset() {
|
|
|
|
this->y_n1 = 0.f;
|
|
|
|
}
|
2022-06-19 12:33:59 +02:00
|
|
|
};
|