Class HardwareStamp

java.lang.Object
frc.spectrumLib.params.HardwareStamp

public final class HardwareStamp extends Object
Ties the pit-saved file of a hard-stop group (swerve offsets, soft limits) to the robot it was saved on, so a controller moved to another robot does not bring that robot's values with it.

The identity is a set of numbers the robot's own devices hold, read at boot before anything writes them. A saved file records the readings that this robot can show at later boots (the afterSave list). At boot, the file is used only if the readings match one of them. Otherwise, or if the devices could not be read, the file is refused, an alert is raised and the values come from git.

The readings are a logged input (Params/Hardware/<name>). No WPILib here, so the rules can be unit tested.

  • Constructor Details

    • HardwareStamp

      public HardwareStamp(String name, String what, double[] atBoot, double tolerance, Supplier<List<double[]>> afterSave)
      Parameters:
      name - the log key, e.g. SwerveMagnetOffsets
      what - what the readings are, for messages, e.g. "swerve CANcoder magnet offsets"
      atBoot - the readings, or null if a device did not answer
      tolerance - how far a reading may be from a stamped one and still match
      afterSave - the readings this robot may show at a later boot, given what is about to be saved; called on the main thread when a save is prepared
  • Method Details

    • name

      public String name()
    • atBoot

      public double[] atBoot()
      The readings at boot, or null if a device did not answer.