]> git.taranathan.com Git - FRC2026.git/commitdiff
not broken
authorWesleyWong-972 <wesleycwong@gmail.com>
Sat, 7 Mar 2026 00:17:52 +0000 (16:17 -0800)
committerWesleyWong-972 <wesleycwong@gmail.com>
Sat, 7 Mar 2026 00:17:52 +0000 (16:17 -0800)
src/main/java/frc/robot/commands/gpm/RunSpindexer.java
src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java

index f0973bba483b10b5f8ba54ac72185a4894eabd33..bcdbf65ff7493a6024b81c836e2ad06a4fb566d5 100644 (file)
@@ -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();
         }
     }
 
index ec4bd9d68715ae4738291135fbb93007121a994e..6a61161ecbc87aa489ee96882801579f1b0d86af 100644 (file)
@@ -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
 }