clip instead

pull/33970/head
Shane Smiskol 7 months ago
parent 7b80d4f050
commit 58df99a37f
  1. 7
      common/pid.py

@ -64,9 +64,14 @@ class PIDController:
# Update when changing i will move the control away from the limits
# or when i will move towards the sign of the error
if (self.neg_limit <= control <= self.pos_limit or control * error < 0) and not freeze_integrator:
# if (self.neg_limit <= control <= self.pos_limit or control * error < 0) and not freeze_integrator:
if not freeze_integrator:
self.i = i
control_no_i = self.p + self.d + self.f
control_no_i = clip(control_no_i, self.neg_limit, self.pos_limit)
self.i = clip(self.i, self.neg_limit - control_no_i, self.pos_limit - control_no_i)
control = self.p + self.i + self.d + self.f
self.control = clip(control, self.neg_limit, self.pos_limit)

Loading…
Cancel
Save