Class BatteryLogger

java.lang.Object
frc.spectrumLib.telemetry.BatteryLogger

public class BatteryLogger extends Object
Tracks and logs current draw, power, cumulative energy consumption, peak current/power, and sustained current windows useful for breaker thermal analysis.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Highest rolling-average current over a 20-second window, in amps.
    double
    Highest rolling-average current over a 45-second window, in amps.
    double
    Highest rolling-average current over a 60-second window, in amps.
    double
    Peak instantaneous current observed since reset, in amps.
    double
    Peak instantaneous power observed since reset, in watts.
    double
    Running total of current draw accumulated since the last logPower() call, in amps.
    double
    Cumulative energy consumed over the entire enabled session, in joules.
    double
    Running total of power accumulated since the last logPower() call, in watts.
    void
    Appends control-overhead current consumers (roboRIO, CANcoders, Pigeon, CANivore, radio), updates rolling-current windows, logs all telemetry, and resets per-loop accumulators.
    void
    reportCurrentUsage(String key, double... amps)
    Records the current draw for a named subsystem channel and accumulates it into the running totals.
    void
    Resets all peak and rolling-window metrics.
    void
    setBatteryVoltage(double batteryVoltage)
    Battery terminal voltage used to convert current to power, in volts.
    void
    setEnabled(boolean enabled)
    When false all methods are no-ops, allowing the logger to be disabled at runtime.
    void
    setRioCurrent(double rioCurrent)
    Estimated current drawn by the RoboRIO itself, in amps.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BatteryLogger

      public BatteryLogger()
  • Method Details

    • reportCurrentUsage

      public void reportCurrentUsage(String key, double... amps)
      Records the current draw for a named subsystem channel and accumulates it into the running totals. The key may 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)
      When false all methods are no-ops, allowing the logger to be disabled at runtime.
    • getTotalCurrent

      public double getTotalCurrent()
      Running total of current draw accumulated since the last logPower() call, in amps.
    • getTotalPower

      public double getTotalPower()
      Running total of power accumulated since the last logPower() 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.