Class PoseSource
java.lang.Object
frc.spectrumLib.localization.PoseSource
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordGate outcome for one observation. -
Constructor Summary
ConstructorsConstructorDescriptionPoseSource(String name, PoseSourceIO io, List<Gate> gates, StdDevModel stdDevModel, boolean enabledByDefault) Creates a source. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether any observation of the given kind was accepted this loop.longThis loop's raw inputs.doublegetName()longResults of the most recentprocess(GateContext)call.booleanWhether the device is reporting.booleanWhether accepted measurements from this source move the fused pose.booleanvoidlogPolicy(boolean allowed) Logs whether the fusion policy allowed this source to move the fused pose this loop.process(GateContext context) Runs every observation through the gate chain and the trust model, and logs the outcome.voidsetEnabled(boolean value) Sets the enable switch (also reflected on the dashboard).voidupdate()Reads the device and records (or, in replay, restores) the raw inputs.
-
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 pathio- the device layer (PoseSourceIO.NONEin replay)gates- rejection rules, checked in order; the first to fire names the rejectionstdDevModel- trust model for observations that passenabledByDefault- 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
This loop's raw inputs. -
update
public void update()Reads the device and records (or, in replay, restores) the raw inputs. Aderivedsource's observations are recomputed every run, replay included, and recorded as outputs. -
process
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
Whether any observation of the given kind was accepted this loop. -
getName
-
isEnabledByDefault
public boolean isEnabledByDefault() -
getResults
Results of the most recentprocess(GateContext)call. -
getAcceptedCount
public long getAcceptedCount() -
getRejectedCount
public long getRejectedCount() -
getLastRejection
-
getLastAcceptedTimestamp
public double getLastAcceptedTimestamp()
-