From 44cb540e1b7a1189f1dc88d0f28973f8c474e758 Mon Sep 17 00:00:00 2001 From: iefomit Date: Sat, 28 Mar 2026 20:58:11 -0700 Subject: [PATCH] change to timer --- .../java/frc/robot/commands/gpm/RunSpindexer.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/commands/gpm/RunSpindexer.java b/src/main/java/frc/robot/commands/gpm/RunSpindexer.java index 253bc85..c0af909 100644 --- a/src/main/java/frc/robot/commands/gpm/RunSpindexer.java +++ b/src/main/java/frc/robot/commands/gpm/RunSpindexer.java @@ -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; } } -- 2.39.5