Class BatteryCheck
java.lang.Object
frc.spectrumLib.checks.BatteryCheck
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe battery IDs this check compares, from logged inputs. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleBelow this at rest, a match's load will brown it out.static final doublestatic final doubleA full pack reads 12.6-12.9 V disabled on FM's SystemCore (TXMAN1 pre-match, nine logs: lowest 12.57 V). -
Constructor Summary
ConstructorsConstructorDescriptionBatteryCheck(DoubleSupplier volts, BooleanSupplier atRest, Supplier<BatteryCheck.Identity> identity) A check on a reading that is already calibrated (offset 0).BatteryCheck(DoubleSupplier volts, OptionalDouble offsetVolts, BooleanSupplier atRest, Supplier<BatteryCheck.Identity> identity) -
Method Summary
-
Field Details
-
WARN_VOLTS
public static final double WARN_VOLTSA 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_VOLTSBelow 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 inputatRest- whether the robot is disabled; sag while enabled is load, not chargeidentity- the battery in the robot and the one in the last match;BatteryCheck.Identity.NONEwithout 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 inputoffsetVolts- added to the reading to give the voltage at the battery; empty when it has not been measured on this robotatRest- whether the robot is disabled; sag while enabled is load, not chargeidentity- the battery in the robot and the one in the last match;BatteryCheck.Identity.NONEwithout a reader
-
-
Method Details
-
observe
public void observe(double now) Description copied from interface:CheckCalled 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. -
evaluate
Description copied from interface:CheckJudges the robot now. Called only while disabled, and not every loop:PreMatchChecksspreads the checks across loops.
-