35 #ifndef COSTMAP_QUEUE__COSTMAP_QUEUE_HPP_
36 #define COSTMAP_QUEUE__COSTMAP_QUEUE_HPP_
42 #include "nav2_costmap_2d/costmap_2d.hpp"
43 #include "costmap_queue/map_based_queue.hpp"
45 namespace costmap_queue
64 const double d,
const unsigned int i,
const unsigned int x,
const unsigned int y,
65 const unsigned int sx,
const unsigned int sy)
66 : distance_(d), index_(i), x_(x), y_(y), src_x_(sx), src_y_(sy)
74 : distance_(std::numeric_limits<double>::max()), index_(0), x_(0), y_(0), src_x_(0), src_y_(0)
78 static unsigned absolute_difference(
const unsigned x,
const unsigned y)
80 return (x > y) ? (x - y) : (y - x);
86 unsigned int src_x_, src_y_;
121 void reset()
override;
147 typedef std::shared_ptr<CostmapQueue>
Ptr;
154 unsigned int index,
unsigned int cur_x,
unsigned int cur_y,
unsigned int src_x,
163 std::vector<bool> seen_;
177 const unsigned int cur_x,
const unsigned int cur_y,
178 const unsigned int src_x,
const unsigned int src_y)
180 unsigned int dx = CellData::absolute_difference(cur_x, src_x);
181 unsigned int dy = CellData::absolute_difference(cur_y, src_y);
182 return cached_distances_[dx][dy];
184 std::vector<std::vector<double>> cached_distances_;
185 int cached_max_distance_;
Storage for cell information used during queue expansion.
CellData(const double d, const unsigned int i, const unsigned int x, const unsigned int y, const unsigned int sx, const unsigned int sy)
Real Constructor.
CellData()
Default Constructor - Should be used sparingly.
double distanceLookup(const unsigned int cur_x, const unsigned int cur_y, const unsigned int src_x, const unsigned int src_y)
Lookup pre-computed distances.
std::shared_ptr< CostmapQueue > Ptr
convenience typedef for a pointer
void enqueueCell(unsigned int x, unsigned int y)
Add a cell the queue.
CellData getNextCell()
Get the next cell to examine, and enqueue its neighbors as needed.
void reset() override
Clear the queue.
void computeCache()
Compute the cached distances.
CostmapQueue(nav2_costmap_2d::Costmap2D &costmap, bool manhattan=false)
constructor
virtual bool validCellToQueue(const CellData &)
Check to see if we should add this cell to the queue. Always true unless overridden.
Templatized interface for a priority queue.
A 2D costmap provides a mapping between points in the world and their associated "costs".