Hybrid A* Planner
 All Classes Namespaces Files Functions Variables Friends Pages
dynamicvoronoi.h
1 #ifndef _DYNAMICVORONOI_H_
2 #define _DYNAMICVORONOI_H_
3 
4 
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include <limits.h>
8 #include <queue>
9 
10 #include "bucketedqueue.h"
11 
12 namespace HybridAStar {
15 
16  public:
17 
19  ~DynamicVoronoi();
20 
22  void initializeEmpty(int _sizeX, int _sizeY, bool initGridMap = true);
24  void initializeMap(int _sizeX, int _sizeY, bool** _gridMap);
25 
27  void occupyCell(int x, int y);
29  void clearCell(int x, int y);
31  void exchangeObstacles(std::vector<INTPOINT> newObstacles);
32 
34  void update(bool updateRealDist = true);
36  void prune();
37 
39  float getDistance(int x, int y);
41  bool isVoronoi(int x, int y);
43  bool isOccupied(int x, int y);
45  void visualize(const char* filename = "result.ppm");
46 
48  unsigned int getSizeX() {return sizeX;}
50  unsigned int getSizeY() {return sizeY;}
51 
52  // was private, changed to public for obstX, obstY
53  public:
54  struct dataCell {
55  float dist;
56  char voronoi;
57  char queueing;
58  int obstX;
59  int obstY;
60  bool needsRaise;
61  int sqdist;
62  };
63 
64  typedef enum {voronoiKeep = -4, freeQueued = -3, voronoiRetry = -2, voronoiPrune = -1, free = 0, occupied = 1} State;
65  typedef enum {fwNotQueued = 1, fwQueued = 2, fwProcessed = 3, bwQueued = 4, bwProcessed = 1} QueueingState;
66  typedef enum {invalidObstData = SHRT_MAX / 2} ObstDataState;
67  typedef enum {pruned, keep, retry} markerMatchResult;
68 
69 
70 
71  // methods
72  void setObstacle(int x, int y);
73  void removeObstacle(int x, int y);
74  inline void checkVoro(int x, int y, int nx, int ny, dataCell& c, dataCell& nc);
75  void recheckVoro();
76  void commitAndColorize(bool updateRealDist = true);
77  inline void reviveVoroNeighbors(int& x, int& y);
78 
79  inline bool isOccupied(int& x, int& y, dataCell& c);
80  inline markerMatchResult markerMatch(int x, int y);
81 
82  // queues
83 
84  BucketPrioQueue open;
85  std::queue<INTPOINT> pruneQueue;
86 
87  std::vector<INTPOINT> removeList;
88  std::vector<INTPOINT> addList;
89  std::vector<INTPOINT> lastObstacles;
90 
91  // maps
92  int sizeY;
93  int sizeX;
94  dataCell** data;
95  bool** gridMap;
96 
97  // parameters
98  int padding;
99  double doubleThreshold;
100 
101  double sqrt2;
102 
103  // dataCell** getData(){ return data; }
104 };
105 }
106 
107 #endif
108 
void initializeEmpty(int _sizeX, int _sizeY, bool initGridMap=true)
Initialization with an empty map.
Definition: dynamicvoronoi.cpp:25
void occupyCell(int x, int y)
add an obstacle at the specified cell coordinate
Definition: dynamicvoronoi.cpp:102
bool isVoronoi(int x, int y)
returns whether the specified cell is part of the (pruned) Voronoi graph
Definition: dynamicvoronoi.cpp:249
unsigned int getSizeY()
returns the vertical size of the workspace/map
Definition: dynamicvoronoi.h:50
bool isOccupied(int x, int y)
checks whether the specficied location is occupied
Definition: dynamicvoronoi.cpp:351
void initializeMap(int _sizeX, int _sizeY, bool **_gridMap)
Initialization with a given binary map (false==free, true==occupied)
Definition: dynamicvoronoi.cpp:62
Definition: dynamicvoronoi.h:54
void visualize(const char *filename="result.ppm")
write the current distance map and voronoi diagram as ppm file
Definition: dynamicvoronoi.cpp:360
void prune()
prune the Voronoi diagram
Definition: dynamicvoronoi.cpp:397
float getDistance(int x, int y)
returns the obstacle distance at the specified location
Definition: dynamicvoronoi.cpp:244
unsigned int getSizeX()
returns the horizontal size of the workspace/map
Definition: dynamicvoronoi.h:48
void clearCell(int x, int y)
remove an obstacle at the specified cell coordinate
Definition: dynamicvoronoi.cpp:106
A DynamicVoronoi object computes and updates a distance map and Voronoi diagram.
Definition: dynamicvoronoi.h:14
void exchangeObstacles(std::vector< INTPOINT > newObstacles)
remove old dynamic obstacles and add the new ones
Definition: dynamicvoronoi.cpp:132
void update(bool updateRealDist=true)
update distance map and Voronoi diagram to reflect the changes
Definition: dynamicvoronoi.cpp:155