Thunderbots Project
Loading...
Searching...
No Matches
BallFilter Class Reference

#include <ball_filter.h>

Public Member Functions

 BallFilter ()
 
std::optional< BallestimateBallState (const std::vector< BallDetection > &new_ball_detections, const Rectangle &filter_area)
 

Static Public Attributes

static constexpr unsigned int MIN_BUFFER_SIZE = 4
 
static constexpr unsigned int MAX_BUFFER_SIZE = 10
 
static constexpr double MIN_BUFFER_SIZE_VELOCITY_MAGNITUDE = 0.5
 
static constexpr double MAX_BUFFER_SIZE_VELOCITY_MAGNITUDE = 4.0
 
static constexpr double MAX_ACCEPTABLE_BALL_SPEED_BUFFER = 2.0
 
static constexpr double LINEAR_REGRESSION_ERROR_THRESHOLD = 1000.0
 

Detailed Description

Given ball data from SSL Vision, filters and returns the position/velocity of the "real" ball.

This ball filter stores a buffer of previous SSL Vision detections, and uses linear regression to find the path the ball is travelling on and estimate its position and velocity. This buffer/regression system was chosen because it results in a very stable output, particularly for the ball velocity. The data we receive isn't perfect (which is why we have a filter). If we receive a noisy position that is off the ball's current trajectory, it will have minimal impact. This means that as the ball is travelling, this filter will return a very steady velocity vector. This is important because small deviations in velocity orientation can have large effects when the AI tries to predict the future position of the ball. For example, consistently receiving a pass relies on the ball's velocity being very stable, otherwise the robot would "jiggle" back and forth as the estimated receiver position would keep changing.

Constructor & Destructor Documentation

◆ BallFilter()

BallFilter ( )
explicit

Creates a new Ball Filter

Member Function Documentation

◆ estimateBallState()

std::optional< Ball > estimateBallState ( const std::vector< BallDetection > &  new_ball_detections,
const Rectangle filter_area 
)

Update the filter with the new ball detection data, and returns the new estimated state of the ball given the new data

Parameters
new_ball_detectionsA list of new Ball detections
filter_areaThe area within which the ball filter will work. Any detections outside of this area will be ignored.
Returns
The new ball based on the estimated state of the ball given the new data. If a filtered result cannot be calculated, returns std::nullopt

The documentation for this class was generated from the following files: