From 3f1a462c0c83e6aa6d74d2d68189a85a210d6081 Mon Sep 17 00:00:00 2001 From: AluskyWolf Date: Fri, 12 Dec 2025 17:13:20 -0800 Subject: [PATCH 1/5] added low battery alert --- src/main/java/frc/robot/Robot.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 45ca9d5..f9a3371 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -11,6 +11,14 @@ import edu.wpi.first.wpilibj2.command.CommandScheduler; import frc.robot.LimelightHelpers.PoseEstimate; +private static final double kLowBatteryVoltage = 11.8; +private static final double kLowBatteryDisabledTime = 1.5; +private static final int kLowBatteryMinCycles = 10; + +private int lowBatteryCycleCount = 0; +private final Timer disabledTimer = new Timer(); +private boolean lowBatteryAlert = false; + public class Robot extends TimedRobot { private Command m_autonomousCommand; @@ -124,6 +132,8 @@ public void robotInit() { DriverStation.silenceJoystickConnectionWarning(true); } + disabledTimer.start(); + } @Override @@ -164,6 +174,20 @@ public void robotPeriodic() { } */ } + lowBatteryCycleCount++; + + if(DriverStation.isEnabled()){ + disabledTimer.reset(); + } + double batteryVoltage = RobotController.getBatteryVoltage(); + + if(batteryVoltage<= kLowBatteryVoltage && disabledTimer.hasElapsed(kLowBatteryDisabledTime) && lowBatteryCycleCount >= kLowBatteryMinCycles){ + lowBatteryAlert = true; + } else { + lowBatteryAlert = false; + } + + SmartDashboard.putBoolean("LowBattery", lowBatteryAlert); } @Override From 93170285ef7a34375e4ff5e16ff60f4e7a148967 Mon Sep 17 00:00:00 2001 From: AluskyWolf Date: Fri, 12 Dec 2025 17:23:47 -0800 Subject: [PATCH 2/5] fixed error --- src/main/java/frc/robot/Robot.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index f9a3371..27469cf 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -11,15 +11,17 @@ import edu.wpi.first.wpilibj2.command.CommandScheduler; import frc.robot.LimelightHelpers.PoseEstimate; -private static final double kLowBatteryVoltage = 11.8; -private static final double kLowBatteryDisabledTime = 1.5; -private static final int kLowBatteryMinCycles = 10; +public class Robot extends TimedRobot { + + private static final double kLowBatteryVoltage = 11.8; + private static final double kLowBatteryDisabledTime = 1.5; + private static final int kLowBatteryMinCycles = 10; + + private int lowBatteryCycleCount = 0; + private final Timer disabledTimer = new Timer(); + private boolean lowBatteryAlert = false; -private int lowBatteryCycleCount = 0; -private final Timer disabledTimer = new Timer(); -private boolean lowBatteryAlert = false; -public class Robot extends TimedRobot { private Command m_autonomousCommand; private final RobotContainer m_container = new RobotContainer(); From 879292169265c9d7039f1f2332787195b8d890e9 Mon Sep 17 00:00:00 2001 From: AluskyWolf Date: Mon, 15 Dec 2025 12:35:53 -0800 Subject: [PATCH 3/5] removed cycle count - was redundant --- src/main/java/frc/robot/Robot.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 27469cf..29acf6a 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -14,10 +14,8 @@ public class Robot extends TimedRobot { private static final double kLowBatteryVoltage = 11.8; - private static final double kLowBatteryDisabledTime = 1.5; - private static final int kLowBatteryMinCycles = 10; + private static final double kLowBatteryDisabledTime = 1.5; //seconds - private int lowBatteryCycleCount = 0; private final Timer disabledTimer = new Timer(); private boolean lowBatteryAlert = false; @@ -176,14 +174,13 @@ public void robotPeriodic() { } */ } - lowBatteryCycleCount++; if(DriverStation.isEnabled()){ disabledTimer.reset(); } double batteryVoltage = RobotController.getBatteryVoltage(); - if(batteryVoltage<= kLowBatteryVoltage && disabledTimer.hasElapsed(kLowBatteryDisabledTime) && lowBatteryCycleCount >= kLowBatteryMinCycles){ + if(batteryVoltage<= kLowBatteryVoltage && disabledTimer.hasElapsed(kLowBatteryDisabledTime)){ lowBatteryAlert = true; } else { lowBatteryAlert = false; From 85943b9d0c0b8aa0a14f261f48e196487b975c12 Mon Sep 17 00:00:00 2001 From: Bang Xiao Date: Sat, 20 Dec 2025 14:23:34 -0800 Subject: [PATCH 4/5] Replace disabledTimer with batteryTimer for monitoring Signed-off-by: Bang Xiao --- src/main/java/frc/robot/Robot.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 29acf6a..3e05cf0 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -16,7 +16,7 @@ public class Robot extends TimedRobot { private static final double kLowBatteryVoltage = 11.8; private static final double kLowBatteryDisabledTime = 1.5; //seconds - private final Timer disabledTimer = new Timer(); + private final Timer batteryTimer = new Timer(); private boolean lowBatteryAlert = false; @@ -176,11 +176,11 @@ public void robotPeriodic() { } if(DriverStation.isEnabled()){ - disabledTimer.reset(); + batteryTimer.reset(); } double batteryVoltage = RobotController.getBatteryVoltage(); - if(batteryVoltage<= kLowBatteryVoltage && disabledTimer.hasElapsed(kLowBatteryDisabledTime)){ + if(batteryVoltage<= kLowBatteryVoltage && batteryTimer.hasElapsed(kLowBatteryDisabledTime)){ lowBatteryAlert = true; } else { lowBatteryAlert = false; @@ -244,4 +244,4 @@ public void simulationPeriodic() { // If you have physics simulation, put it here // For now: do nothing fast } -} \ No newline at end of file +} From a53a6fbd48dfea660899ca7e257fa9e981616160 Mon Sep 17 00:00:00 2001 From: Bang Xiao Date: Sat, 20 Dec 2025 14:42:13 -0800 Subject: [PATCH 5/5] Update Robot.java Signed-off-by: Bang Xiao --- src/main/java/frc/robot/Robot.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 3e05cf0..2af5bc3 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -132,7 +132,7 @@ public void robotInit() { DriverStation.silenceJoystickConnectionWarning(true); } - disabledTimer.start(); + batteryTimer.start(); }