From 81892ce5e24cc630df7059f91e1320bc629a7162 Mon Sep 17 00:00:00 2001 From: WesleyWong-972 Date: Sun, 29 Mar 2026 11:28:31 -0700 Subject: [PATCH] move to constants --- .../frc/robot/commands/gpm/BrownOutControl.java | 16 ++++++++++++---- .../robot/util/BrownOut/BrownOutConstants.java | 6 ++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/commands/gpm/BrownOutControl.java b/src/main/java/frc/robot/commands/gpm/BrownOutControl.java index 0fecc1e..c5b34b7 100644 --- a/src/main/java/frc/robot/commands/gpm/BrownOutControl.java +++ b/src/main/java/frc/robot/commands/gpm/BrownOutControl.java @@ -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 diff --git a/src/main/java/frc/robot/util/BrownOut/BrownOutConstants.java b/src/main/java/frc/robot/util/BrownOut/BrownOutConstants.java index b560936..a48a97c 100644 --- a/src/main/java/frc/robot/util/BrownOut/BrownOutConstants.java +++ b/src/main/java/frc/robot/util/BrownOut/BrownOutConstants.java @@ -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, -- 2.39.5