From d475c305bfdae78ebe9e67422c05064d8534e73f Mon Sep 17 00:00:00 2001 From: vivi-o Date: Sun, 22 Feb 2026 09:42:39 -0800 Subject: [PATCH] get accumulated current over the robot runnning time --- src/main/java/frc/robot/Robot.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 372cdff..2a01ef8 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -171,6 +171,12 @@ public enum RobotEdition { private static final double lowBatteryDisabledTime = 1.5; private static final double lowBatteryMinCycleCount = 10; + private final PowerDistribution pd = new PowerDistribution(); + private final Timer timer = new Timer(); + private double lastTimeStamp = 0.0; + private double totalCurrent = 0.0; + private double accumulatedCurrentAmps = 0.0; + /** * As per the 2026+ ctre api we should be passing in the actual canbus object to any ctre device * constructors, NOT the name as a string @@ -664,6 +670,18 @@ private void addControllerBindings(Indexer indexer, Shooter shooter, Intake inta .onFalse(Commands.runOnce(() -> operatorJoystickDisconnectedAlert.set(false))); } + @AutoLogOutput(key = "Robot/Accumulated Current Amp") + private double AccumulatedCurrentAmp() { + double timeStamp = timer.getFPGATimestamp(); + double dt = timeStamp - lastTimeStamp; + lastTimeStamp = timeStamp; + totalCurrent = pd.getTotalCurrent(); + + // integrate! + accumulatedCurrentAmps += totalCurrent * dt; + return accumulatedCurrentAmps; + } + private void addAutos() { System.out.println("------- Regenerating Autos"); System.out.println(