Performance: Global planner (A*, Dijkstra)
This affects the time it takes for the robot to compute a path and start moving, impacting responsiveness and user experience in navigation tasks.
Use A* algorithm with an admissible heuristic (e.g., Euclidean distance): // Pseudocode while openSet not empty: current = node with lowest cost + heuristic for each neighbor of current: update cost if cheaper path found return shortest path
Use Dijkstra's algorithm without heuristics on large maps:
// Pseudocode
while openSet not empty:
current = node with lowest cost
for each neighbor of current:
update cost if cheaper path found
return shortest path| Pattern | CPU Usage | Nodes Explored | Calculation Time | Verdict |
|---|---|---|---|---|
| Dijkstra (no heuristic) | High | All reachable nodes | Slow on large maps | [X] Bad |
| A* with heuristic | Medium | Fewer nodes near goal | Faster path calculation | [OK] Good |
std::vector<Point> path = planner.makePlan(start, goal); std::cout << path.size() << std::endl;If the planner finds a path with 5 points, what will be printed?
std::vector<Point> path = planner.makePlan(start, goal);
for (int i = 0; i <= path.size(); i++) {
std::cout << path[i].x << "," << path[i].y << std::endl;
}
What is the error in this code?Pass the test and this pattern moves unknown