18 #ifndef hifi_PIDController_h
19 #define hifi_PIDController_h
30 void setMeasuredValueSetpoint(
float newValue) { _measuredValueSetpoint = newValue; }
31 float update(
float measuredValue,
float dt,
bool resetAccumulator =
false);
32 void setHistorySize(QString label = QString(
""),
int size = 0) { _history.reserve(size); _history.resize(0); _label = label; }
34 bool getIsLogging() {
return !_label.isEmpty(); }
35 float getMeasuredValueSetpoint()
const {
return _measuredValueSetpoint; }
38 float getControlledValueLowLimit()
const {
return _controlledValueLowLimit; }
39 float getControlledValueHighLimit()
const {
return _controlledValueHighLimit; }
40 float getAntiWindupFactor()
const {
return _antiWindupFactor; }
41 float getKP()
const {
return _kp; }
42 float getKI()
const {
return _ki; }
43 float getKD()
const {
return _kd; }
44 float getAccumulatedValueHighLimit()
const {
return getAntiWindupFactor() * getMeasuredValueSetpoint(); }
45 float getAccumulatedValueLowLimit()
const {
return -getAntiWindupFactor() * getMeasuredValueSetpoint(); }
49 void setControlledValueLowLimit(
float newValue) { _controlledValueLowLimit = newValue; }
50 void setControlledValueHighLimit(
float newValue) { _controlledValueHighLimit = newValue; }
51 void setAntiWindupFactor(
float newValue) { _antiWindupFactor = newValue; }
52 void setKP(
float newValue) { _kp = newValue; }
53 void setKI(
float newValue) { _ki = newValue; }
54 void setKD(
float newValue) { _kd = newValue; }
70 void updateHistory(
float measured,
float dt,
float error,
float accumulatedError,
float changeInErro,
float p,
float i,
float d,
float computedValue);
71 float _measuredValueSetpoint { 0.0f };
72 float _controlledValueLowLimit { 0.0f };
73 float _controlledValueHighLimit { std::numeric_limits<float>::max() };
74 float _antiWindupFactor { 10.0f };
80 float _lastError{ 0.0f };
81 float _lastAccumulation{ 0.0f };
84 QVector<Row> _history{};