36 static constexpr unsigned int MIN_BUFFER_SIZE = 4;
37 static constexpr unsigned int MAX_BUFFER_SIZE = 10;
40 static constexpr double MIN_BUFFER_SIZE_VELOCITY_MAGNITUDE = 0.5;
43 static constexpr double MAX_BUFFER_SIZE_VELOCITY_MAGNITUDE = 4.0;
45 static constexpr double MAX_ACCEPTABLE_BALL_SPEED_BUFFER = 2.0;
48 static constexpr double LINEAR_REGRESSION_ERROR_THRESHOLD = 1000.0;
67 const std::vector<BallDetection>& new_ball_detections,
74 struct BallVelocityEstimate
77 double average_velocity_magnitude;
79 double min_max_magnitude_average;
85 struct LinearRegressionResults
88 double regression_error;
102 void addNewDetectionsToBuffer(std::vector<BallDetection> new_ball_detections,
114 static std::optional<Ball> estimateBallStateFromBuffer(
115 boost::circular_buffer<BallDetection> ball_detections);
129 static std::optional<size_t> getAdjustedBufferSize(
130 boost::circular_buffer<BallDetection> ball_detections);
143 static LinearRegressionResults calculateLineOfBestFit(
144 boost::circular_buffer<BallDetection> ball_detections);
156 static LinearRegressionResults calculateLinearRegression(
157 boost::circular_buffer<BallDetection> ball_detections);
170 static Point estimateBallPosition(
171 boost::circular_buffer<BallDetection> ball_detections,
172 const Line& regression_line);
187 static std::optional<BallVelocityEstimate> estimateBallVelocity(
188 boost::circular_buffer<BallDetection> ball_detections,
189 const std::optional<Line>& ball_regression_line = std::nullopt);
191 boost::circular_buffer<BallDetection> ball_detection_buffer;