Quote:
Originally Posted by team-4480
So if I did a state machine for that setSetpoint like this:
Code:
if state == 1:
setSetpoint(90)
state = 2
elif state ==2:
if onTarget():
state=3
Would that solve the issue?
|
That seems to be a bit more complex than necessary. First, don't ignore the other suggestions on this thread -- proper tuning will go a long way also. But, if you want onTarget to work, then a simpler solution is:
Code:
self.last = None
...
if self.last is None or abs(self.last - target) > 0.001:
self.pid_controller.setSetpoint(target)
self.last = target