Class PoseSource

java.lang.Object
frc.spectrumLib.localization.PoseSource

public class PoseSource extends Object
One robot-pose source: a device, its own gate chain, and its own trust model.

A source always runs. update() reads the device into logged inputs and process(GateContext) gates every observation and logs the verdict, whether or not the source is enabled. Enabled only decides whether its accepted measurements move the robot's fused pose. A disabled source still feeds its own shadow estimator in PoseFusion, so every source can be compared, live or in replay, on equal terms.

The enable switch is a dashboard input (/Localization/Sources/<name>/Enabled on NetworkTables), recorded by AdvantageKit, so a replay reproduces exactly which sources were fused.

  • Constructor Details

    • PoseSource

      public PoseSource(String name, PoseSourceIO io, List<Gate> gates, StdDevModel stdDevModel, boolean enabledByDefault)
      Creates a source.
      Parameters:
      name - unique name; becomes the log path
      io - the device layer (PoseSourceIO.NONE in replay)
      gates - rejection rules, checked in order; the first to fire names the rejection
      stdDevModel - trust model for observations that pass
      enabledByDefault - whether this source moves the fused pose until the dashboard says otherwise
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Whether accepted measurements from this source move the fused pose.
    • setEnabled

      public void setEnabled(boolean value)
      Sets the enable switch (also reflected on the dashboard).
    • isConnected

      public boolean isConnected()
      Whether the device is reporting.
    • getInputs

      public PoseSourceInputs getInputs()
      This loop's raw inputs.
    • update

      public void update()
      Reads the device and records (or, in replay, restores) the raw inputs. A derived source's observations are recomputed every run, replay included, and recorded as outputs.
    • process

      public List<PoseSource.Result> process(GateContext context)
      Runs every observation through the gate chain and the trust model, and logs the outcome.
      Parameters:
      context - robot state for this loop
      Returns:
      this loop's results, one per observation
    • logPolicy

      public void logPolicy(boolean allowed)
      Logs whether the fusion policy allowed this source to move the fused pose this loop.
      Parameters:
      allowed - the policy's answer
    • acceptedThisLoop

      public boolean acceptedThisLoop(PoseObservation.Kind kind)
      Whether any observation of the given kind was accepted this loop.
    • getName

      public String getName()
    • isEnabledByDefault

      public boolean isEnabledByDefault()
    • getResults

      public List<PoseSource.Result> getResults()
      Results of the most recent process(GateContext) call.
    • getAcceptedCount

      public long getAcceptedCount()
    • getRejectedCount

      public long getRejectedCount()
    • getLastRejection

      public String getLastRejection()
    • getLastAcceptedTimestamp

      public double getLastAcceptedTimestamp()