Class PoseFilterStats

java.lang.Object
yall.filter.PoseFilterStats

public class PoseFilterStats extends Object
Counts of what a camera's pose filter accepted and rejected, and how spread out the accepted poses are.

The spread is how to find a camera's standard deviations: hold the robot still where it sees tags, reset(), wait a few seconds, then read getStdDevs(). getSuggestedBaseStdDevs(double) turns that into the base standard deviations for VisionPoseFilter.withStdDevs(Matrix, Matrix, double).

  • Constructor Details

    • PoseFilterStats

      public PoseFilterStats()
      Creates empty stats.
  • Method Details

    • recordAccepted

      public void recordAccepted(VisionPoseEstimate estimate)
      Counts an accepted estimate and adds its pose to the spread.
      Parameters:
      estimate - The accepted estimate.
    • recordRejected

      public void recordRejected(String reason)
      Counts a rejected estimate.
      Parameters:
      reason - Why it was rejected: the name of the check that rejected it.
    • reset

      public void reset()
      Starts counting again.
    • getAcceptedCount

      public long getAcceptedCount()
      How many estimates the filter accepted.
      Returns:
      The count.
    • getRejectedCount

      public long getRejectedCount()
      How many estimates the filter rejected.
      Returns:
      The count.
    • getRejectedCount

      public long getRejectedCount(String reason)
      How many estimates one check rejected.
      Parameters:
      reason - The check's rejection reason, such as "ambiguous", or a custom check's name.
      Returns:
      The count.
    • getRejectionCounts

      public Map<String,Long> getRejectionCounts()
      How many estimates each check rejected.
      Returns:
      Counts by rejection reason, in the order the reasons first appeared.
    • getAcceptanceRate

      public double getAcceptanceRate()
      The share of estimates the filter accepted.
      Returns:
      0 to 1, or Double.NaN before any estimate.
    • getSampleCount

      public long getSampleCount()
      How many accepted poses the spread is measured from.
      Returns:
      The count.
    • getMeanPose

      public Optional<Pose2d> getMeanPose()
      The average accepted pose.
      Returns:
      The average, or empty before any accepted estimate.
    • getStdDevs

      public Matrix<N3,N1> getStdDevs()
      How spread out the accepted poses are: the sample standard deviation of x (meters), y (meters) and heading (radians). Measured with the robot still, this is the camera's real standard deviation at the current distance.
      Returns:
      The standard deviations, or Double.NaNs with fewer than two samples.
    • getAverageTagDistanceMeters

      public double getAverageTagDistanceMeters()
      The average tag distance of the accepted poses.
      Returns:
      Meters, or Double.NaN before any accepted estimate.
    • getSuggestedBaseStdDevs

      public Matrix<N3,N1> getSuggestedBaseStdDevs(double distanceDivisor)
      The base standard deviations that would give the measured spread at the measured tag distance, for VisionPoseFilter.withStdDevs(Matrix, Matrix, double): measured / (1 + distance² / distanceDivisor).
      Parameters:
      distanceDivisor - The filter's distance divisor (30 by default).
      Returns:
      The base standard deviations, or Double.NaNs with fewer than two samples.