#include <RFieldStateMachine.h>
Collaboration diagram for RFieldStateMachine:
Public Types | |
enum | PointTypes { nothing = 0, blueRobot, redRobot, border, line, ball, skyblueGoal, yellowGoal, unknown, numberOfPointTypes } |
Different point types. More... | |
enum | FIELD_STATES { START = 0, FOUND_WHITE, FOUND_FIELD, FOUND_BORDER, LINE_IN, LINE_OUT, YELLOW_GOAL, YELLOW_FINISHED, SKYBLUE_GOAL, SKYBLUE_FINISHED, FOUND_RED_ROBOT, FOUND_BLUE_ROBOT, FINISHED_BLUE_ROBOT, FINISHED_RED_ROBOT, FOUND_BALL, FINISHED_BALL, FOUND_UNKNOWN, FINISHED_UNKNOWN } |
The different states. More... | |
Public Member Functions | |
RFieldStateMachine () | |
Constructor. | |
~RFieldStateMachine () | |
Destructor. | |
void | update (int x, int y, REdgeDetection &scanner) |
Updates the state machine after a scan. | |
void | reset (int x, int y) |
Resets the state machine. | |
Vector2< int > | getEdge (int index) |
Returns one of the detected edge points. | |
PointTypes | getType (int index) |
Returns the type of one of the detected edge points. | |
int | size () |
Returns the number of edges found after the last reset. | |
bool | foundObstacle () |
Tells if the machine determined a obstacle and its free space. | |
Vector2< int > & | nearPoint () |
Returns the near point of the detected obstacle space. | |
Vector2< int > & | farPoint () |
Returns the far point of the detected obstacle space. | |
ObstaclesPercept::ObstacleType | getObstacleType () |
Returns the type of the obstacle. | |
Private Member Functions | |
void | findNextState () |
Calculates the next state. | |
void | executeState () |
Executes the active state. | |
Private Attributes | |
colorClass | color |
Current color. | |
int | range |
The range between the last two edges. | |
int | rangeSum |
The sum of ranges since the last reset. | |
int | greenRange |
The sum of the green range. | |
int | whiteRange |
The sum of the white range. | |
int | grayRange |
The sum of the gray range. | |
bool | isUnknownBot |
Temporary variable. | |
Vector2< int > | edgeBuffer [20] |
The edge buffer. | |
Vector2< int > | start |
The start point stored at the last reset. | |
PointTypes | types [20] |
The type buffer. | |
FIELD_STATES | state |
The active state. | |
int | numberOfEdges |
The number of edges found since last reset. | |
int | obstacleFarPoint |
The far point of the obstacle. | |
int | obstacleNearPoint |
The near point of the obstacle. |
The machine has the ability to determine the object-type of an edge-point found on the field. The scans should go from the horizon to the ground. It is not really needed to scan perpendicular to the horizon. The machine is reading from the buffers of the edgeDetection and changes its states automaticly. For this the client should call reset() before every scan and then use a buffered scan to an edge to fill the buffer. After this call update() to update the state of the machine and continue the scan. So the client has to call update() after an edge is found or the scan is finished.
Definition at line 34 of file RFieldStateMachine.h.
|
Different point types.
Definition at line 40 of file RFieldStateMachine.h. Referenced by getType(). |
|
The different states.
Definition at line 54 of file RFieldStateMachine.h. |
|
Constructor.
Definition at line 11 of file RFieldStateMachine.cpp. References reset(). |
Here is the call graph for this function:
|
Destructor.
Definition at line 17 of file RFieldStateMachine.cpp. |
|
Updates the state machine after a scan.
Definition at line 29 of file RFieldStateMachine.cpp. References edgeBuffer, executeState(), findNextState(), REdgeDetection::getBufferSize(), REdgeDetection::getColor(), REdgeDetection::getRange(), grayRange, greenRange, obstacleFarPoint, obstacleNearPoint, rangeSum, types, whiteRange, Vector2< int >::x, and Vector2< int >::y. Referenced by RDefaultStrategy::postScan(). |
Here is the call graph for this function:
|
Resets the state machine. The first point is setted to (x,y).
Definition at line 19 of file RFieldStateMachine.cpp. References isUnknownBot, obstacleFarPoint, obstacleNearPoint, START, Vector2< int >::x, and Vector2< int >::y. Referenced by RDefaultStrategy::postScan(), and RFieldStateMachine(). |
|
Returns one of the detected edge points.
Definition at line 98 of file RFieldStateMachine.h. References edgeBuffer. Referenced by RDefaultStrategy::postScan(). |
|
Returns the type of one of the detected edge points.
Definition at line 106 of file RFieldStateMachine.h. References PointTypes, and types. Referenced by RDefaultStrategy::postScan(). |
|
Returns the number of edges found after the last reset.
Definition at line 112 of file RFieldStateMachine.h. Referenced by RDefaultStrategy::postScan(). |
|
Tells if the machine determined a obstacle and its free space.
Definition at line 118 of file RFieldStateMachine.h. References obstacleFarPoint, and obstacleNearPoint. Referenced by RDefaultStrategy::postScan(). |
|
Returns the near point of the detected obstacle space.
Definition at line 124 of file RFieldStateMachine.h. References edgeBuffer, and obstacleNearPoint. Referenced by RDefaultStrategy::postScan(). |
|
Returns the far point of the detected obstacle space.
Definition at line 130 of file RFieldStateMachine.h. References edgeBuffer, and obstacleFarPoint. Referenced by RDefaultStrategy::postScan(). |
|
Returns the type of the obstacle.
Definition at line 136 of file RFieldStateMachine.h. References getPlayer(), Player::getTeamColor(), obstacleFarPoint, and types. Referenced by RDefaultStrategy::postScan(). |
Here is the call graph for this function:
|
Calculates the next state.
Definition at line 62 of file RFieldStateMachine.cpp. References FINISHED_BALL, FINISHED_BLUE_ROBOT, FINISHED_RED_ROBOT, FINISHED_UNKNOWN, FOUND_BALL, FOUND_BLUE_ROBOT, FOUND_BORDER, FOUND_FIELD, FOUND_RED_ROBOT, FOUND_UNKNOWN, FOUND_WHITE, grayRange, isUnknownBot, LINE_IN, LINE_OUT, SKYBLUE_FINISHED, SKYBLUE_GOAL, START, whiteRange, YELLOW_FINISHED, and YELLOW_GOAL. Referenced by update(). |
|
Executes the active state.
Definition at line 243 of file RFieldStateMachine.cpp. References FINISHED_BALL, FINISHED_BLUE_ROBOT, FINISHED_RED_ROBOT, FINISHED_UNKNOWN, FOUND_BALL, FOUND_BLUE_ROBOT, FOUND_BORDER, FOUND_FIELD, FOUND_RED_ROBOT, FOUND_UNKNOWN, FOUND_WHITE, greenRange, LINE_IN, LINE_OUT, obstacleFarPoint, SKYBLUE_FINISHED, SKYBLUE_GOAL, START, types, YELLOW_FINISHED, and YELLOW_GOAL. Referenced by update(). |
|
Current color.
Definition at line 164 of file RFieldStateMachine.h. |
|
The range between the last two edges.
Definition at line 166 of file RFieldStateMachine.h. |
|
The sum of ranges since the last reset.
Definition at line 168 of file RFieldStateMachine.h. Referenced by update(). |
|
The sum of the green range.
Definition at line 170 of file RFieldStateMachine.h. Referenced by executeState(), and update(). |
|
The sum of the white range.
Definition at line 172 of file RFieldStateMachine.h. Referenced by findNextState(), and update(). |
|
The sum of the gray range.
Definition at line 174 of file RFieldStateMachine.h. Referenced by findNextState(), and update(). |
|
Temporary variable.
Definition at line 176 of file RFieldStateMachine.h. Referenced by findNextState(), and reset(). |
|
The edge buffer.
Definition at line 178 of file RFieldStateMachine.h. Referenced by farPoint(), getEdge(), nearPoint(), and update(). |
|
The start point stored at the last reset.
Definition at line 180 of file RFieldStateMachine.h. |
|
The type buffer.
Definition at line 182 of file RFieldStateMachine.h. Referenced by executeState(), getObstacleType(), getType(), and update(). |
|
The active state.
Definition at line 184 of file RFieldStateMachine.h. |
|
The number of edges found since last reset.
Definition at line 186 of file RFieldStateMachine.h. |
|
The far point of the obstacle.
Definition at line 188 of file RFieldStateMachine.h. Referenced by executeState(), farPoint(), foundObstacle(), getObstacleType(), reset(), and update(). |
|
The near point of the obstacle.
Definition at line 190 of file RFieldStateMachine.h. Referenced by foundObstacle(), nearPoint(), reset(), and update(). |