Class ShotPoints.DistanceAverage
java.lang.Object
com.crossbotics.ftchelper.finders.ShotPoints.DistanceAverage
- Enclosing class:
ShotPoints
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
FieldsModifier and TypeFieldDescriptionstatic final doubleHow far back readings count, seconds. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidA fresh reading.doubleaverage(double nowSec) The average of the readings in the lastWINDOW_SECseconds; NaN if there are none.intcount(double nowSec) How many readings are in the average now.source()Where the readings came from ("camera", "odometry"), "" if none yet.
-
Field Details
-
WINDOW_SEC
public static final double WINDOW_SECHow far back readings count, seconds.- See Also:
-
-
Constructor Details
-
DistanceAverage
public DistanceAverage()
-
-
Method Details
-
add
A fresh reading.- Parameters:
nowSec- the time, secondsdistance- inchesfrom- where it came from ("camera", "odometry")
-
average
public double average(double nowSec) The average of the readings in the lastWINDOW_SECseconds; NaN if there are none. -
count
public int count(double nowSec) How many readings are in the average now. -
source
Where the readings came from ("camera", "odometry"), "" if none yet.
-