Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

RFieldStateMachine Class Reference

This class represents a deterministic state machine. More...

#include <RFieldStateMachine.h>

Collaboration diagram for RFieldStateMachine:

Collaboration graph
[legend]
List of all members.

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.


Detailed Description

This class represents a deterministic state machine.

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.

Author:
Bernd Schmidt

Definition at line 34 of file RFieldStateMachine.h.


Member Enumeration Documentation

enum RFieldStateMachine::PointTypes
 

Different point types.

Enumeration values:
nothing 
blueRobot 
redRobot 
border 
line 
ball 
skyblueGoal 
yellowGoal 
unknown 
numberOfPointTypes 

Definition at line 40 of file RFieldStateMachine.h.

Referenced by getType().

enum RFieldStateMachine::FIELD_STATES
 

The different states.

Enumeration values:
START 
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 

Definition at line 54 of file RFieldStateMachine.h.


Constructor & Destructor Documentation

RFieldStateMachine::RFieldStateMachine  ) 
 

Constructor.

Definition at line 11 of file RFieldStateMachine.cpp.

References reset().

Here is the call graph for this function:

RFieldStateMachine::~RFieldStateMachine  ) 
 

Destructor.

Definition at line 17 of file RFieldStateMachine.cpp.


Member Function Documentation

void RFieldStateMachine::update int  x,
int  y,
REdgeDetection scanner
 

Updates the state machine after a scan.

Parameters:
x current x-coordinate.
y current y-coordinate.
scanner Reference of the edge scanner.

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:

void RFieldStateMachine::reset int  x,
int  y
 

Resets the state machine.

The first point is setted to (x,y).

Parameters:
x x-coordinate
y y-coordinate

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().

Vector2<int> RFieldStateMachine::getEdge int  index  )  [inline]
 

Returns one of the detected edge points.

Parameters:
index The index of the point.
Returns:
The edge point as Vector2<int>

Definition at line 98 of file RFieldStateMachine.h.

References edgeBuffer.

Referenced by RDefaultStrategy::postScan().

PointTypes RFieldStateMachine::getType int  index  )  [inline]
 

Returns the type of one of the detected edge points.

Parameters:
index The index of the point.
Returns:
The type of a edge point.

Definition at line 106 of file RFieldStateMachine.h.

References PointTypes, and types.

Referenced by RDefaultStrategy::postScan().

int RFieldStateMachine::size  )  [inline]
 

Returns the number of edges found after the last reset.

Returns:
Number of edge points.

Definition at line 112 of file RFieldStateMachine.h.

Referenced by RDefaultStrategy::postScan().

bool RFieldStateMachine::foundObstacle  )  [inline]
 

Tells if the machine determined a obstacle and its free space.

Returns:
True, if the machine determined a obstacle after the last reset.

Definition at line 118 of file RFieldStateMachine.h.

References obstacleFarPoint, and obstacleNearPoint.

Referenced by RDefaultStrategy::postScan().

Vector2<int>& RFieldStateMachine::nearPoint  )  [inline]
 

Returns the near point of the detected obstacle space.

Returns:
The near obstacle point.

Definition at line 124 of file RFieldStateMachine.h.

References edgeBuffer, and obstacleNearPoint.

Referenced by RDefaultStrategy::postScan().

Vector2<int>& RFieldStateMachine::farPoint  )  [inline]
 

Returns the far point of the detected obstacle space.

Returns:
The far obstacle point.

Definition at line 130 of file RFieldStateMachine.h.

References edgeBuffer, and obstacleFarPoint.

Referenced by RDefaultStrategy::postScan().

ObstaclesPercept::ObstacleType RFieldStateMachine::getObstacleType  )  [inline]
 

Returns the type of the obstacle.

Returns:
The obstacle type.

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:

void RFieldStateMachine::findNextState  )  [private]
 

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().

void RFieldStateMachine::executeState  )  [private]
 

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().


Member Data Documentation

colorClass RFieldStateMachine::color [private]
 

Current color.

Definition at line 164 of file RFieldStateMachine.h.

int RFieldStateMachine::range [private]
 

The range between the last two edges.

Definition at line 166 of file RFieldStateMachine.h.

int RFieldStateMachine::rangeSum [private]
 

The sum of ranges since the last reset.

Definition at line 168 of file RFieldStateMachine.h.

Referenced by update().

int RFieldStateMachine::greenRange [private]
 

The sum of the green range.

Definition at line 170 of file RFieldStateMachine.h.

Referenced by executeState(), and update().

int RFieldStateMachine::whiteRange [private]
 

The sum of the white range.

Definition at line 172 of file RFieldStateMachine.h.

Referenced by findNextState(), and update().

int RFieldStateMachine::grayRange [private]
 

The sum of the gray range.

Definition at line 174 of file RFieldStateMachine.h.

Referenced by findNextState(), and update().

bool RFieldStateMachine::isUnknownBot [private]
 

Temporary variable.

Definition at line 176 of file RFieldStateMachine.h.

Referenced by findNextState(), and reset().

Vector2<int> RFieldStateMachine::edgeBuffer[20] [private]
 

The edge buffer.

Definition at line 178 of file RFieldStateMachine.h.

Referenced by farPoint(), getEdge(), nearPoint(), and update().

Vector2<int> RFieldStateMachine::start [private]
 

The start point stored at the last reset.

Definition at line 180 of file RFieldStateMachine.h.

PointTypes RFieldStateMachine::types[20] [private]
 

The type buffer.

Definition at line 182 of file RFieldStateMachine.h.

Referenced by executeState(), getObstacleType(), getType(), and update().

FIELD_STATES RFieldStateMachine::state [private]
 

The active state.

Definition at line 184 of file RFieldStateMachine.h.

int RFieldStateMachine::numberOfEdges [private]
 

The number of edges found since last reset.

Definition at line 186 of file RFieldStateMachine.h.

int RFieldStateMachine::obstacleFarPoint [private]
 

The far point of the obstacle.

Definition at line 188 of file RFieldStateMachine.h.

Referenced by executeState(), farPoint(), foundObstacle(), getObstacleType(), reset(), and update().

int RFieldStateMachine::obstacleNearPoint [private]
 

The near point of the obstacle.

Definition at line 190 of file RFieldStateMachine.h.

Referenced by foundObstacle(), nearPoint(), reset(), and update().


The documentation for this class was generated from the following files:
Generated on Thu Sep 23 20:11:23 2004 for GT2004 by doxygen 1.3.6