From 74edbb23a7f9db392eaf3fc5f3987269ca63cd55 Mon Sep 17 00:00:00 2001 From: "drew thompson (sr1899)" Date: Wed, 31 Jan 2018 15:45:23 -0800 Subject: [PATCH] removing homebrew PID to avoid confusion with WPILIB PIDController --- src/main/java/com/github/dozer/util/PID.java | 46 -------------------- 1 file changed, 46 deletions(-) delete mode 100644 src/main/java/com/github/dozer/util/PID.java diff --git a/src/main/java/com/github/dozer/util/PID.java b/src/main/java/com/github/dozer/util/PID.java deleted file mode 100644 index 83887c4..0000000 --- a/src/main/java/com/github/dozer/util/PID.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.github.dozer.util; - -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; - -public class PID { - - private final double maxSum; - - public double kp; - private double ki; - private double kd; - - private double lastError = 0; - public double errorSum = 0; - - private double outMin = -1; - private double outMax = 1; - - public PID(double kp, double ki, double kd, double maxSum) { - this.kp = kp; - this.ki = ki; - this.kd = kd; - this.maxSum = maxSum; - } - - public double compute(double input, double setpoint) { - double error = setpoint - input; - - this.errorSum += error * ki; - if (this.errorSum < -this.maxSum) - this.errorSum = -this.maxSum; - if (this.errorSum > this.maxSum) - this.errorSum = this.maxSum; - - SmartDashboard.putNumber("pid_error_sum", errorSum); - - double output = this.kp * error + this.errorSum - this.kd * (error - this.lastError); - if (output < this.outMin) - output = this.outMin; - if (output > this.outMax) - output = this.outMax; - - this.lastError = error; - return output; - } -}