]> git.taranathan.com Git - FRC2026.git/commitdiff
forgot the debouncer
authormaxwtan <100314265+MaxwellTTan20@users.noreply.github.com>
Tue, 24 Feb 2026 04:07:12 +0000 (20:07 -0800)
committermaxwtan <100314265+MaxwellTTan20@users.noreply.github.com>
Tue, 24 Feb 2026 04:07:12 +0000 (20:07 -0800)
src/main/java/frc/robot/subsystems/turret/Turret.java

index cbab18d1b42f797019d472776d885de4e7ea53b5..3a9cc27ae576bdbb8c6ff3564924d273f4e92028 100644 (file)
@@ -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{