Skip to content

Commit f2c651f

Browse files
committed
Changes following review
1 parent 0159629 commit f2c651f

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

PathPlanning/BreadthFirstSearch/breadth_first_search.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
show_animation = True
1818

1919

20-
class BFSPlanner:
20+
class BreadthFirstSearchPlanner:
2121

2222
def __init__(self, ox, oy, reso, rr):
2323
"""
@@ -48,7 +48,7 @@ def __str__(self):
4848

4949
def planning(self, sx, sy, gx, gy):
5050
"""
51-
Breadth First search
51+
Breadth First search based planning
5252
5353
input:
5454
sx: start x position [m]
@@ -101,12 +101,10 @@ def planning(self, sx, sy, gx, gy):
101101
del open_set[c_id]
102102

103103
# expand_grid search grid based on motion model
104-
successors = [self.Node(current.x + self.motion[i][0],
104+
for i, _ in enumerate(self.motion):
105+
node = self.Node(current.x + self.motion[i][0],
105106
current.y + self.motion[i][1],
106-
current.cost + self.motion[i][2], c_id+1, current) for i, _ in enumerate(self.motion)]
107-
108-
random.shuffle(successors)
109-
for node in successors:
107+
current.cost + self.motion[i][2], c_id+1, current)
110108
n_id = self.calc_grid_index(node)
111109

112110
# If the node is not safe, do nothing
@@ -132,12 +130,6 @@ def calc_final_path(self, ngoal, closedset):
132130

133131
return rx, ry
134132

135-
@staticmethod
136-
def calc_heuristic(n1, n2):
137-
w = 1.0 # weight of heuristic
138-
d = w * math.hypot(n1.x - n2.x, n1.y - n2.y)
139-
return d
140-
141133
def calc_grid_position(self, index, minp):
142134
"""
143135
calc grid position
@@ -257,7 +249,7 @@ def main():
257249
plt.grid(True)
258250
plt.axis("equal")
259251

260-
bfs = BFSPlanner(ox, oy, grid_size, robot_radius)
252+
bfs = BreadthFirstSearchPlanner(ox, oy, grid_size, robot_radius)
261253
rx, ry = bfs.planning(sx, sy, gx, gy)
262254

263255
if show_animation: # pragma: no cover

0 commit comments

Comments
 (0)