Class PreMatchChecks

java.lang.Object
frc.spectrumLib.checks.PreMatchChecks

public final class PreMatchChecks extends Object
Pre-match self-checks: a registry of Checks that run while the robot is disabled and add up to one GO / NO-GO.

Each check gives PASS, WARN, FAIL or SKIP with a one-line reason. The robot is NO-GO while any check fails; warnings are shown but do not change GO. Results are outputs, never inputs to anything: the checks are advisory and never stop the robot from enabling.

Outputs, under the prefix given (e.g. PreMatch):

  • Go and Reason: the verdict and one line saying why, on NetworkTables for Elastic and the pit app.
  • Summary: one line per check, "FAIL CAN: ...", on NetworkTables too.
  • Checks/<name>/Status and Checks/<name>/Reason.
  • Active: whether the checks are running (disabled, before a match starts). While not, the last results stay published but nothing is re-judged.

A failing check raises a HIGH alert and a warning a MEDIUM one, both cleared on enable: in a match the subsystems' own alerts speak for themselves. Once a match has started (the first enable with the FMS attached), the checks stay quiet until the FMS detaches, so the disabled gap between auto and teleop raises nothing; the pre-match results stay published as they were.

One check is evaluated per loop, in turn, so the cost is one check's work whatever the number registered. Every check's Check.observe(double) still runs every loop.

  • Constructor Details

    • PreMatchChecks

      public PreMatchChecks(String prefix)
      Parameters:
      prefix - log key prefix, e.g. "PreMatch"
  • Method Details

    • register

      public PreMatchChecks register(String name, Check check)
      Adds a check. Call at startup, before the first periodic(boolean, double).
      Parameters:
      name - short display name, also its log path (Checks/<name>/...)
      check - the check
      Returns:
      this, for chaining
    • periodic

      public void periodic(boolean disabled, double nowSeconds)
      Runs the checks with no FMS attached. Call once per loop on the main thread, after this loop's inputs are read.
      Parameters:
      disabled - whether the robot is disabled; the checks judge only then
      nowSeconds - this loop's robot time
    • periodic

      public void periodic(boolean disabled, boolean fmsAttached, double nowSeconds)
      Runs the checks. Call once per loop on the main thread, after this loop's inputs are read.
      Parameters:
      disabled - whether the robot is disabled; the checks judge only then, and not between the periods of a match
      fmsAttached - whether the FMS is attached, a logged input
      nowSeconds - this loop's robot time
    • isMatchStarted

      public boolean isMatchStarted()
      Whether a match has started (enabled with the FMS attached) and the FMS is still attached.
    • isGo

      public boolean isGo()
      Whether no check fails (and every check has been judged since the robot disabled).
    • getReason

      public String getReason()
      One line: GO or NO-GO, and the first failing (else warning) check's reason.
    • resultOf

      public CheckResult resultOf(String name)
      The latest result of a check, or null before it has been judged since the last disable.