Class PoseSourceInputs

java.lang.Object
frc.spectrumLib.localization.PoseSourceInputs
All Implemented Interfaces:
LoggableInputs

public class PoseSourceInputs extends Object implements LoggableInputs
Everything a pose source reported since the last loop, as an AdvantageKit input.

This is logged before any gate runs. It is the raw record that answers "would this source have been right?", and in replay it is what the gates and the fusion re-run against. The observations are stored as parallel arrays because AdvantageKit logs arrays of primitives and structs natively.

Size matters here: these inputs were a third of the log. AdvantageKit writes a value only when it changes, and the observation arrays change every frame (a frame is reported once, then the arrays go back to empty). So values that are the same for every observation of a source are not arrays: Kind is one number per source, written once, and Tracking is written only for a loop in which some observation was not tracking (AprilTag solves always are; the Quest sometimes is not). Logs written before this change still replay: their per-observation Kinds and full Tracking arrays are read when present.

Logged under /Localization/Sources/<name>/....

  • Field Details

    • connected

      public boolean connected
      Whether the device is talking at all (NT heartbeat, frames arriving).
    • timestamps

      public double[] timestamps
    • poses

      public Pose3d[] poses
    • kind

      public int kind
      PoseObservation.Kind ordinal of this source's observations; -1 before the first.
    • tagCounts

      public int[] tagCounts
    • avgTagDistances

      public double[] avgTagDistances
    • targetSizes

      public double[] targetSizes
    • maxAmbiguities

      public double[] maxAmbiguities
    • tracking

      public boolean[] tracking
    • stdDevScales

      public double[] stdDevScales
      Per-observation PoseObservation.stdDevScale; logged only when some entry isn't 1.
    • tagIds

      public int[] tagIds
      Every tag id seen this loop, for display.
    • fiducials

      public double[] fiducials
      Per-tag data of this loop's frame, FIDUCIAL_STRIDE values per tag: id, horizontal and vertical angle from the principal point (deg, positive right and up), camera-to-tag distance (m), ambiguity. Limelight MegaTag1 only; empty otherwise.
    • FIDUCIAL_STRIDE

      public static final int FIDUCIAL_STRIDE
      See Also:
    • health

      public double[] health
      Source-specific health numbers, e.g. QuestNav battery, Limelight fps. Keys fixed per IO.
  • Constructor Details

    • PoseSourceInputs

      public PoseSourceInputs()
  • Method Details

    • resize

      public void resize(int n)
      Sets the observation arrays to hold n entries.
    • set

      public void set(int i, PoseObservation o)
      Writes observation i.
    • count

      public int count()
      Number of observations.
    • get

      public PoseObservation get(String source, int i)
      Rebuilds observation i, e.g. from replayed inputs.
    • toLog

      public void toLog(LogTable table)
      Specified by:
      toLog in interface LoggableInputs
    • fromLog

      public void fromLog(LogTable table)
      Specified by:
      fromLog in interface LoggableInputs
    • recordAsOutputs

      public void recordAsOutputs(String prefix)
      Records these observations as AdvantageKit outputs under prefix, for a source whose observations are computed from other logged inputs (see PoseSourceIO.derived()). In replay they are recomputed, not read back.