37 intersects(
const VirtualRobot::BoundingBox& bb1,
const VirtualRobot::BoundingBox& bb2)
163 std::vector<Eigen::Vector2f> result;
166 ARMARX_DEBUG <<
"Setting start node for position " << start;
167 NodePtr nodeStart = closestNode(start);
170 ARMARX_DEBUG <<
"Setting goal node for position " << goal;
171 NodePtr nodeGoal = closestNode(goal);
172 ARMARX_CHECK(fulfillsConstraints(nodeGoal)) <<
"Goal node in collision!";
174 std::vector<NodePtr> closedSet;
176 std::vector<NodePtr> openSet;
177 openSet.push_back(nodeStart);
179 std::map<NodePtr, float> gScore;
180 gScore[nodeStart] = 0;
182 std::map<NodePtr, float> fScore;
183 fScore[nodeStart] = gScore[nodeStart] + heuristic(nodeStart, nodeGoal);
185 while (!openSet.empty())
187 float lowestScore = fScore[openSet[0]];
188 auto currentIT = openSet.begin();
189 for (
auto it = openSet.begin() + 1; it != openSet.end(); it++)
191 if (fScore[*it] < lowestScore)
193 lowestScore = fScore[*it];
197 NodePtr currentBest = *currentIT;
198 if (currentBest == nodeGoal)
203 openSet.erase(currentIT);
204 closedSet.push_back(currentBest);
205 for (
size_t i = 0; i < currentBest->successors.size(); i++)
207 NodePtr neighbor = currentBest->successors[i];
208 if (std::find(closedSet.begin(), closedSet.end(), neighbor) != closedSet.end())
213 float tentativeGScore = gScore[currentBest] + costs(currentBest, neighbor);
214 bool notInOS = std::find(openSet.begin(), openSet.end(), neighbor) == openSet.end();
215 if (notInOS || tentativeGScore < gScore[neighbor])
217 neighbor->predecessor = currentBest;
218 gScore[neighbor] = tentativeGScore;
219 fScore[neighbor] = tentativeGScore + heuristic(neighbor, nodeGoal);
222 openSet.push_back(neighbor);
231 result = nodeGoal->traversePredecessors();
235 ranges::reverse(result);