From 925601f4f5b19b75630503d1ad75373866c1c462 Mon Sep 17 00:00:00 2001 From: linuswck Date: Fri, 10 May 2024 10:28:56 +0800 Subject: [PATCH] rm pid setpoint change kick --- src/pid.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pid.rs b/src/pid.rs index 9708135..afc6451 100644 --- a/src/pid.rs +++ b/src/pid.rs @@ -54,15 +54,13 @@ impl Controller { // + x0 * (kp + ki + kd) // - x1 * (kp + 2kd) // + x2 * kd - // + kp * (u0 - u1) // y0 = clip(y0', ymin, ymax) pub fn update(&mut self, input: f64) -> f64 { let mut output: f64 = self.y1 - self.target * f64::from(self.parameters.ki) + input * f64::from(self.parameters.kp + self.parameters.ki + self.parameters.kd) - self.x1 * f64::from(self.parameters.kp + 2.0 * self.parameters.kd) - + self.x2 * f64::from(self.parameters.kd) - + f64::from(self.parameters.kp) * (self.target - self.u1); + + self.x2 * f64::from(self.parameters.kd); if output < self.parameters.output_min.into() { output = self.parameters.output_min.into(); } -- 2.44.2