Skip to content

Commit 71daa78

Browse files
committed
easier path retrieving and shuffle children node
1 parent 68c4c78 commit 71daa78

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

PathPlanning/BreadthFirstSearch/breadth_first_search.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def planning(self, sx, sy, gx, gy):
100100
# Remove the item from the open set
101101
del open_set[c_id]
102102

103+
random.shuffle(self.motion)
104+
103105
# expand_grid search grid based on motion model
104106
for i, _ in enumerate(self.motion):
105107
node = self.Node(current.x + self.motion[i][0],
@@ -123,14 +125,11 @@ def calc_final_path(self, ngoal, closedset):
123125
rx, ry = [self.calc_grid_position(ngoal.x, self.minx)], [
124126
self.calc_grid_position(ngoal.y, self.miny)]
125127
n = closedset[ngoal.pind]
126-
while n.parent is not None:
128+
while n is not None:
127129
rx.append(self.calc_grid_position(n.x, self.minx))
128130
ry.append(self.calc_grid_position(n.y, self.miny))
129131
n = n.parent
130132

131-
rx.append(self.calc_grid_position(n.x, self.minx))
132-
ry.append(self.calc_grid_position(n.y, self.miny))
133-
134133
return rx, ry
135134

136135
def calc_grid_position(self, index, minp):

0 commit comments

Comments
 (0)