]> git.taranathan.com Git - FRC2026.git/commitdiff
breaking check
authorWesley28w <wesleycwong@gmail.com>
Sat, 18 Apr 2026 00:31:19 +0000 (17:31 -0700)
committerWesley28w <wesleycwong@gmail.com>
Sat, 18 Apr 2026 00:31:19 +0000 (17:31 -0700)
src/main/java/frc/robot/subsystems/Breaker/Breaker.java
src/main/java/frc/robot/subsystems/Breaker/BreakerConstants.java [new file with mode: 0644]

index 7f7af64c915e6439746f90f147be5b11b0222742..e6644491e45af0e60e43a1cb83ac7ac14a45611c 100644 (file)
@@ -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 (file)
index 0000000..eba9dc6
--- /dev/null
@@ -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
+}