From 4bbe5f218c077678efea4af1c557f2a470497709 Mon Sep 17 00:00:00 2001 From: DanTheMan-byte Date: Fri, 28 Nov 2025 19:21:54 -0600 Subject: [PATCH] changes to PID --- .../firstinspires/ftc/teamcode/tests/ShooterTest.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/ShooterTest.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/ShooterTest.java index 4596845..960cd57 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/ShooterTest.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/tests/ShooterTest.java @@ -44,6 +44,8 @@ public class ShooterTest extends LinearOpMode { public static boolean intake = true; + public static int tolerance = 50; + public static double kP = 0.0005; // small proportional gain (tune this) public static double maxStep = 0.06; // prevents sudden jumps @@ -106,20 +108,21 @@ public class ShooterTest extends LinearOpMode { double feed = vel / maxVel; // Example: vel=2500 → feed=0.5 - // --- PROPORTIONAL CORRECTION --- + // --- PROPORTIONAL CORRECTION --- double error = vel - velo1; double correction = kP * error; - // limit how fast power changes (prevents oscillation) + // limit how fast power changes (prevents oscillation) correction = Math.max(-maxStep, Math.min(maxStep, correction)); - // --- FINAL MOTOR POWER --- + // --- FINAL MOTOR POWER --- powPID = feed + correction; - // clamp to allowed range + // clamp to allowed range powPID = Math.max(0, Math.min(1, powPID)); shooter.setVelocity(powPID); + if (shoot){ robot.transferServo.setPosition(transferServo_in); } else {