]> git.taranathan.com Git - FRC2026.git/commitdiff
change to timer
authoriefomit <timofei.stem@gmail.com>
Sun, 29 Mar 2026 03:58:11 +0000 (20:58 -0700)
committeriefomit <timofei.stem@gmail.com>
Sun, 29 Mar 2026 03:58:11 +0000 (20:58 -0700)
src/main/java/frc/robot/commands/gpm/RunSpindexer.java

index 253bc855c9ea5028e715575c9b2a289185e5501b..c0af90904f11c8ec8451465babeec705a8648a3d 100644 (file)
@@ -2,6 +2,7 @@ package frc.robot.commands.gpm;
 
 import edu.wpi.first.math.filter.Debouncer;
 import edu.wpi.first.math.filter.Debouncer.DebounceType;
+import edu.wpi.first.wpilibj.Timer;
 import edu.wpi.first.wpilibj2.command.Command;
 import frc.robot.subsystems.hood.Hood;
 import frc.robot.subsystems.spindexer.Spindexer;
@@ -13,10 +14,10 @@ public class RunSpindexer extends Command {
     private Turret turret;
     private Hood hood;
 
-    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 Debouncer jam_debouncer = new Debouncer(SpindexerConstants.JAM_DEBOUNCE_TIME, DebounceType.kRising); // if there is jam I would think this is 0 -> 1
 
     private boolean reversing = false;
+    private Timer reverseTimer = new Timer();
     public RunSpindexer(Spindexer spindexer, Turret turret, Hood hood) {
         this.spindexer = spindexer;
         this.turret = turret;
@@ -40,14 +41,14 @@ public class RunSpindexer extends Command {
         boolean jammed = spindexer.getStatorCurrent() > SpindexerConstants.JAM_CURRENT_THRESHOLD;
         if (jam_debouncer.calculate(jammed)) {
             reversing = true;
-            reversing_debouncer.calculate(reversing);
-            // System.out.println("Reversing the spindexer for Anti-Jam");
+            reverseTimer.reset();
+            reverseTimer.start();
         }
         if (!reversing) {
             spindexer.maxSpindexer();
         } else {
             spindexer.reverseSpindexer();
-            if (!reversing_debouncer.calculate(false)) {
+            if (reverseTimer.hasElapsed(SpindexerConstants.REVERSE_DEBOUNCE_TIME)) {
                 reversing = false;
             }
         }