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
Depth-first search raises KeyError for unreachable goal or start equal to goal #1503
DepthFirstSearchPlanner.planning in PathPlanning/DepthFirstSearch/depth_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.
This is the same bug as in breadth-first search (#1502); the two planners share this code.
Reproduce
fromPathPlanning.DepthFirstSearchimportdepth_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.DepthFirstSearchPlanner(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