pushNodeInOrder(start);
/// <li> Expand nbest :for all x E Star(nbest) that are not in C
- const struct { int x; int y; } neigh[] = { { 0, 1}, { 1, 1}, { 1, 0}, {-1, 1},
- {-1, 0}, {-1,-1}, { 0,-1}, { 1,-1}};
-
-
- // Adds safety zone around the obstacle.
- // This zone contains one neighbour cell (to avoid frequent recalculation).
- int xx, yy, ii;
- for (yy=0;yy<MAP_HEIGHT;yy++) {
- for (xx=0;xx<MAP_WIDTH;xx++) {
- // check obstacles around this cell to determine safety zone flag
- map->cells[yy][xx].flags &= ~MAP_FLAG_PLAN_MARGIN; // delete margin status
- for (ii=0; ii< sizeof(neigh)/sizeof(neigh[0]); ii++)
- {
- if (ShmapIsCellInMap(xx+neigh[ii].x, yy+neigh[ii].y)
- && (((map->cells[yy+neigh[ii].y][xx+neigh[ii].x]).flags & MAP_FLAG_DET_OBST)
- || (map->cells[yy+neigh[ii].y][xx+neigh[ii].x]).detected_obstacle > 0 ))
- {
- // creates safety status
- map->cells[yy][xx].flags |= MAP_FLAG_PLAN_MARGIN;
- //cntr ++;
- break;
- }
- }
- }
- }
+
//printf("*cntr %d \n", cntr);
/// <li> REPEAT until the queue is empty.
#include <pthread.h>
#define DBG printf
+static void add_safety_margin()
+{
+ // Adds safety zone around the obstacle.
+ // This zone contains one neighbour cell (to avoid frequent recalculation).
+ int xx, yy, ii;
+ struct map *map = ShmapIsMapInit();
+ const struct { int x; int y; } neigh[] = { { 0, 1}, { 1, 1}, { 1, 0}, {-1, 1},
+ {-1, 0}, {-1,-1}, { 0,-1}, { 1,-1}};
+
+ for (yy=0;yy<MAP_HEIGHT;yy++) {
+ for (xx=0;xx<MAP_WIDTH;xx++) {
+ // check obstacles around this cell to determine safety zone flag
+ map->cells[yy][xx].flags &= ~MAP_FLAG_PLAN_MARGIN; // delete margin status
+ for (ii=0; ii< sizeof(neigh)/sizeof(neigh[0]); ii++)
+ {
+ if (ShmapIsCellInMap(xx+neigh[ii].x, yy+neigh[ii].y)
+ && (((map->cells[yy+neigh[ii].y][xx+neigh[ii].x]).flags & MAP_FLAG_DET_OBST)
+ || (map->cells[yy+neigh[ii].y][xx+neigh[ii].x]).detected_obstacle > 0 ))
+ {
+ // creates safety status
+ map->cells[yy][xx].flags |= MAP_FLAG_PLAN_MARGIN;
+ //cntr ++;
+ break;
+ }
+ }
+ }
+ }
+}
+
/**
* Returns the number of points of the path on success or an error code.
return PP_ERROR_MAP_NOT_INIT;
}
+ add_safety_margin();
+
// If the goal map is not free, abort.
if (!ShmapIsFreePoint(xgoal_real, ygoal_real)) {
DBG("ERROR: the goal cell is an obstacle.\n");