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

#include <field.h>

Public Member Functions

 Field (double field_x_length, double field_y_length, double defense_x_length, double defense_y_length, double goal_x_length, double goal_y_length, double boundary_buffer_size, double center_circle_radius)
 
 Field (const TbotsProto::Field &field_proto)
 
double xLength () const
 
double totalXLength () const
 
double yLength () const
 
double totalYLength () const
 
double goalYLength () const
 
double goalXLength () const
 
double centerCircleRadius () const
 
Circle centerCircle () const
 
Point centerPoint () const
 
Segment halfwayLine () const
 
double defenseAreaYLength () const
 
double defenseAreaXLength () const
 
const RectanglefriendlyDefenseArea () const
 
const RectangleenemyDefenseArea () const
 
Rectangle friendlyHalf () const
 
Rectangle friendlyPositiveYQuadrant () const
 
Rectangle friendlyNegativeYQuadrant () const
 
Rectangle enemyHalf () const
 
Rectangle enemyPositiveYQuadrant () const
 
Rectangle enemyNegativeYQuadrant () const
 
const RectanglefieldLines () const
 
Rectangle fieldBoundary () const
 
Point friendlyGoalCenter () const
 
Point enemyGoalCenter () const
 
const RectanglefriendlyGoal () const
 
const RectangleenemyGoal () const
 
Point friendlyPenaltyMark () const
 
Point enemyPenaltyMark () const
 
Point friendlyCornerPos () const
 
Point friendlyCornerNeg () const
 
Point enemyCornerPos () const
 
Point enemyCornerNeg () const
 
Point friendlyGoalpostPos () const
 
Point friendlyGoalpostNeg () const
 
Point enemyGoalpostPos () const
 
Point enemyGoalpostNeg () const
 
double boundaryMargin () const
 
bool pointInFriendlyDefenseArea (const Point &p) const
 
bool pointInEnemyDefenseArea (const Point &p) const
 
bool pointInFriendlyHalf (const Point &p) const
 
bool pointInEnemyHalf (const Point &p) const
 
bool pointInFriendlyCorner (const Point &p, double radius) const
 
bool pointInEnemyCorner (const Point &p, double radius) const
 
bool operator== (const Field &other) const
 
bool operator!= (const Field &other) const
 

Static Public Member Functions

static Field createSSLDivisionBField ()
 
static Field createSSLDivisionAField ()
 
static Field createField (TbotsProto::FieldType field_type)
 

Detailed Description

Exposes the dimensions of various parts of the field.

 +-------+-------+-------+
 |       | Enemy |       |
 |       +-------+       |
 |                       |
 |           ^ +x        |
 |           |           |
 |           |           |
 |           |           |
 |  +y       |           |
 |  <--------+ (0,0)     |
 |                       |
 |                       |
 |                       |
 |      +----------+     |
 |      | Friendly |     |
 +------+----------+-----+

Constructor & Destructor Documentation

◆ Field() [1/2]

Field ( double  field_x_length,
double  field_y_length,
double  defense_x_length,
double  defense_y_length,
double  goal_x_length,
double  goal_y_length,
double  boundary_buffer_size,
double  center_circle_radius 
)
explicit

Constructs a new field with the given dimensions

Precondition
all dimensions (except for the boundary buffer) must be > 0.
the boundary buffer must be >= 0
Exceptions
invalid_argumentif at least one dimension is <= 0
Parameters
field_x_lengththe length of the playing area (along the x-axis)
field_y_lengththe length of the playing area (along the y-axis)
defense_x_lengththe length of the defense area (along the x-axis)
defense_y_lengththe length of the defense area (along the y-axis)
goal_x_lengththe length of the goal (along the x-axis)
goal_y_lengththe length of the goal (along the y-axis)
boundary_buffer_sizethe size of the boundary area between the edge of the playing area and the physical border/perimeter of the field
center_circle_radiusthe radius of the center circle

◆ Field() [2/2]

Field ( const TbotsProto::Field &  field_proto)
explicit

Constructs a new field based on the TbotsProto::Field protobuf representation

Precondition
all dimensions (except for the boundary buffer) must be > 0.
the boundary buffer must be >= 0
Exceptions
invalid_argumentif at least one dimension is <= 0
Parameters
field_proto

Member Function Documentation

◆ boundaryMargin()

double boundaryMargin ( ) const

Gets the margin for being out of bounds on the top or bottom of the field in metres.

Returns
the size of the margin/bounds around the field in metres

◆ centerCircle()

Circle centerCircle ( ) const

Returns the center circle at the middle of the field

Returns
the center circle at the middle of the field

◆ centerCircleRadius()

double centerCircleRadius ( ) const

Gets the radius of the centre circle in metres.

Returns
the radius of the centre circle in metres.

◆ centerPoint()

Point centerPoint ( ) const

Returns the center point of the field

Returns
the center point of the field

◆ createField()

Field createField ( TbotsProto::FieldType  field_type)
static

Creates a field with the standard SSL Division A or B dimensions

Parameters
field_typeThe field type
Returns
a field with the standard SSL Division A or B dimensions

◆ createSSLDivisionAField()

Field createSSLDivisionAField ( )
static

Creates a field with the standard SSL Division A dimensions

Returns
a field with the standard SSL Division A dimensions

◆ createSSLDivisionBField()

Field createSSLDivisionBField ( )
static

Creates a field with the standard SSL Division B dimensions

Returns
a field with the standard SSL Division B dimensions

◆ defenseAreaXLength()

double defenseAreaXLength ( ) const

Gets the length of the defense area in metres, which runs along the x-axis. This is how far the defense area extends in front of the goal.

Returns
the width of the straight parts in metres.

◆ defenseAreaYLength()

double defenseAreaYLength ( ) const

Gets the width of the defense area in metres, which runs along the y-axis. This is the total width of how far the defense area stretches from one side of the goal to the other.

Returns
the width of the defense area

◆ enemyCornerNeg()

Point enemyCornerNeg ( ) const

Gets the position of the enemy corner with the negative y-axis

Returns
the position of the enemy corner with the negative y-axis

◆ enemyCornerPos()

Point enemyCornerPos ( ) const

Gets the position of the enemy corner with the positive y-axis

Returns
the position of the enemy corner with the positive y-axis

◆ enemyDefenseArea()

const Rectangle & enemyDefenseArea ( ) const

Gets the enemy defense area as a Rectangle.

Returns
defense area of the enemy team

◆ enemyGoal()

const Rectangle & enemyGoal ( ) const

Gets the area within the enemy goal.

Returns
the area within the enemy goal.

◆ enemyGoalCenter()

Point enemyGoalCenter ( ) const

Gets the position of the centre of the enemy goal.

Returns
the position of the enemy goal.

◆ enemyGoalpostNeg()

Point enemyGoalpostNeg ( ) const

Gets the position of the enemy goalpost with the negative y-axis

Returns
the position of the enemy goalpost with the negative y-axis

◆ enemyGoalpostPos()

Point enemyGoalpostPos ( ) const

Gets the position of the enemy goalpost with the positive y-axis

Returns
the position of the enemy goalpost with the positive y-axis

◆ enemyHalf()

Rectangle enemyHalf ( ) const

Gets the enemy half of the field within field lines

Returns
the enemy half of the field

◆ enemyNegativeYQuadrant()

Rectangle enemyNegativeYQuadrant ( ) const

Gets the enemy negative Y quadrant of the field

Returns
the enemy negative Y quadrant of the field

◆ enemyPenaltyMark()

Point enemyPenaltyMark ( ) const

Gets the position of the enemy team's penalty mark.

Returns
the position of the penalty mark for the enemy team.

◆ enemyPositiveYQuadrant()

Rectangle enemyPositiveYQuadrant ( ) const

Gets the enemy positive Y quadrant of the field

Returns
the enemy positive Y quadrant of the field

◆ fieldBoundary()

Rectangle fieldBoundary ( ) const

Gets the area within the field boundary (the physical walls surrounding the Field). This is the entire area where the robots and ball can move, and is a superset of the area inside the field lines.

Returns
The area within the field boundary as a rectangle

◆ fieldLines()

const Rectangle & fieldLines ( ) const

Gets the area within the field lines as a rectangle. This is the set of locations where the ball is considered "in play".

Returns
The area within the field lines as a rectangle

◆ friendlyCornerNeg()

Point friendlyCornerNeg ( ) const

Gets the position of our corner with the negative y-axis

Returns
the position of our corner with the negative y-axis

◆ friendlyCornerPos()

Point friendlyCornerPos ( ) const

Gets the position of our corner with the positive y-axis

Returns
the position of our corner with the positive y-axis

◆ friendlyDefenseArea()

const Rectangle & friendlyDefenseArea ( ) const

Gets the friendly defense area as a Rectangle.

Returns
defense area of the friendly team

◆ friendlyGoal()

const Rectangle & friendlyGoal ( ) const

Gets the area within the friendly goal.

Returns
the area within the friendly goal.

◆ friendlyGoalCenter()

Point friendlyGoalCenter ( ) const

Gets the position of the centre of the friendly goal.

Returns
the position of the friendly goal.

◆ friendlyGoalpostNeg()

Point friendlyGoalpostNeg ( ) const

Gets the position of the friendly goalpost with the negative y-axis

Returns
the position of the friendly goalpost with the negative y-axis

◆ friendlyGoalpostPos()

Point friendlyGoalpostPos ( ) const

Gets the position of the friendly goalpost with the positive y-axis

Returns
the position of the friendly goalpost with the positive y-axis

◆ friendlyHalf()

Rectangle friendlyHalf ( ) const

Gets the friendly half of the field within field lines

Returns
the friendly half of the field

◆ friendlyNegativeYQuadrant()

Rectangle friendlyNegativeYQuadrant ( ) const

Gets the friendly negative Y quadrant of the field

Returns
the friendly negative Y quadrant of the field

◆ friendlyPenaltyMark()

Point friendlyPenaltyMark ( ) const

Gets the position of the friendly team's penalty mark.

Returns
the position of the penalty mark for the friendly team.

◆ friendlyPositiveYQuadrant()

Rectangle friendlyPositiveYQuadrant ( ) const

Gets the friendly positive Y quadrant of the field

Returns
the friendly positive Y quadrant of the field

◆ goalXLength()

double goalXLength ( ) const

Gets the "depth" of the goal along the x-axis, in metres.

Returns
the "depth" of the goal along the x-axis, in metres.

◆ goalYLength()

double goalYLength ( ) const

Gets the y-axis length of the goal, symmetric above and below the centreline, from goalpost to goalpost in metres.

Returns
the y-axis length of the goal in metres.

◆ halfwayLine()

Segment halfwayLine ( ) const

Returns the halfway line of the field (as a segment) The segment is on the Y axis and is bounded by the field lines

Returns
the center line of the field

◆ operator!=()

bool operator!= ( const Field other) const

Compares two fields for inequality

Parameters
otherthe field the compare to
Returns
true if the fields do not have the same dimensions, and false otherwise

◆ operator==()

bool operator== ( const Field other) const

Compares two fields for equality

Parameters
otherthe field to compare to
Returns
true if the fields have the same dimensions, and false otherwise

◆ pointInEnemyCorner()

bool pointInEnemyCorner ( const Point p,
double  radius 
) const

Returns true if the point is in within the provided radius in one of the enemy corner.

Parameters
point
theradius from the corner, to decide whether or not the point is in the field.
Returns
true if the point is in within the provided radius in one of the enemy corner.

◆ pointInEnemyDefenseArea()

bool pointInEnemyDefenseArea ( const Point p) const

Returns whether p is in the enemy defense area

Returns
true if point p is in enemy defense area

◆ pointInEnemyHalf()

bool pointInEnemyHalf ( const Point p) const

Returns true if the point is in the enemy half of the field, and false otherwise

Parameters
point
Returns
true if the point is in the enemy's half of the field, and false otherwise

◆ pointInFriendlyCorner()

bool pointInFriendlyCorner ( const Point p,
double  radius 
) const

Returns true if the point is in within the provided radius in one of the friendly corner.

Parameters
point
theradius from the corner, to decide whether or not the point is in the field.
Returns
true if the point is in within the provided radius in one of the friendly corner.

◆ pointInFriendlyDefenseArea()

bool pointInFriendlyDefenseArea ( const Point p) const

Returns whether p is in the friendly defense area

Returns
true if point p is in friendly defense area

◆ pointInFriendlyHalf()

bool pointInFriendlyHalf ( const Point p) const

Returns true if the point is in the friendly half of the field, and false otherwise

Parameters
point
Returns
true if the point is in the friendly half of the field, and false otherwise

◆ totalXLength()

double totalXLength ( ) const

Gets the x-axis length of the field including the boundary area in metres.

Returns
the total x-axis length of the field in metres, including the boundary area.

◆ totalYLength()

double totalYLength ( ) const

Gets the y-axis length of the field including the boundary area in metres.

Returns
the total y-axis length of the field in metres, including the boundary area.

◆ xLength()

double xLength ( ) const

Gets the x-axis length of the field from goal-line to goal-line in metres.

Returns
the x-axis length of the field in metres.

◆ yLength()

double yLength ( ) const

Gets the y-axis length of the field from sideline to sideline in metres.

Returns
the y-axis length of the field in metres.

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