You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Breadth-first search raises KeyError for unreachable goal or start equal to goal #1502
BreadthFirstSearchPlanner.planning in PathPlanning/BreadthFirstSearch/breadth_first_search.py raises KeyError: -1 instead of returning a result in two cases.
1. The goal cannot be reached. When the open set is exhausted the loop only breaks, and calc_final_path then evaluates closedset[ngoal.parent_index] with the goal's initial parent index -1.
2. The start is the goal. The goal is found on the first iteration with parent_index == -1, so the same lookup fails.
Reproduce
fromPathPlanning.BreadthFirstSearchimportbreadth_first_searchasmm.show_animation=False# square boundary 0..10 with an inner wall at x = 5ox, oy= [], []
foriinrange(11):
ox+= [0.0, 10.0, float(i), float(i), 5.0]
oy+= [float(i), float(i), 0.0, 10.0, float(i)]
planner=m.BreadthFirstSearchPlanner(ox, oy, 1.0, 0.5)
planner.planning(2.0, 5.0, 8.0, 5.0) # KeyError: -1 (goal behind the wall)planner.planning(2.0, 5.0, 2.0, 5.0) # KeyError: -1 (start == goal)
Activity