fix the negative sign scope (#1696)

This commit is contained in:
Raja Subramanian
2023-05-09 00:13:01 +05:30
committed by GitHub
parent 153f02091c
commit 0e582ec82a

View File

@@ -1855,7 +1855,7 @@ func (p *PIDController) Update(setpoint, measurement float64, at time.Time) floa
}
p.iVal = boundIVal
p.dVal = (-2.0*p.kd*(measurement-p.prevMeasurement) + (2.0*p.tau-duration)*p.dVal) / (2.0*p.tau + duration)
p.dVal = -(2.0*p.kd*(measurement-p.prevMeasurement) + (2.0*p.tau-duration)*p.dVal) / (2.0*p.tau + duration)
output := proportional + p.iVal + p.dVal
boundOutput := output