Go to the source code of this file.
Classes | |
struct | _GraphMapCell |
Typedefs | |
typedef struct _GraphMapCell | GraphMapCell |
Functions | |
int | aAlgorithm (double xstart_real, double ystart_real, double xgoal_real, double ygoal_real, double **original_path) |
void | calculateMapHeuristic (int xgoal, int ygoal) |
float | calculateCost (int x1, int y1, int x2, int y2) |
void | initGraphStructure (void) |
int | getPathLength (int xstart, int ystart, int xgoal, int ygoal) |
void | ShmapAllFreeSpace (void) |
Definition in file aalgorithm.h.
typedef struct _GraphMapCell GraphMapCell |
Information of a cell in A* Algorithm
int aAlgorithm | ( | double | xstart_real, | |
double | ystart_real, | |||
double | xgoal_real, | |||
double | ygoal_real, | |||
double ** | original_path | |||
) |
Search the shortest path between two points
xstart | Coordonate X of the start point | |
ystart | Coordonate Y of the start point | |
xgoal | Coordonate X of the goal point | |
ygoal | Coordonate Y of the goal point | |
original_path | [out] The original path. See details bellow. |
This is an implementation of A* Algorithm (Algorithm 24, p531) defined in the book "Principles of Robot Motion" by H. Choset&others
prioritySet : Set of nodes to process order by heuristic distance
nbest : Best node to reach the goal
Definition at line 45 of file aalgorithm.c.
References _GraphMapCell::bx, _GraphMapCell::by, calculateMapHeuristic(), cFunction(), delQueue(), drainQueue(), _GraphMapCell::f, _GraphMapCell::g, getPathLength(), graph, _GraphMapCell::h, initGraphStructure(), isInQueue(), newQueue(), popNode(), _GraphMapCell::processed, pushNodeInOrder(), pushNodeLast(), queueIsEmpty(), ShmapCell2Point_X(), ShmapCell2Point_Y(), ShmapIsCellInMap(), ShmapIsFreeCell(), ShmapPoint2Cell_X(), ShmapPoint2Cell_Y(), _Node::x, and _Node::y.
float calculateCost | ( | int | x1, | |
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Calculates the cost of moving from the first cell to the second cell.
x1 | Coordonate X of the first cell | |
y1 | Coordonate Y of the first cell | |
x2 | Coordonate X of the second cell | |
y2 | Coordonate Y of the second cell |
Definition at line 272 of file aalgorithm.c.
References SQRT2.
void calculateMapHeuristic | ( | int | xgoal, | |
int | ygoal | |||
) |
Calculates Map Heuristic values.
xgoal | Coordonate X of the goal | |
ygoal | Coordonate Y of the goal |
This function calculates the map heuristic values (the distance to the goal that is supoused to be the shortest). The chosen method has been the euclidean distance. The distance between a point of the grid and the goal
is
.
Another method explained in the book is coded but not used.It is called Brushfire algorithm. (section 4.3.2 of the book)
Definition at line 201 of file aalgorithm.c.
References calculateCost(), graph, _GraphMapCell::h, isInQueue(), MAP_HEIGHT, MAP_WIDTH, newQueue(), popNode(), _GraphMapCell::processed, pushNode(), queueIsEmpty(), ShmapIsCellInMap(), _Node::x, and _Node::y.
int getPathLength | ( | int | xstart, | |
int | ystart, | |||
int | xgoal, | |||
int | ygoal | |||
) |
Returns the number of points of original path
xstart | Coordonate X of the first cell | |
ystart | Coordonate Y of the first cell | |
xgoal | Coordonate X of the second cell | |
ygoal | Coordonate Y of the second cell |
Definition at line 370 of file aalgorithm.c.
References _GraphMapCell::bx, _GraphMapCell::by, graph, MAP_GOAL, MAP_PATH, MAP_START, and ShmapSetCellValue().
void initGraphStructure | ( | void | ) |
Init Graph structure with default values
Definition at line 291 of file aalgorithm.c.
References _GraphMapCell::bx, _GraphMapCell::by, _GraphMapCell::f, _GraphMapCell::g, graph, _GraphMapCell::h, MAP_HEIGHT, MAP_WIDTH, and _GraphMapCell::processed.
void ShmapAllFreeSpace | ( | void | ) |