Controlpp
Loading...
Searching...
No Matches
TimeVariantControl.hpp
Go to the documentation of this file.
1#pragma once
11#include <algorithm>
12#include <limits>
13
14#include <Eigen/Dense>
15
16namespace controlpp
17{
18
20 namespace timevar{
21
22 template<class T>
27
45 template<class T>
46 class PControl{
47 public:
48 using value_type = T;
49 private:
50
51 T kp_;
52
53 public:
54
56 constexpr PControl(const PControl&) = default;
57
62 constexpr PControl(const T& kp) : kp_(kp){}
63
68 constexpr void kp(const T& kp){this->kp_ = kp;}
69
73 [[nodiscard]] constexpr const T& kp() const {return this->kp_;}
74
80 constexpr T input(const T& u) {return u * this->kp_;}
81
88 constexpr T input(const T& u, [[maybe_unused]]const T& Ts) {return this->input(u);}
89
95 constexpr T operator() (const T& u) {return this->input(u);}
96
103 constexpr T operator() (const T& u, [[maybe_unused]]const T& Ts) {return this->input(u);}
104
108
114 constexpr void reset() {/*no operation*/}
115 };
116
117
150 template<class T>
151 class IControl{
152 public:
153 using value_type = T;
154 private:
155 T ki_;
156 T u_k1_ = static_cast<T>(0);
157 T y_k1_ = static_cast<T>(0);
158
159 public:
160
165 constexpr IControl(const T& ki) : ki_(ki){}
166
168 constexpr IControl(const IControl&) = default;
169
172 constexpr void set_param(const T& ki) {return this->ki_ = ki;}
173
179 constexpr void reset(){
180 this->u_k1_ = static_cast<T>(0);
181 this->y_k1_ = static_cast<T>(0);
182 }
183
189 constexpr T input(const T& u, const T& Ts){
190 const T y = this->ki_ * Ts / 2 * (u + this->u_k1_) + this->y_k1_;
191 this->y_k1_ = y;
192 this->u_k1_ = u;
193 return y;
194 }
195
202 constexpr T operator() (const T& u, const T& Ts){return this->input(u, Ts);}
203
207 };
208
260 template<class T>
262 public:
263 using value_type = T;
264 private:
265 T ki_;
266 T min_;
267 T max_;
268 T vn_;
269 T vp_;
270
271 T u_k1_ = static_cast<T>(0);
272 T y_k1_ = static_cast<T>(0);
273
274 public:
275
284 constexpr IAntiWindup(const T& ki, const T& min, const T& max, const T& vn = std::numeric_limits<T>::lowest(), const T& vp = std::numeric_limits<T>::max())
285 : ki_(ki)
286 , min_(min)
287 , max_(max)
288 , vn_(vn)
289 , vp_(vp)
290 {}
291
293 constexpr IAntiWindup(const IAntiWindup&) = default;
294
297 constexpr void set_param(const T& ki) {return this->ki_ = ki;}
298
301 constexpr void prate_limit(const T& pv) {return this->vp_ = pv;}
302
304 [[nodiscard]] constexpr const T& prate_limit() const {return this->vp_;}
305
308 constexpr void nrate_limit(const T& nv) {return this->vn_ = nv;}
309
311 [[nodiscard]] constexpr const T& nrate_limit() const {return this->vn_;}
312
315 constexpr void max_limit(const T& max) {return this->max_ = max;}
316
318 [[nodiscard]] constexpr const T& max_limit() const {return this->max_;}
319
322 constexpr void min_limit(const T& min) {return this->min_ = min;}
323
325 [[nodiscard]] constexpr const T& min_limit() const {return this->min_;}
326
335 constexpr void reset(){
336 this->u_k1_ = static_cast<T>(0);
337 this->y_k1_ = static_cast<T>(0);
338 }
339
345 constexpr T input(const T& u, const T& Ts){
346 const T v = std::clamp(this->ki_ / 2 * (u + this->u_k1_), this->vn_, this->vp_);
347 const T dy = v * Ts;
348 const T y = std::clamp(dy + this->y_k1_, this->min_, this->max_);
349
350 this->y_k1_ = y;
351 this->u_k1_ = u;
352 return y;
353 }
354
361 constexpr T operator() (const T& u, const T& Ts){return this->input(u, Ts);}
362
366 };
367
408 template<class T>
409 class DControl{
410 private:
411 T kd_;
412 T omega_;
413 T x_ = static_cast<T>(0);
414
415 public:
416
422 constexpr DControl(const T& kd, const T& omega)
423 : kd_(kd)
424 , omega_(omega){}
425
427 constexpr DControl(const DControl&) = default;
428
429 constexpr T input(const T& u, const T& Ts){
430 const T V = 2 * kd_ * omega_;
431
432 const T b0 = 1;
433 const T b1 = -1;
434
435 const T omega_Ts = omega_ * Ts;
436 const T a0 = omega_Ts + 2;
437 const T a1 = omega_Ts - 2;
438
439 const T b0_ = b0 / a0;
440 const T b1_ = b1 / a0;
441
442 const T a1_ = a1 / a0;
443
444 const T A = -a1_;
445 const T C = b1_ - a1_ * b0_;
446 const T D = b0_;
447
448 const T new_x = A * x_ + u;
449 const T y = C * x_ + D * u;
450
451 this->x_ = new_x;
452 return y * V;
453 }
454
455 constexpr T operator() (const T& u, const T& Ts) {return this->input(u, Ts);}
456
460
461 constexpr void reset(){
462 this->x_ = static_cast<T>(0);
463 }
464 };
465
500 template<class T>
502 private:
503 T _K = static_cast<T>(1);
504 T _omega = static_cast<T>(1);
505 T _x = static_cast<T>(0);
506
507 public:
508
514 constexpr PT1Control(const T& K, const T& omega)
515 : _K(K)
516 , _omega(omega){}
517
519 constexpr PT1Control(const PT1Control&) = default;
520
521 constexpr void set_gain(const T& g){this->_K = g;}
522 [[nodiscard]] constexpr const T& gain() const {return this->_K;}
523
524 constexpr void set_omega(const T& w){this->_omega = w;}
525 [[nodiscard]] constexpr const T& omega() const {return this->_omega;}
526
527 constexpr T input(const T& u, const T& Ts){
528 // helper values
529 const T p = (Ts * this->_omega + 2);
530 const T n = (Ts * this->_omega - 2);
531
532 // parameters
533 // a_0 = 1
534 const T a = n / p;
535 const T b = this->_K * Ts * this->_omega / p;
536
537 // calculate new state and output
538 const T new_x = (-a) * this->_x + u;
539 const T new_y = b * ((1 - a) * this->_x + u);
540
541 // update state and output
542 this->_x = new_x;
543 return new_y;
544 }
545
546 constexpr T operator() (const T& u, const T& Ts) {return this->input(u, Ts);}
547
551
552 constexpr void reset(){
553 this->_x = static_cast<T>(0);
554 }
555 };
556
598 template<class T>
600 private:
601 T K_;
602 T D_;
603 T omega_;
604 Eigen::Vector<T, 2> x_ = Eigen::Vector<T, 2>::Zero();
605
606 public:
607 PT2Control(const PT2Control&) = default;
608
615 PT2Control(const T& K, const T& D, const T& omega)
616 : K_(K)
617 , D_(D)
618 , omega_(omega){}
619
620 constexpr T input(const T& u, const T& Ts){
621 // calculate params of the tustin transformed transfer function
622 const T b0 = static_cast<T>(1);
623 const T b1 = static_cast<T>(2);
624 const T b2 = static_cast<T>(1);
625
626 const T omega_Ts_sqr = this->omega_ * this->omega_ * Ts * Ts;
627 const T _4_DomegaTs = 4 * this->D_ * this->omega_ * Ts;
628
629 const T V = this->K_ * omega_Ts_sqr;
630 const T a0 = omega_Ts_sqr + _4_DomegaTs + 4;
631 const T a1 = 2 * omega_Ts_sqr - 8;
632 const T a2 = omega_Ts_sqr - _4_DomegaTs + 4;
633
634 const T b0_ = b0 / a0;
635 const T b1_ = b1 / a0;
636 const T b2_ = b2 / a0;
637
638 const T a1_ = a1 / a0;
639 const T a2_ = a2 / a0;
640
641 // turn it into state space form
642 Eigen::Matrix<T, 2, 2> A({
643 {-a1_, -a2_},
644 {static_cast<T>(1), static_cast<T>(0)}
645 });
646
647 const Eigen::Matrix<T, 2, 1> B({
648 static_cast<T>(1),
649 static_cast<T>(0)
650 });
651
652 const Eigen::Matrix<T, 1, 2> C({
653 (b1_ - a1_ * b0_), (b2_ - a2_ * b0_)
654 });
655
656 const T D = b0_;
657
658 // calculate the state space system response
659 const Eigen::Vector<T, 2> new_x = A * this->x_ + B * u;
660 const T y = C * this->x_ + D * u;
661
662 // update states and output result
663 this->x_ = new_x;
664 return y * V;
665 }
666
667 constexpr T operator() (const T& u, const T& Ts) {return this->input(u, Ts);}
668
672
673 constexpr void reset(){
674 this->x_.setZero();
675 }
676 };
677
716 template<class T>
718 private:
719 PControl<T> P_;
720 IControl<T> I_;
721
722 public:
723
728 PIControl(const T& kp, const T& ki)
729 : P_(kp)
730 , I_(ki){}
731
732 PIControl(const PIControl&) = default;
733
734 constexpr T input(const T& u, const T& Ts){
735 const T y = P_(u, Ts) + I_(u, Ts);
736 return y;
737 }
738
739 constexpr T operator() (const T& u, const T& Ts) {return this->input(u, Ts);}
740
744
745 constexpr void reset(){
746 this->P_.reset();
747 this->I_.reset();
748 }
749 };
750
799 template<class T>
801 private:
802 PControl<T> P_;
804
805 T y_k1_ = static_cast<T>(0);
806
807 public:
808
816 PIAntiWindup(const T& kp, const T& ki, const T& min, const T& max, const T& vn = std::numeric_limits<T>::lowest(), const T& vp = std::numeric_limits<T>::max())
817 : P_(kp)
818 , I_(ki, min, max, vn, vp)
819 {}
820
821 PIAntiWindup(const PIAntiWindup&) = default;
822
827 constexpr void kp(const T& kp){this->P_.kp(kp);}
828
832 [[nodiscard]] constexpr const T& kp() const {return this->P_.kp();}
833
838 constexpr void ki(const T& ki){this->I_.ki(ki);}
839
843 [[nodiscard]] constexpr const T& ki() const {return this->I_.ki_();}
844
847 constexpr void prate_limit(const T& pv) {this->I_.prate_limit(pv);}
848
850 [[nodiscard]] constexpr const T& prate_limit() const {return this->I_.prate_limit();}
851
854 constexpr void nrate_limit(const T& nv) {this->I_.nrate_limit(nv);}
855
857 [[nodiscard]] constexpr const T& nrate_limit() const {return this->I_.nrate_limit();}
858
861 constexpr void max_limit(const T& max) {this->I_.max_limit(max);}
862
864 [[nodiscard]] constexpr const T& max_limit() const {return this->I_.max_limit();}
865
868 constexpr void min_limit(const T& min) {this->I_.min_limit(min);}
869
871 [[nodiscard]] constexpr const T& min_limit() const {return this->I_.min_limit();}
872
879 constexpr T input(const T& u, const T& Ts){
880 // calculate new output
881 T y_raw = I_.input(u, Ts) + P_.input(u);
882 T rate_raw = (y_raw - y_k1_)/Ts;
883 T rate = std::clamp(rate_raw, nrate_limit(), prate_limit());
884 T y_rate_clamped = rate * Ts + y_k1_;
885 T y = std::clamp(y_rate_clamped, min_limit(), max_limit());
886
887 // update states
888 this->y_k1_ = y;
889
890 return y;
891 }
892
899 constexpr T operator()(const T& u, const T& Ts){return this->input(u, Ts);}
900
904
909 constexpr void reset(){
910 this->I_.reset();
911 this->y_k1_ = static_cast<T>(0);
912 }
913 };
914
915
968 template<class T>
970 private:
971
972 PT1Control<T> PT1_;
973 IControl<T> I_;
974
975 public:
976
977 constexpr PT1IControl(const PT1IControl&) = default;
978
985 constexpr PT1IControl(const T& kp, const T& ki, const T& omega)
986 : PT1_(kp, omega)
987 , I_(ki)
988 {}
989
996 constexpr T input(const T& u, const T& Ts){
997 // calculate filter parameters
998 const T result = PT1_(u, Ts) + I_(u, Ts);
999 return result;
1000 }
1001
1008 constexpr T operator()(const T& u, const T& Ts){return this->input(u, Ts);}
1009
1013
1018 constexpr void reset(){
1019 PT1_.reset();
1020 I_.reset();
1021 }
1022 };
1023
1046 template<class T>
1048 private:
1049 PControl<T> P_;
1050 IControl<T> I_;
1051 DControl<T> D_;
1052
1053 public:
1054
1062 PIDControl(const T& kp, const T& ki, const T& kd, const T& omega)
1063 : P_(kp)
1064 , I_(ki)
1065 , D_(kd, omega){}
1066
1084 static PIDControl from_alpha_tune(const T& alpha, const T& omega_c, const T& mag_G){
1085 const T kp = 1 / (mag_G * alpha);
1086 const T ki = omega_c / (mag_G * alpha * alpha * alpha);
1087 const T kd = 1 / (omega_c * mag_G);
1088 const T omega = omega_c * alpha;
1089 PIDControl result(kp, ki, ki, omega);
1090 return result;
1091 }
1092
1099 constexpr T input(const T& u, const T& Ts){
1100 const T result = P_(u, Ts) + I_(u, Ts) + D_(u, Ts);
1101 return result;
1102 }
1103
1108 constexpr T operator() (const T& u, const T& Ts){return this->input(u, Ts);}
1109
1113
1118 constexpr void reset(){
1119 this->I_.reset();
1120 this->D_.reset();
1121 }
1122
1123 };
1124
1126 //TODO
1127 };
1128
1153 template<class T>
1155 private:
1156 T omega1_;
1157 T omega2_;
1158 T x_ = static_cast<T>(0);
1159
1160 public:
1161
1162 constexpr LeadLagControl(const T& omega1, const T& omega2)
1163 : omega1_(omega1)
1164 , omega2_(omega2){}
1165
1166 constexpr T input(const T& u, const T& Ts){
1167 const T V = this->omega2_ / this->omega1_;
1168
1169 const T b0 = Ts * this->omega1_ + static_cast<T>(2);
1170 const T b1 = Ts * this->omega1_ - static_cast<T>(2);
1171
1172 const T a0 = Ts * this->omega2_ + static_cast<T>(2);
1173 const T a1 = Ts * this->omega2_ - static_cast<T>(2);
1174
1175 const T b0_ = b0 / a0;
1176 const T b1_ = b1 / a0;
1177
1178 const T a1_ = a1 / a0;
1179
1180 const T A = -a1_;
1181 const T C = b1_ - a1_ * b0_;
1182 const T D = b0_;
1183
1184 const T new_x = A * x_ + u;
1185 const T y = C * x_ + D * u;
1186
1187 this->x_ = new_x;
1188 return y * V;
1189 }
1190
1191 constexpr T operator() (const T& u, const T& Ts) {return this->input(u, Ts);}
1192
1196
1197 constexpr void reset(){this->x_ = static_cast<T>(0);}
1198 };
1199
1216 template<class T>
1218 private:
1219 T w_;
1220 T g_min_;
1221 T omega_;
1222 Eigen::Vector<T, 2> x_ = Eigen::Vector<T, 2>::Zero();
1223
1224 public:
1225
1234 constexpr NotchControl(const T& w, const T& g_min, const T& omega)
1235 : w_(w)
1236 , g_min_(g_min)
1237 , omega_(omega){}
1238
1239 constexpr T input(const T& u, const T& Ts){
1240 const T Ts_omega_sqr = Ts * Ts * this->omega_ * this->omega_;
1241 const T Ts_omega_sqr_plus_4 = Ts_omega_sqr + 4;
1242 const T _4_Ts_w_omega = 4 * Ts * this->w_ * this->omega_;
1243 const T _4_Ts_w_omega_g = _4_Ts_w_omega * this->g_min_;
1244
1245 const T b0 = Ts_omega_sqr_plus_4 + _4_Ts_w_omega_g;
1246 const T b1 = 2 * (Ts_omega_sqr - 4);
1247 const T b2 = Ts_omega_sqr_plus_4 - _4_Ts_w_omega_g;
1248
1249 const T a0 = Ts_omega_sqr_plus_4 + _4_Ts_w_omega;
1250 const T a1 = b1;
1251 const T a2 = Ts_omega_sqr_plus_4 - _4_Ts_w_omega;
1252
1253 const T b0_ = b0 / a0;
1254 const T b1_ = b1 / a0;
1255 const T b2_ = b2 / a0;
1256
1257 const T a1_ = a1 / a0;
1258 const T a2_ = a2 / a0;
1259
1260 // turn it into state space form
1261 Eigen::Matrix<T, 2, 2> A({
1262 {-a1_, -a2_},
1263 {static_cast<T>(1), static_cast<T>(0)}
1264 });
1265
1266 const Eigen::Matrix<T, 2, 1> B({
1267 static_cast<T>(1),
1268 static_cast<T>(0)
1269 });
1270
1271 const Eigen::Matrix<T, 1, 2> C({
1272 (b1_ - a1_ * b0_), (b2_ - a2_ * b0_)
1273 });
1274
1275 const T D = b0_;
1276
1277 // calculate the state space system response
1278 const Eigen::Vector<T, 2> new_x = A * this->x_ + B * u;
1279 const T y = C * this->x_ + D * u;
1280
1281 // update states and output result
1282 this->x_ = new_x;
1283 return y;
1284 }
1285
1286 constexpr T operator() (const T& u, const T& Ts) {return this->input(u, Ts);}
1287
1291
1292 constexpr void reset(){
1293 this->x_.setZero();
1294 }
1295 };
1296
1297 } // vartime
1298} // namespace controlpp
A D (differntial) controller, with varying smaple-time.
Definition TimeVariantControl.hpp:409
constexpr void reset()
Definition TimeVariantControl.hpp:461
constexpr T input(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:429
constexpr DControl(const DControl &)=default
default copy constructor
constexpr DControl(const T &kd, const T &omega)
Construct a D control element.
Definition TimeVariantControl.hpp:422
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, DControl &c)
Definition TimeVariantControl.hpp:457
constexpr T operator()(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:455
An I (integrating) controller with anti windup protection (rate and value limits),...
Definition TimeVariantControl.hpp:261
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, IAntiWindup &c)
Definition TimeVariantControl.hpp:363
constexpr IAntiWindup(const T &ki, const T &min, const T &max, const T &vn=std::numeric_limits< T >::lowest(), const T &vp=std::numeric_limits< T >::max())
Constructs an I (Integrator) controller with anti-windup controller.
Definition TimeVariantControl.hpp:284
constexpr const T & min_limit() const
returns the minimal value limit
Definition TimeVariantControl.hpp:325
constexpr const T & prate_limit() const
returns the positive rate limit
Definition TimeVariantControl.hpp:304
constexpr T input(const T &u, const T &Ts)
Adds a new value input and sample time to calculate the next output.
Definition TimeVariantControl.hpp:345
constexpr const T & max_limit() const
returns the maximal value limit
Definition TimeVariantControl.hpp:318
constexpr IAntiWindup(const IAntiWindup &)=default
Default copy constructor.
constexpr void prate_limit(const T &pv)
Sets the positive rate limit of the I controller.
Definition TimeVariantControl.hpp:301
constexpr void nrate_limit(const T &nv)
Sets the negative rate limit of the I controller.
Definition TimeVariantControl.hpp:308
constexpr T operator()(const T &u, const T &Ts)
Adds a new value input and sample time to calculate the next output.
Definition TimeVariantControl.hpp:361
T value_type
Definition TimeVariantControl.hpp:263
constexpr void max_limit(const T &max)
Sets the maximal value limit.
Definition TimeVariantControl.hpp:315
constexpr void set_param(const T &ki)
Sets the integrator gain.
Definition TimeVariantControl.hpp:297
constexpr void min_limit(const T &min)
Sets the minimal value limit.
Definition TimeVariantControl.hpp:322
constexpr void reset()
resets (clears) the internal states
Definition TimeVariantControl.hpp:335
constexpr const T & nrate_limit() const
returns the negative rate limit
Definition TimeVariantControl.hpp:311
An I (Integrator) controller, with varying smaple-time.
Definition TimeVariantControl.hpp:151
constexpr void set_param(const T &ki)
Sets the integrator gain.
Definition TimeVariantControl.hpp:172
constexpr T input(const T &u, const T &Ts)
Adds a new value input and sample time to calculate the next output.
Definition TimeVariantControl.hpp:189
constexpr IControl(const IControl &)=default
Default copy constructor.
T value_type
Definition TimeVariantControl.hpp:153
constexpr IControl(const T &ki)
Constructs an I (Integrator) controller.
Definition TimeVariantControl.hpp:165
constexpr void reset()
resets (clears) the internal states
Definition TimeVariantControl.hpp:179
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, IControl &c)
Definition TimeVariantControl.hpp:204
constexpr T operator()(const T &u, const T &Ts)
Adds a new value input and sample time to calculate the next output.
Definition TimeVariantControl.hpp:202
A Lead-Lag control element with varying sample-times.
Definition TimeVariantControl.hpp:1154
constexpr void reset()
Definition TimeVariantControl.hpp:1197
constexpr T operator()(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:1191
constexpr LeadLagControl(const T &omega1, const T &omega2)
Definition TimeVariantControl.hpp:1162
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, LeadLagControl &c)
Definition TimeVariantControl.hpp:1193
constexpr T input(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:1166
A notch element with variable sample-time.
Definition TimeVariantControl.hpp:1217
constexpr T input(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:1239
constexpr NotchControl(const T &w, const T &g_min, const T &omega)
Creates a notch filter.
Definition TimeVariantControl.hpp:1234
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, NotchControl &c)
Definition TimeVariantControl.hpp:1288
constexpr T operator()(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:1286
constexpr void reset()
Definition TimeVariantControl.hpp:1292
A P (Proportional) controller.
Definition TimeVariantControl.hpp:46
constexpr void reset()
resets the internal states of the filter
Definition TimeVariantControl.hpp:114
constexpr T input(const T &u, const T &Ts)
Adds a new sample.
Definition TimeVariantControl.hpp:88
constexpr T input(const T &u)
Adds a new sample.
Definition TimeVariantControl.hpp:80
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, PControl &c)
Definition TimeVariantControl.hpp:105
constexpr PControl(const T &kp)
Construct a P (Proportional) controller with a constant gain.
Definition TimeVariantControl.hpp:62
constexpr void kp(const T &kp)
sets the proportional gain
Definition TimeVariantControl.hpp:68
constexpr PControl(const PControl &)=default
Default copy constructor.
constexpr T operator()(const T &u)
Adds a new sample.
Definition TimeVariantControl.hpp:95
T value_type
Definition TimeVariantControl.hpp:48
constexpr const T & kp() const
returns the current gain
Definition TimeVariantControl.hpp:73
A PI (Proportional Integral) controller with varying sample-times.
Definition TimeVariantControl.hpp:800
constexpr T operator()(const T &u, const T &Ts)
Input a new sample to the controller.
Definition TimeVariantControl.hpp:899
constexpr void ki(const T &ki)
sets the integral gain
Definition TimeVariantControl.hpp:838
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, PIAntiWindup &c)
Definition TimeVariantControl.hpp:901
constexpr const T & min_limit() const
returns the minimal value limit
Definition TimeVariantControl.hpp:871
constexpr void min_limit(const T &min)
Sets the minimal value limit.
Definition TimeVariantControl.hpp:868
constexpr void prate_limit(const T &pv)
Sets the positive rate limit of the I controller.
Definition TimeVariantControl.hpp:847
constexpr const T & kp() const
returns the current gain
Definition TimeVariantControl.hpp:832
constexpr const T & prate_limit() const
returns the positive rate limit
Definition TimeVariantControl.hpp:850
constexpr T input(const T &u, const T &Ts)
Input a new sample to the controller.
Definition TimeVariantControl.hpp:879
constexpr const T & nrate_limit() const
returns the negative rate limit
Definition TimeVariantControl.hpp:857
constexpr void reset()
resets (clears) the internal states resets the internal states ( , ) to zero
Definition TimeVariantControl.hpp:909
PIAntiWindup(const PIAntiWindup &)=default
constexpr const T & ki() const
returns the current gain
Definition TimeVariantControl.hpp:843
constexpr void max_limit(const T &max)
Sets the maximal value limit.
Definition TimeVariantControl.hpp:861
constexpr const T & max_limit() const
returns the maximal value limit
Definition TimeVariantControl.hpp:864
constexpr void kp(const T &kp)
sets the proportional gain
Definition TimeVariantControl.hpp:827
constexpr void nrate_limit(const T &nv)
Sets the negative rate limit of the I controller.
Definition TimeVariantControl.hpp:854
PIAntiWindup(const T &kp, const T &ki, const T &min, const T &max, const T &vn=std::numeric_limits< T >::lowest(), const T &vp=std::numeric_limits< T >::max())
Constructs a PI (proportional + integral) controller with anti-windup.
Definition TimeVariantControl.hpp:816
A PI (Proportional Integral) controller with varying sample-times.
Definition TimeVariantControl.hpp:717
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, PIControl &c)
Definition TimeVariantControl.hpp:741
PIControl(const PIControl &)=default
constexpr T input(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:734
PIControl(const T &kp, const T &ki)
Definition TimeVariantControl.hpp:728
constexpr void reset()
Definition TimeVariantControl.hpp:745
constexpr T operator()(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:739
Definition TimeVariantControl.hpp:1125
A PID (proportional + integral + differential) controller with variable sample-times.
Definition TimeVariantControl.hpp:1047
constexpr T operator()(const T &u, const T &Ts)
resets (clears) the internal states resets the internal states ( , , and ) to zero
Definition TimeVariantControl.hpp:1108
constexpr T input(const T &u, const T &Ts)
Input a new sample to the controller.
Definition TimeVariantControl.hpp:1099
constexpr void reset()
resets (clears) the internal states resets the internal states ( , , and ) to zero
Definition TimeVariantControl.hpp:1118
PIDControl(const T &kp, const T &ki, const T &kd, const T &omega)
constructs a PID controller form gain parameters
Definition TimeVariantControl.hpp:1062
static PIDControl from_alpha_tune(const T &alpha, const T &omega_c, const T &mag_G)
Constructa a PID controller using the alpha tuning method.
Definition TimeVariantControl.hpp:1084
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, PIDControl &c)
Definition TimeVariantControl.hpp:1110
A PT1 (proportional time first order) filter (=low-pass element of order 1), with varying smaple-time...
Definition TimeVariantControl.hpp:501
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, PT1Control &c)
Definition TimeVariantControl.hpp:548
constexpr PT1Control(const T &K, const T &omega)
Constructs a low-pass filter.
Definition TimeVariantControl.hpp:514
constexpr void reset()
Definition TimeVariantControl.hpp:552
constexpr void set_omega(const T &w)
Definition TimeVariantControl.hpp:524
constexpr void set_gain(const T &g)
Definition TimeVariantControl.hpp:521
constexpr const T & gain() const
Definition TimeVariantControl.hpp:522
constexpr T operator()(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:546
constexpr const T & omega() const
Definition TimeVariantControl.hpp:525
constexpr PT1Control(const PT1Control &)=default
Default copy constructor.
constexpr T input(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:527
A Thamed PI controller (PI controller with a low pass filter) with variable sample-times.
Definition TimeVariantControl.hpp:969
constexpr PT1IControl(const T &kp, const T &ki, const T &omega)
Constructs a PT1I (proportional time delayed + integral) controller.
Definition TimeVariantControl.hpp:985
constexpr void reset()
resets (clears) the internal states resets the internal states ( , , and ) to zero
Definition TimeVariantControl.hpp:1018
constexpr T input(const T &u, const T &Ts)
Input a new sample to the controller.
Definition TimeVariantControl.hpp:996
constexpr PT1IControl(const PT1IControl &)=default
constexpr T operator()(const T &u, const T &Ts)
Input a new sample to the controller.
Definition TimeVariantControl.hpp:1008
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, PT1IControl &c)
Definition TimeVariantControl.hpp:1010
A PT2 (proportional time second order) filter (=low-pass element of order 1), with varying smaple-tim...
Definition TimeVariantControl.hpp:599
constexpr T operator()(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:667
PT2Control(const PT2Control &)=default
constexpr void reset()
Definition TimeVariantControl.hpp:673
friend constexpr ValueSampletimePair< T > operator>>(const ValueSampletimePair< T > &p, PT2Control &c)
Definition TimeVariantControl.hpp:669
constexpr T input(const T &u, const T &Ts)
Definition TimeVariantControl.hpp:620
PT2Control(const T &K, const T &D, const T &omega)
constructs a PT2 element
Definition TimeVariantControl.hpp:615
The main namespace for the Control++ library.
Definition Bode.cpp:3
Definition TimeVariantControl.hpp:23
T value
Definition TimeVariantControl.hpp:24
T sample_time
Definition TimeVariantControl.hpp:25