From: WesleyWong-972 Date: Sat, 7 Mar 2026 00:17:52 +0000 (-0800) Subject: not broken X-Git-Url: https://git.taranathan.com/?a=commitdiff_plain;h=9868673a681c3b8d8d8f385991e9c2532cd8ccdc;p=FRC2026.git not broken --- diff --git a/src/main/java/frc/robot/commands/gpm/RunSpindexer.java b/src/main/java/frc/robot/commands/gpm/RunSpindexer.java index f0973bb..bcdbf65 100644 --- a/src/main/java/frc/robot/commands/gpm/RunSpindexer.java +++ b/src/main/java/frc/robot/commands/gpm/RunSpindexer.java @@ -10,9 +10,12 @@ import frc.robot.subsystems.turret.Turret; public class RunSpindexer extends Command { private Spindexer spindexer; private Turret turret; - private Debouncer jam_debouncer = new Debouncer(SpindexerConstants.JAM_DEBOUNCE_TIME, DebounceType.kFalling); + + private Debouncer jam_debouncer = new Debouncer(SpindexerConstants.JAM_DEBOUNCE_TIME, DebounceType.kRising); // if their is jam I would think this is 0 -> 1 + private Debouncer reversing_debouncer = new Debouncer(SpindexerConstants.REVERSE_DEBOUNCE_TIME, DebounceType.kFalling); // if there is a release in time Idk what it would be (kfalling vs krising) + private boolean reversing = false; - public RunSpindexer(Spindexer spindexer, Turret turret){ + public RunSpindexer(Spindexer spindexer, Turret turret) { this.spindexer = spindexer; this.turret = turret; addRequirements(spindexer, turret); @@ -26,19 +29,19 @@ public class RunSpindexer extends Command { return; // this is so the balls don't fly out when unaligned } boolean jammed = spindexer.getStatorCurrent() > SpindexerConstants.JAM_CURRENT_THRESHOLD; - if (jammed) { + if (jam_debouncer.calculate(jammed)) { reversing = true; - jam_debouncer.calculate(false); + System.out.println("Reversing the spindexer for Anti-Jam"); } - - if (reversing) { + if (!reversing) { + spindexer.maxSpindexer(); + } else { spindexer.reverseSpindexer(); - - if (jam_debouncer.calculate(!jammed)) { + if (reversing_debouncer.calculate(reversing)) { reversing = false; + reversing_debouncer.calculate(false); + jam_debouncer.calculate(false); } - } else { - spindexer.maxSpindexer(); } } diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java index ec4bd9d..6a61161 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java @@ -9,4 +9,5 @@ public class SpindexerConstants { public static final double CURRENT_TIME_LIMIT = 1.0; //s public static final double JAM_CURRENT_THRESHOLD = 9.0; // A public static final double JAM_DEBOUNCE_TIME = 0.3; // seconds + public static final double REVERSE_DEBOUNCE_TIME = 0.75; // seconds }