From 5ceb83783e7c2e561afac87f9bb899609fe7770e Mon Sep 17 00:00:00 2001 From: Atsushi Sakai Date: Sun, 5 Jan 2020 13:53:49 +0900 Subject: [PATCH] Add node valid check to fix #271 --- PathPlanning/RRT/rrt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PathPlanning/RRT/rrt.py b/PathPlanning/RRT/rrt.py index b590d7b1..4acea0c1 100644 --- a/PathPlanning/RRT/rrt.py +++ b/PathPlanning/RRT/rrt.py @@ -140,7 +140,7 @@ class RRT: plt.clf() # for stopping simulation with the esc key. plt.gcf().canvas.mpl_connect('key_release_event', - lambda event: [exit(0) if event.key == 'escape' else None]) + lambda event: [exit(0) if event.key == 'escape' else None]) if rnd is not None: plt.plot(rnd.x, rnd.y, "^k") for node in self.node_list: @@ -175,6 +175,10 @@ class RRT: @staticmethod def check_collision(node, obstacleList): + + if node is None: + return False + for (ox, oy, size) in obstacleList: dx_list = [ox - x for x in node.path_x] dy_list = [oy - y for y in node.path_y]