Package frc.spectrumLib.telemetry
Class BatteryLogger
java.lang.Object
frc.spectrumLib.telemetry.BatteryLogger
Tracks and logs current draw, power, cumulative energy consumption, peak current/power, and
sustained current windows useful for breaker thermal analysis.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleHighest rolling-average current over a 20-second window, in amps.doubleHighest rolling-average current over a 45-second window, in amps.doubleHighest rolling-average current over a 60-second window, in amps.doublePeak instantaneous current observed since reset, in amps.doublePeak instantaneous power observed since reset, in watts.doubleRunning total of current draw accumulated since the lastlogPower()call, in amps.doubleCumulative energy consumed over the entire enabled session, in joules.doubleRunning total of power accumulated since the lastlogPower()call, in watts.voidlogPower()Appends control-overhead current consumers (roboRIO, CANcoders, Pigeon, CANivore, radio), updates rolling-current windows, logs all telemetry, and resets per-loop accumulators.voidreportCurrentUsage(String key, double... amps) Records the current draw for a named subsystem channel and accumulates it into the running totals.voidResets all peak and rolling-window metrics.voidsetBatteryVoltage(double batteryVoltage) Battery terminal voltage used to convert current to power, in volts.voidsetEnabled(boolean enabled) Whenfalseall methods are no-ops, allowing the logger to be disabled at runtime.voidsetRioCurrent(double rioCurrent) Estimated current drawn by the RoboRIO itself, in amps.
-
Constructor Details
-
BatteryLogger
public BatteryLogger()
-
-
Method Details
-
reportCurrentUsage
Records the current draw for a named subsystem channel and accumulates it into the running totals. Thekeymay use "/" or "-" as separators; parent keys are automatically aggregated.- Parameters:
key- Hierarchical name for the current consumer (e.g."Drive/FrontLeft")amps- One or more current readings in amps; absolute values are summed
-
logPower
public void logPower()Appends control-overhead current consumers (roboRIO, CANcoders, Pigeon, CANivore, radio), updates rolling-current windows, logs all telemetry, and resets per-loop accumulators. -
resetMaximums
public void resetMaximums()Resets all peak and rolling-window metrics. -
setEnabled
public void setEnabled(boolean enabled) Whenfalseall methods are no-ops, allowing the logger to be disabled at runtime. -
getTotalCurrent
public double getTotalCurrent()Running total of current draw accumulated since the lastlogPower()call, in amps. -
getTotalPower
public double getTotalPower()Running total of power accumulated since the lastlogPower()call, in watts. -
getTotalEnergy
public double getTotalEnergy()Cumulative energy consumed over the entire enabled session, in joules. -
getMaxCurrent
public double getMaxCurrent()Peak instantaneous current observed since reset, in amps. -
getMaxPower
public double getMaxPower()Peak instantaneous power observed since reset, in watts. -
getMax20sCurrentA
public double getMax20sCurrentA()Highest rolling-average current over a 20-second window, in amps. -
getMax45sCurrentA
public double getMax45sCurrentA()Highest rolling-average current over a 45-second window, in amps. -
getMax60sCurrentA
public double getMax60sCurrentA()Highest rolling-average current over a 60-second window, in amps. -
setBatteryVoltage
public void setBatteryVoltage(double batteryVoltage) Battery terminal voltage used to convert current to power, in volts. -
setRioCurrent
public void setRioCurrent(double rioCurrent) Estimated current drawn by the RoboRIO itself, in amps.
-