astar.h 946 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef _ASTAR_H
  2. #define _ASTAR_H
  3. #include <global_planner/planner_core.h>
  4. #include <global_planner/expander.h>
  5. #include <vector>
  6. #include <algorithm>
  7. namespace global_planner {
  8. class Index {
  9. public:
  10. Index(int a, float b)
  11. {
  12. i = a;
  13. cost = b;
  14. }
  15. int i;
  16. float cost;
  17. };
  18. struct greater1 {
  19. bool operator()(const Index& a, const Index& b) const {
  20. return a.cost > b.cost;
  21. }
  22. };
  23. class AStarExpansion : public Expander {
  24. public:
  25. AStarExpansion(PotentialCalculator* p_calc, int nx, int ny);
  26. bool calculatePotentials(unsigned char* costs, double start_x, double start_y, double end_x, double end_y, int cycles, float* potential);
  27. private:
  28. void add(unsigned char* costs, float* potential, float prev_potential, int next_i, int end_x, int end_y);
  29. std::vector<Index> queue_;
  30. };
  31. } //end namespace global_planner
  32. #endif