From 6dde41a03e7cf420803fd3c15b4d692ec69c727c Mon Sep 17 00:00:00 2001 From: huxiaoyi-ovo Date: Mon, 31 Aug 2026 23:32:36 +0800 Subject: [PATCH 1/2] Fix no-path result in road-map Dijkstra search --- PathPlanning/VoronoiRoadMap/dijkstra_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PathPlanning/VoronoiRoadMap/dijkstra_search.py b/PathPlanning/VoronoiRoadMap/dijkstra_search.py index 503ccc342e..68df9e5b81 100644 --- a/PathPlanning/VoronoiRoadMap/dijkstra_search.py +++ b/PathPlanning/VoronoiRoadMap/dijkstra_search.py @@ -59,7 +59,7 @@ def search(self, sx, sy, gx, gy, node_x, node_y, edge_ids_list): break elif not open_set: print("Cannot find path") - break + return [], [] current_id = min(open_set, key=lambda o: open_set[o].cost) current_node = open_set[current_id] From 0bb71cd66e86f48ac950607eef71c3873d0b1596 Mon Sep 17 00:00:00 2001 From: huxiaoyi-ovo Date: Mon, 31 Aug 2026 23:32:43 +0800 Subject: [PATCH 2/2] Add regression test for unreachable road-map goal --- tests/test_voronoi_dijkstra_search.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/test_voronoi_dijkstra_search.py diff --git a/tests/test_voronoi_dijkstra_search.py b/tests/test_voronoi_dijkstra_search.py new file mode 100644 index 0000000000..ee043b675a --- /dev/null +++ b/tests/test_voronoi_dijkstra_search.py @@ -0,0 +1,18 @@ +import conftest # Add root path to sys.path +from PathPlanning.VoronoiRoadMap.dijkstra_search import DijkstraSearch + + +def test_unreachable_goal_returns_empty_path(): + node_x = [0.0, 1.0, 2.0] + node_y = [0.0, 0.0, 0.0] + edge_ids_list = [[1], [0], []] + + rx, ry = DijkstraSearch(False).search( + 0.0, 0.0, 2.0, 0.0, node_x, node_y, edge_ids_list) + + assert rx == [] + assert ry == [] + + +if __name__ == '__main__': + conftest.run_this_test(__file__)