#include "aalgorithm.h"#include "pathqueue.h"#include "map.h"#include <math.h>#include <stdlib.h>

Go to the source code of this file.
| #define | SQRT2 1.41421356 |
| #define | WALL_COST 1000 |
| Cost fo jumping a wall. | |
| GraphMapCell | graph [MAP_HEIGHT][MAP_WIDTH] |
| void | pushNodeInOrder (NodeQueue *q, int x, int y) |
| float | cFunction (int x1, int y1, int x2, int y2) |
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) |
A* Implementation Functions | |
This functions have not a meaning in A* algorithm, but are needed for implementation. | |
| void | initGraphStructure (void) |
A* Other Functions | |
| int | getPathLength (int xstart, int ystart, int xgoal, int ygoal) |
Definition in file aalgorithm.c.
| 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.
Referenced by path_planner().

| 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.
Referenced by calculateMapHeuristic().

| 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.
Referenced by aAlgorithm().

| 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.
Referenced by aAlgorithm().

| void initGraphStructure | ( | void | ) |
Init Graph structure with default values
Definition at line 291 of file aalgorithm.c.
Referenced by aAlgorithm().

1.5.3