From: Wesley28w Date: Sat, 18 Apr 2026 00:31:19 +0000 (-0700) Subject: breaking check X-Git-Url: https://git.taranathan.com/?a=commitdiff_plain;h=c552358687ccd15fd5fe315af06405c69ea6a728;p=FRC2026.git breaking check --- diff --git a/src/main/java/frc/robot/subsystems/Breaker/Breaker.java b/src/main/java/frc/robot/subsystems/Breaker/Breaker.java index 7f7af64..e664449 100644 --- a/src/main/java/frc/robot/subsystems/Breaker/Breaker.java +++ b/src/main/java/frc/robot/subsystems/Breaker/Breaker.java @@ -27,10 +27,27 @@ public class Breaker extends SubsystemBase { for (double index : trimmedCurrents) { sum += index; } - return sum/trimmedCurrents.size(); } + public boolean thresholdPassed(double threshold, double secondsBackward) { + return average(secondsBackward) > threshold; + } + + public boolean checkThresholdsBroken() { + if ( + thresholdPassed(BreakerConstants.HALF_SECOND_THRESHOLD_AMPS, 0.5) + || thresholdPassed(BreakerConstants.ONE_SECOND_THRESHOLD_AMPS, 1) + || thresholdPassed(BreakerConstants.TWO_SECOND_THRESHOLD_AMPS, 2) + || thresholdPassed(BreakerConstants.FOUR_SECOND_THRESHOLD_AMPS, 4) + || thresholdPassed(BreakerConstants.EIGHT_SECOND_THRESHOLD_AMPS, 8) + ) { + return true; + } else { + return false; + } + } + public double getCurrentFromPowerDistribution() { return pDis.getTotalCurrent(); // not using .getCurrent() and then an arguement for the port you can get just one port } diff --git a/src/main/java/frc/robot/subsystems/Breaker/BreakerConstants.java b/src/main/java/frc/robot/subsystems/Breaker/BreakerConstants.java new file mode 100644 index 0000000..eba9dc6 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Breaker/BreakerConstants.java @@ -0,0 +1,10 @@ +package frc.robot.subsystems.Breaker; + +public class BreakerConstants { + public static final double HALF_SECOND_THRESHOLD_AMPS = 67.0; + public static final double ONE_SECOND_THRESHOLD_AMPS = 67.0; + public static final double TWO_SECOND_THRESHOLD_AMPS = 67.0; + public static final double FOUR_SECOND_THRESHOLD_AMPS = 67.0; + public static final double EIGHT_SECOND_THRESHOLD_AMPS = 67.0; + // TODO: add other time thresholds for the breaker +}