Roomba Controller Dashboard 1
A GUI and TCP client application that is used to control a Roomba for Computer Engineering 2880 @ Iowa State
Loading...
Searching...
No Matches
Field Class Reference

#include <Field.hpp>

Public Member Functions

 Field (const std::vector< Pillar > &pillars, const Pose2D &desiredDestination, const Pillar &botPose)
 
 Field (const std::vector< Pillar > &pillars, const Pose2D &desiredDestination)
 
 Field ()
 
 Field (const std::unique_ptr< std::vector< Pillar > > &pillars, const Pose2D &desired_destination, const Pillar &bot_pose, const Graph< Pose2D > &graph)
 
void addEdgeMeasurement (double rawPosition, Cardinality cardinality)
 
HoleManagergetManager ()
 
void applyOffsetToEdge (double x, double y)
 
int32_t getDesiredIndex () const
 
void clearField ()
 
Graph< Pose2D > & getGraph ()
 
Pillar getBotPose ()
 
void discretizeGraph ()
 
void weightGraph ()
 
std::vector< Pose2DmakePath ()
 
void addPillar (Pillar &newPillar)
 
void updateBotPose (const Pose2D &updatedPosition)
 
std::unique_ptr< std::vector< Pillar > > getPillars ()
 
void setPillars (std::unique_ptr< std::vector< Pillar > > pillars)
 
std::vector< PillargetCopyPillars ()
 
bool validLocationForNode (const Pose2D &location)
 
Pose2D getDesiredDestination ()
 
void updateDesired (const Pose2D &other)
 
void setDesiredIndex (int32_t index)
 

Static Public Member Functions

static bool outOfBounds (const Pose2D &location)
 
static bool lineIntersectsCircle (double cx, double cy, double r, double x1, double y1, double x2, double y2)
 
static bool lineIntersectsCircle (Pillar p1, const Pose2D &one, const Pose2D &two)
 
static double roundRadius (double radius)
 

Protected Attributes

std::unique_ptr< std::vector< Pillar > > pillars
 
HoleManager holeManager
 
Pose2D offset
 
Pose2D desiredDestination
 
Pillar botPose
 
Pose2D runningError
 
Graph< Pose2Dgraph
 
int32_t desiredIndex = -1
 
std::vector< PillarnewPillars
 

Detailed Description

A class that represents the objects that can be and are on the field

Definition at line 40 of file Field.hpp.

Constructor & Destructor Documentation

◆ Field() [1/4]

Field::Field ( const std::vector< Pillar > & pillars,
const Pose2D & desiredDestination,
const Pillar & botPose )

constructs a new field object

Parameters
pillarsthe pillars that the field stores
desiredDestinationthe desired destination for the app to generate a path to
botPose

Definition at line 7 of file Field.cpp.

◆ Field() [2/4]

Field::Field ( const std::vector< Pillar > & pillars,
const Pose2D & desiredDestination )

constructs a new field object

Parameters
pillarsthe pillars that the field stores
desiredDestinationthe desired destination for the app to generate a path to

Definition at line 16 of file Field.cpp.

◆ Field() [3/4]

Field::Field ( )

Constructs a deafult field object

Definition at line 24 of file Field.cpp.

◆ Field() [4/4]

Field::Field ( const std::unique_ptr< std::vector< Pillar > > & pillars,
const Pose2D & desired_destination,
const Pillar & bot_pose,
const Graph< Pose2D > & graph )

Copys the majority of the important parts of the field

Parameters
pillarsthe pillars to store
desired_destinationthe desired destination to travel to
bot_posethe bot position
graphthe graph object

Member Function Documentation

◆ addEdgeMeasurement()

void Field::addEdgeMeasurement ( double rawPosition,
Cardinality cardinality )

Add an edge measurement to the field.

Parameters
rawPositionthe raw position (X or Y) of the measurmenet
cardinalitythe direction of the measurement

Definition at line 203 of file Field.cpp.

◆ addPillar()

void Field::addPillar ( Pillar & newPillar)

Add a pillar measurement to the graph

Parameters
newPillarto add

Definition at line 159 of file Field.cpp.

◆ applyOffsetToEdge()

void Field::applyOffsetToEdge ( double x,
double y )

Applys some offset from getting the edge of the field

Parameters
xcomponent of the offset
ycomponent of the offset

Definition at line 228 of file Field.cpp.

◆ clearField()

void Field::clearField ( )

Clears the entire field and cooresponding managers and graphs

Definition at line 138 of file Field.cpp.

◆ discretizeGraph()

void Field::discretizeGraph ( )

add nodes to the graph that are valid places the bot can be at

Definition at line 32 of file Field.cpp.

◆ getBotPose()

Pillar Field::getBotPose ( )
Returns
the robot pose on the field as a pillar. The radius is the radius of the bot

Definition at line 155 of file Field.cpp.

◆ getCopyPillars()

std::vector< Pillar > Field::getCopyPillars ( )
Returns
a copy of the pillars on the field

Definition at line 191 of file Field.cpp.

◆ getDesiredDestination()

Pose2D Field::getDesiredDestination ( )

get the desired destination to travel to

Returns
the position to get to

Definition at line 274 of file Field.cpp.

◆ getDesiredIndex()

int32_t Field::getDesiredIndex ( ) const
Returns
the index of the desired pillar in the graph

Definition at line 257 of file Field.cpp.

◆ getGraph()

Graph< Pose2D > & Field::getGraph ( )

Gets a reference to the graph object on the field

Returns
a reference to the graph object

Definition at line 261 of file Field.cpp.

◆ getManager()

HoleManager & Field::getManager ( )

Gets a reference to the hole manager

Returns
a reference to the hole manager

Definition at line 134 of file Field.cpp.

◆ getPillars()

std::unique_ptr< std::vector< Pillar > > Field::getPillars ( )

a unique pointer for the pillars on the field

Returns
the pillars on the field

Definition at line 142 of file Field.cpp.

◆ lineIntersectsCircle() [1/2]

bool Field::lineIntersectsCircle ( double cx,
double cy,
double r,
double x1,
double y1,
double x2,
double y2 )
static

Util function that returns whether a given line intersects a circle

Definition at line 236 of file Field.cpp.

◆ lineIntersectsCircle() [2/2]

static bool Field::lineIntersectsCircle ( Pillar p1,
const Pose2D & one,
const Pose2D & two )
inlinestatic

Util function that returns whether a given line intersects a circle

Definition at line 182 of file Field.hpp.

◆ makePath()

std::vector< Pose2D > Field::makePath ( )

Generates a path from the graph using Dijkstra's algorithm

Returns
a path to the desired destination

Definition at line 109 of file Field.cpp.

◆ outOfBounds()

bool Field::outOfBounds ( const Pose2D & location)
static

A static check to determine if a given location in the field coordinate system is out of bounds

Parameters
locationthe position to check
Returns
whether that postiion is out of bounds on the field.

Definition at line 199 of file Field.cpp.

◆ roundRadius()

static double Field::roundRadius ( double radius)
inlinestatic

round a given radius to possible radii

Parameters
radiusthe radius to round
Returns
the rounded radius

Definition at line 258 of file Field.hpp.

◆ setDesiredIndex()

void Field::setDesiredIndex ( int32_t index)

set the index of the desired position to travel to IN THE GRAPH

Parameters
indexthe index IN the graph

Definition at line 146 of file Field.cpp.

◆ setPillars()

void Field::setPillars ( std::unique_ptr< std::vector< Pillar > > pillars)

sets the pillars on the field

Parameters
pillarsthe pillars that the field stores

Definition at line 151 of file Field.cpp.

◆ updateBotPose()

void Field::updateBotPose ( const Pose2D & updatedPosition)
Parameters
updatedPosition

Definition at line 179 of file Field.cpp.

◆ updateDesired()

void Field::updateDesired ( const Pose2D & other)
Parameters
otherthe new desired position

Definition at line 265 of file Field.cpp.

◆ validLocationForNode()

bool Field::validLocationForNode ( const Pose2D & location)

Check whether a given position is a valid place for a node in the graph with respect to "this" field

Parameters
locationthe location of the node
Returns
whether it collides with anything

Definition at line 118 of file Field.cpp.

◆ weightGraph()

void Field::weightGraph ( )

Weight the graph in a way that the bot does not intersect and objects on the field

Definition at line 75 of file Field.cpp.

Member Data Documentation

◆ botPose

Pillar Field::botPose
protected

THe position of the robot on the field

Definition at line 67 of file Field.hpp.

◆ desiredDestination

Pose2D Field::desiredDestination
protected

the desired destination for the robot to get to

Definition at line 62 of file Field.hpp.

◆ desiredIndex

int32_t Field::desiredIndex = -1
protected

The index of the desired position in the graph

Definition at line 87 of file Field.hpp.

◆ graph

Graph<Pose2D> Field::graph
protected

The graph object which is used to generate trajectorys from nodes. Nodes represent places we can be on the field. The connections between nodes represents the possible paths we can take. The values of the connections represent the cost of moving between those nodes which is measured as the distance between nodes.

Definition at line 82 of file Field.hpp.

◆ holeManager

HoleManager Field::holeManager
protected

A hole maanger to manage and check collision with holes

Definition at line 51 of file Field.hpp.

◆ newPillars

std::vector<Pillar> Field::newPillars
protected

A queue for new pillars that we add to the field. This is used to speed up discretization and weighting of the graph.

Definition at line 93 of file Field.hpp.

◆ offset

Pose2D Field::offset
protected

The amount to offset everything by after reading edges. X value stores the X (N, S) offset, Y value stores the Y (E, W) offset

Definition at line 57 of file Field.hpp.

◆ pillars

std::unique_ptr<std::vector<Pillar> > Field::pillars
protected

the pillars on the field. The physical 3D cylinders get stored here

Definition at line 46 of file Field.hpp.

◆ runningError

Pose2D Field::runningError
protected

the running error that we have accumulated over time in our measurements. This is just an approixmation based on read in error from the IPC

Definition at line 73 of file Field.hpp.


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