From e03001eae696f9475614e3cfbe351cf543ad51bf Mon Sep 17 00:00:00 2001 From: huxiaoyi-ovo Date: Mon, 31 Aug 2026 23:34:45 +0800 Subject: [PATCH 1/3] Handle goal node at index zero in RRT Dubins --- PathPlanning/RRTDubins/rrt_dubins.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PathPlanning/RRTDubins/rrt_dubins.py b/PathPlanning/RRTDubins/rrt_dubins.py index f938419f35..817b6d57c7 100644 --- a/PathPlanning/RRTDubins/rrt_dubins.py +++ b/PathPlanning/RRTDubins/rrt_dubins.py @@ -89,13 +89,13 @@ def planning(self, animation=True, search_until_max_iter=True): if (not search_until_max_iter) and new_node: # check reaching the goal last_index = self.search_best_goal_node() - if last_index: + if last_index is not None: return self.generate_final_course(last_index) print("reached max iteration") last_index = self.search_best_goal_node() - if last_index: + if last_index is not None: return self.generate_final_course(last_index) else: print("Cannot find path") @@ -141,7 +141,6 @@ def steer(self, from_node, to_node): new_node.x = px[-1] new_node.y = py[-1] new_node.yaw = pyaw[-1] - new_node.path_x = px new_node.path_y = py new_node.path_yaw = pyaw From fe248d737a3bccb3ceb5b31784d407df6ff853a1 Mon Sep 17 00:00:00 2001 From: huxiaoyi-ovo Date: Mon, 31 Aug 2026 23:34:55 +0800 Subject: [PATCH 2/3] Add regression test for RRT Dubins goal index zero --- tests/test_rrt_dubins.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_rrt_dubins.py b/tests/test_rrt_dubins.py index 66130484bc..980375535e 100644 --- a/tests/test_rrt_dubins.py +++ b/tests/test_rrt_dubins.py @@ -7,5 +7,21 @@ def test1(): m.main() +def test_start_already_satisfies_goal(): + planner = m.RRTDubins( + start=[0.0, 0.0, 0.0], + goal=[0.0, 0.0, 0.0], + obstacle_list=[], + rand_area=[-1.0, 1.0], + max_iter=0, + ) + + path = planner.planning(animation=False) + + assert path is not None + assert path[0] == [0.0, 0.0] + assert path[-1] == [0.0, 0.0] + + if __name__ == '__main__': conftest.run_this_test(__file__) From fa10a1cdca0bc4bd1fe18f24e302bd51a32cc4b5 Mon Sep 17 00:00:00 2001 From: huxiaoyi-ovo Date: Mon, 31 Aug 2026 23:39:13 +0800 Subject: [PATCH 3/3] Remove unrelated formatting change --- PathPlanning/RRTDubins/rrt_dubins.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PathPlanning/RRTDubins/rrt_dubins.py b/PathPlanning/RRTDubins/rrt_dubins.py index 817b6d57c7..3c257075df 100644 --- a/PathPlanning/RRTDubins/rrt_dubins.py +++ b/PathPlanning/RRTDubins/rrt_dubins.py @@ -141,6 +141,7 @@ def steer(self, from_node, to_node): new_node.x = px[-1] new_node.y = py[-1] new_node.yaw = pyaw[-1] + new_node.path_x = px new_node.path_y = py new_node.path_yaw = pyaw