Class BatteryCheck

java.lang.Object
frc.spectrumLib.checks.BatteryCheck
All Implemented Interfaces:
Check

public final class BatteryCheck extends Object implements Check
The battery at rest is charged, and is not the one used in the last match.

Voltage: disabled, the robot draws only its controllers and coprocessors, so the reading is close to the pack's resting voltage. It must stay under a threshold for HOLD_SECONDS before it counts, so a mechanism moved by hand or a camera booting does not trip it.

The thresholds are for the voltage at the battery. Each controller reads it a little off, so the reading is corrected by the robot's calibration offset. A robot whose offset has not been measured warns at most on voltage: a FAIL there could be the controller, not the battery.

Same battery (6328 2024): when a match starts, the battery's ID is saved; at the next boot, the same ID means nobody swapped it. Needs a battery ID (an NFC tag reader); without one this part is skipped.

  • Field Details

    • WARN_VOLTS

      public static final double WARN_VOLTS
      A full pack reads 12.6-12.9 V disabled on FM's SystemCore (TXMAN1 pre-match, nine logs: lowest 12.57 V). Below this, it has been used.
      See Also:
    • FAIL_VOLTS

      public static final double FAIL_VOLTS
      Below this at rest, a match's load will brown it out.
      See Also:
    • HOLD_SECONDS

      public static final double HOLD_SECONDS
      See Also:
  • Constructor Details

    • BatteryCheck

      public BatteryCheck(DoubleSupplier volts, BooleanSupplier atRest, Supplier<BatteryCheck.Identity> identity)
      A check on a reading that is already calibrated (offset 0).
      Parameters:
      volts - battery voltage, a logged input
      atRest - whether the robot is disabled; sag while enabled is load, not charge
      identity - the battery in the robot and the one in the last match; BatteryCheck.Identity.NONE without a reader
    • BatteryCheck

      public BatteryCheck(DoubleSupplier volts, OptionalDouble offsetVolts, BooleanSupplier atRest, Supplier<BatteryCheck.Identity> identity)
      Parameters:
      volts - battery voltage as the controller reads it, a logged input
      offsetVolts - added to the reading to give the voltage at the battery; empty when it has not been measured on this robot
      atRest - whether the robot is disabled; sag while enabled is load, not charge
      identity - the battery in the robot and the one in the last match; BatteryCheck.Identity.NONE without a reader
  • Method Details

    • observe

      public void observe(double now)
      Description copied from interface: Check
      Called every loop, enabled or not, for checks that must see every loop: a reset flag that is true for one loop, or a condition that has to hold for some time. Keep it cheap.
      Specified by:
      observe in interface Check
      Parameters:
      now - this loop's robot time
    • evaluate

      public CheckResult evaluate(double now)
      Description copied from interface: Check
      Judges the robot now. Called only while disabled, and not every loop: PreMatchChecks spreads the checks across loops.
      Specified by:
      evaluate in interface Check
      Parameters:
      now - this loop's robot time
      Returns:
      the verdict