Quote:
Originally Posted by jwakeman
I ran into this tonight as well. Last year the implementation of PIDController:GetError() just set error = m_error inside the critical section. Anyone know the reason for now trying to set error = GetSetpoint() - m_pidInput->PIDGet()? Seemed like just returning m_error was good enough..
|
After this weekend I think I understand now why they attempted to update the GetError() method this year. With last year's implementation the following code results in a race condition. It will not work if the OnTarget() method ends up running before the PID gets a chance to run its calculation loop at least once.
Code:
myPID->SetSetpoint();
while(!myPID->OnTarget()){}