From 952cff6b34e6abf9c52469952c20373c8d842f40 Mon Sep 17 00:00:00 2001 From: Erwin Lejeune Date: Mon, 13 Apr 2020 14:29:12 +0200 Subject: [PATCH] fix path not connecting to start node --- .../DepthFirstSearch/depth_first_search.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PathPlanning/DepthFirstSearch/depth_first_search.py b/PathPlanning/DepthFirstSearch/depth_first_search.py index 466aa164..bb080807 100644 --- a/PathPlanning/DepthFirstSearch/depth_first_search.py +++ b/PathPlanning/DepthFirstSearch/depth_first_search.py @@ -104,13 +104,13 @@ class DepthFirstSearchPlanner: # Add it to the closed set closed_set[c_id] = current - # expand_grid search grid based on motion model - successors = [self.Node(current.x + self.motion[i][0], - current.y + self.motion[i][1], - current.cost + self.motion[i][2], c_id+1, current) for i, _ in enumerate(self.motion)] + random.shuffle(self.motion) - random.shuffle(successors) - for node in successors: + # expand_grid search grid based on motion model + for i, _ in enumerate(self.motion): + node = self.Node(current.x + self.motion[i][0], + current.y + self.motion[i][1], + current.cost + self.motion[i][2], c_id+1, current) n_id = self.calc_grid_index(node) # If the node is not safe, do nothing @@ -128,7 +128,7 @@ class DepthFirstSearchPlanner: rx, ry = [self.calc_grid_position(ngoal.x, self.minx)], [ self.calc_grid_position(ngoal.y, self.miny)] n = closedset[ngoal.pind] - while n.parent is not None: + while n is not None: rx.append(self.calc_grid_position(n.x, self.minx)) ry.append(self.calc_grid_position(n.y, self.miny)) n = n.parent