32 #include <unordered_map> 53 std::vector<Astar::PriorityVec> centers;
61 std::vector<Astar::GridmapUpdate> updates;
63 std::unordered_map<Astar::Vec, bool, Astar::Vec> edges_local;
64 edges_local.reserve(open.
capacity() / omp_get_num_threads());
75 const float start_cost =
g_[s_rough];
82 if (center.p_raw_ >
g_[center.v_])
84 if (center.p_raw_ - range_overshoot > start_cost)
89 centers.emplace_back(std::move(center));
94 if (centers.size() == 0)
98 #pragma omp for schedule(static) 99 for (
auto it = centers.cbegin(); it < centers.cend(); ++it)
108 if (static_cast<size_t>(next[0]) >=
static_cast<size_t>(
p_.
size[0]) ||
109 static_cast<size_t>(next[1]) >=
static_cast<size_t>(
p_.
size[1]))
114 float cost = ds.euclid_cost;
116 const float gnext =
g_[next];
118 if (gnext <
g_[p] + cost)
125 float sum = 0, sum_hist = 0;
126 bool collision =
false;
127 for (
const auto& d : ds.pos)
141 edges_local[p] =
true;
145 (weight_linear * ds.grid_to_len) *
155 const float cost_next = it->p_raw_ + cost;
156 if (gnext > cost_next)
158 updates.emplace_back(p, next, cost_next, cost_next);
165 for (
const Astar::GridmapUpdate& u : updates)
167 if (
g_[u.getPos()] > u.getCost())
169 g_[u.getPos()] = u.getCost();
170 open.push(std::move(u.getPriorityVec()));
173 for (
const auto& e : edges_local)
210 const int range_rough = 4;
211 for (
Astar::Vec d(-range_rough, 0, 0);
d[0] <= range_rough;
d[0]++)
213 for (
d[1] = -range_rough;
d[1] <= range_rough;
d[1]++)
215 if (
d[0] == 0 &&
d[1] == 0)
217 if (
d.sqlen() > range_rough * range_rough)
222 const float grid_to_len =
d.gridToLenFactor();
223 const int dist =
d.len();
224 const float dpx =
static_cast<float>(
d[0]) / dist;
225 const float dpy =
static_cast<float>(
d[1]) / dist;
227 for (
int i = 0; i < dist; i++)
230 if (diffs.
pos.size() == 0 || diffs.
pos.back() != ipos)
232 diffs.
pos.push_back(std::move(ipos));
250 float cost_min = std::numeric_limits<float>::max();
253 for (p[0] = rect.
min[0]; p[0] <= rect.
max[0]; p[0]++)
255 if (cost_min >
g_[p])
274 if (cost_min != std::numeric_limits<float>::max())
279 if (
g_[s_rough] > cost_min)
292 if (
g_[p] == std::numeric_limits<float>::max())
294 g_[p] = std::numeric_limits<float>::max();
298 for (
d[1] = -1;
d[1] <= 1;
d[1]++)
300 if (!((
d[0] == 0) ^ (
d[1] == 0)))
304 if ((
unsigned int)next[0] >= (
unsigned int)
p_.
size[0] ||
305 (
unsigned int)next[1] >= (
unsigned int)
p_.
size[1])
307 const float gn =
g_[next];
308 if (gn == std::numeric_limits<float>::max())
329 for (
const auto& e :
edges_)
331 const float p =
g_[e.first];
342 g_.clear(std::numeric_limits<float>::max());
std::shared_ptr< GridAstarModel3D > Ptr
void init(const GridAstarModel3D::Ptr model, const Params &p)
CyclicVecInt< DIM, NONCYCLIC > Vec
DistanceMap(const BlockMemGridmapBase< char, 3, 2 > &cm_rough, const CostmapBBF &bbf_costmap)
char getCost(const Vec &p) const
std::vector< Astar::Vec > pos
const BlockMemGridmapBase< char, 3, 2 > & cm_rough_
reservable_priority_queue< Astar::PriorityVec > pq_erase_
Astar::Gridmap< float > g_
size_type capacity() const
const CostmapBBF & bbf_costmap_
void setParams(const CostCoeff &cc, const int num_cost_estim_task)
reservable_priority_queue< Astar::PriorityVec > pq_open_
std::vector< SearchDiffs > search_diffs_
void fillCostmap(reservable_priority_queue< Astar::PriorityVec > &open, const Astar::Vec &s_rough)
void create(const Astar::Vec &s, const Astar::Vec &e)
std::unordered_map< Astar::Vec, bool, Astar::Vec > edges_
void update(const Astar::Vec &s, const Astar::Vec &e, const Rect &rect)