Class ShotPoints.DistanceAverage

java.lang.Object
com.crossbotics.ftchelper.finders.ShotPoints.DistanceAverage
Enclosing class:
ShotPoints

public static final class ShotPoints.DistanceAverage extends Object
The distance averaged over the last WINDOW_SEC seconds of fresh readings, so one noisy camera frame does not go into the table. A reading from another source (camera, then odometry) starts the average again: the two can differ by a few inches.

 ShotPoints.DistanceAverage avg = new ShotPoints.DistanceAverage();
 avg.add(10.0, 47, "camera");
 avg.add(10.1, 49, "camera");
 avg.average(10.1);   // 48
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    How far back readings count, seconds.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(double nowSec, double distance, String from)
    A fresh reading.
    double
    average(double nowSec)
    The average of the readings in the last WINDOW_SEC seconds; NaN if there are none.
    int
    count(double nowSec)
    How many readings are in the average now.
    Where the readings came from ("camera", "odometry"), "" if none yet.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • WINDOW_SEC

      public static final double WINDOW_SEC
      How far back readings count, seconds.
      See Also:
  • Constructor Details

    • DistanceAverage

      public DistanceAverage()
  • Method Details

    • add

      public void add(double nowSec, double distance, String from)
      A fresh reading.
      Parameters:
      nowSec - the time, seconds
      distance - inches
      from - where it came from ("camera", "odometry")
    • average

      public double average(double nowSec)
      The average of the readings in the last WINDOW_SEC seconds; NaN if there are none.
    • count

      public int count(double nowSec)
      How many readings are in the average now.
    • source

      public String source()
      Where the readings came from ("camera", "odometry"), "" if none yet.