]> git.taranathan.com Git - FRC2026.git/commitdiff
move to constants
authorWesleyWong-972 <wesleycwong@gmail.com>
Sun, 29 Mar 2026 18:28:31 +0000 (11:28 -0700)
committerWesleyWong-972 <wesleycwong@gmail.com>
Sun, 29 Mar 2026 18:28:31 +0000 (11:28 -0700)
src/main/java/frc/robot/commands/gpm/BrownOutControl.java
src/main/java/frc/robot/util/BrownOut/BrownOutConstants.java

index 0fecc1ee6aa50e4fccd46ce5cb68efad3b57425e..c5b34b7b240830daa4c604023a606290ded14b19 100644 (file)
@@ -48,18 +48,25 @@ public class BrownOutControl extends Command {
     public BrownOutLevel monitor() {
         // pretty sure this is where you get it. Need to check if this is same as logs. 
         // voltage 6.3 is brownout where issues occur, but 4.75 is dead robot
+        int level = 1;
         double batteryVoltage = RobotController.getBatteryVoltage();
-        if (batteryVoltage > 7.5) { // normal
+        if (batteryVoltage > BrownOutConstants.LEVEL_ONE_LIMIT) { // normal
             return levels[0];
-        } else if (batteryVoltage > 6.75) { // if 7.5 to 6.75
+            level = 1;
+        } else if (batteryVoltage > BrownOutConstants.LEVEL_TWO_LIMIT) { // if 7.5 to 6.75
             return levels[1]; // lower drivetrain
-        } else if (batteryVoltage > 6.0) { // if 6.75 to 6.0 (browning out)
+            level = 2;
+        } else if (batteryVoltage > BrownOutConstants.LEVEL_THREE_LIMIT) { // if 6.75 to 6.0 (browning out)
             return levels[2];
-        } else if (batteryVoltage > 5.25) { // if 6.0 to 5.0 (mayday)
+            level = 3;
+        } else if (batteryVoltage > BrownOutConstants.LEVEL_FOUR_LIMIT) { // if 6.0 to 5.0 (mayday)
             return levels[3];
+            level = 4;
         } else { // were are on life support at this point 5.25 to 4.75
             return levels[4];
+            level = 5;
         }
+        Logger.recordOutput("BrownoutProtection/Level", level);
     }
 
     public void applyLevel(BrownOutLevel level) {
@@ -78,6 +85,7 @@ public class BrownOutControl extends Command {
         spindexer.setNewCurrentLimit(spindexerCurrent);
         intake.setCurrentLimits(intakeCurrent);
         drivetrain.applyNewModuleCurrents(steerCurrent, driveCurrent);
+
     }
 
     @Override
index b560936ebc27c6ed10ec193617615da6c099e6dd..a48a97c127f4cd111668be217f9585a586be585a 100644 (file)
@@ -22,6 +22,12 @@ public class BrownOutConstants {
     // currently for show. I would imagine u would decrease movement: drivetrain, then bps impacters: intake/indexing speed, and then a bit on aiming: turret/hood. 
     // I don't see a world where you would decrease shooter current, but we need to do some testing to see how much current we are at when shooting
     
+    // level numbers
+    public static final double LEVEL_ONE_LIMIT = 7.5;
+    public static final double LEVEL_TWO_LIMIT = 6.75;
+    public static final double LEVEL_THREE_LIMIT = 6.0;
+    public static final double LEVEL_FOUR_LIMIT = 5.25;
+
     // normal
     public static final BrownOutLevel BROWNOUT_LVL_ONE = new BrownOutLevel(
         ShooterConstants.SHOOTER_CURRENT_LIMIT,