From: maxwtan <100314265+MaxwellTTan20@users.noreply.github.com> Date: Tue, 24 Feb 2026 04:07:12 +0000 (-0800) Subject: forgot the debouncer X-Git-Url: https://git.taranathan.com/?a=commitdiff_plain;h=19ce15a79fc59d6bbf938cba2d9b957b1bb62f72;p=FRC2026.git forgot the debouncer --- diff --git a/src/main/java/frc/robot/subsystems/turret/Turret.java b/src/main/java/frc/robot/subsystems/turret/Turret.java index cbab18d..3a9cc27 100644 --- a/src/main/java/frc/robot/subsystems/turret/Turret.java +++ b/src/main/java/frc/robot/subsystems/turret/Turret.java @@ -12,7 +12,9 @@ import com.ctre.phoenix6.signals.NeutralModeValue; import com.ctre.phoenix6.sim.TalonFXSimState; import edu.wpi.first.math.MathUtil; +import edu.wpi.first.math.filter.Debouncer; import edu.wpi.first.math.filter.LinearFilter; +import edu.wpi.first.math.filter.Debouncer.DebounceType; import edu.wpi.first.math.geometry.Rotation2d; import edu.wpi.first.math.util.Units; import edu.wpi.first.wpilibj.RobotBase; @@ -34,6 +36,7 @@ public class Turret extends SubsystemBase implements TurretIO{ private final TurretIOInputsAutoLogged inputs = new TurretIOInputsAutoLogged(); private boolean calibrating; + private Debouncer calibrationDebouncer = new Debouncer(0.5, DebounceType.kRising); /* ---------------- Hardware ---------------- */ @@ -211,7 +214,8 @@ public class Turret extends SubsystemBase implements TurretIO{ if(calibrating){ motor.set(0.05); - if(Math.abs(motor.getStatorCurrent().getValueAsDouble()) >= TurretConstants.CALIBRATION_CURRENT_THRESHOLD){ + boolean calibrated = Math.abs(motor.getStatorCurrent().getValueAsDouble()) >= TurretConstants.CALIBRATION_CURRENT_THRESHOLD; + if(calibrationDebouncer.calculate(calibrated)){ stopCalibrating(); } } else{