30 #include <opencv2/core/mat.hpp> 46 float potentialPrev = _potential[_current.
i];
50 if (next.
i < 0 || next.
i >
ns_)
64 _potential[next.
i] = pot;
74 uint32_t _noGoalPoses = _optimizationSteps + 1;
76 Index current(_start.
i, 0, 0, 0);
77 _potential[current.
i] = 0;
83 Index currentGoal(-1, -1, -1, -1);
86 while (!
queue_.empty() && _noGoalPoses > 0 && cycle < _cycles)
89 return Index(-1, -1, -1, -1);
94 int32_t segmentIndex = -1;
96 if (
isGoal(current, _goals, segmentIndex))
98 if (currentGoal.
i == -1)
100 currentGoal = current;
101 segIdx = segmentIndex;
105 if (_potential[current.
i] < _potential[currentGoal.
i] + current.
distance(currentGoal,
nx_))
107 currentGoal = current;
108 segIdx = segmentIndex;
114 if (_noGoalPoses == 0)
126 if (cycle >= _cycles)
127 return Index(-1, -1, -1, -1);
136 for (
const std::pair<uint32_t, Index> &g : _goals)
138 if (_p.
i == g.second.i)
148 bool PointExpander::findGoalOnMap(
const Eigen::Vector2d &_start,
const uint32_t &_cycles,
float *_potential,
const std::map<uint32_t, Eigen::Vector2d> &_goals,
const uint32_t &_optimizationSteps, Eigen::Vector2d &_foundPoint, int32_t &_segIdx,
const uint32_t &_radius)
150 Index startPoint((int32_t)_start[0], (int32_t)_start[1],
nx_, 0, 0, 0);
152 if (startPoint.
i < 0)
155 Index foundPoint(-1, -1, -1, -1);
157 std::map<uint32_t, Index> goals;
159 for (
const std::pair<int, Eigen::Vector2d> &g : _goals)
161 Index idx((int32_t)g.second[0], (int32_t)g.second[1],
nx_, 0, 0, 0);
162 std::pair<uint32_t, Index> i(g.first, idx);
166 foundPoint =
findGoal(startPoint, _cycles, _potential, goals, _optimizationSteps, _segIdx, _radius);
167 _foundPoint[0] = ((int32_t)foundPoint.
getX(
nx_));
168 _foundPoint[1] = ((int32_t)foundPoint.
getY(
nx_));
170 return (foundPoint.
i >= 0);
175 Index point((int32_t)_pt[0], (int32_t)_pt[1],
nx_, 0, 0, 0);
float distance(Index _p, int _nx)
void addPotentialExpansionCandidate(Index _current, int32_t _next_x, int32_t _next_y, float *_potential, uint32_t _distToObstacle)
bool findGoalOnMap(const Eigen::Vector2d &_start, const uint32_t &_cycles, float *_potential, const std::map< uint32_t, Eigen::Vector2d > &_goals, const uint32_t &_optimizationSteps, Eigen::Vector2d &_foundPoint, int32_t &_segIdx, const uint32_t &_radius)
searches the first occurence of a point in the goals_ list and returns the index
float getDistanceToObstacle(const Eigen::Vector2d &vec)
returns the distance to the closest obstacle for a point
void clearpq(std::priority_queue< T, S, C > &q)
void initialize(const cv::Mat &_map)
initializes the point expander with a distance map
Index findGoal(const Index &_start, const uint32_t &_cycles, float *_potential, const std::map< uint32_t, Index > &_goals, const uint32_t &_optimizationSteps, int32_t &segIdx, const uint32_t &_radius)
std::priority_queue< Index, std::vector< Index >, greater1 > queue_
Index offsetDist(int dist_x, int dist_y, int nx, int ny)
bool isGoal(Index _p, const std::map< uint32_t, Index > &_goals, int32_t &segIdx)