@@ -104,13 +104,13 @@ def planning(self, sx, sy, gx, gy):
104
104
# Add it to the closed set
105
105
closed_set [c_id ] = current
106
106
107
+ random .shuffle (self .motion )
108
+
107
109
# expand_grid search grid based on motion model
108
- successors = [self .Node (current .x + self .motion [i ][0 ],
110
+ for i , _ in enumerate (self .motion ):
111
+ node = self .Node (current .x + self .motion [i ][0 ],
109
112
current .y + self .motion [i ][1 ],
110
- current .cost + self .motion [i ][2 ], c_id + 1 , current ) for i , _ in enumerate (self .motion )]
111
-
112
- random .shuffle (successors )
113
- for node in successors :
113
+ current .cost + self .motion [i ][2 ], c_id + 1 , current )
114
114
n_id = self .calc_grid_index (node )
115
115
116
116
# If the node is not safe, do nothing
@@ -128,7 +128,7 @@ def calc_final_path(self, ngoal, closedset):
128
128
rx , ry = [self .calc_grid_position (ngoal .x , self .minx )], [
129
129
self .calc_grid_position (ngoal .y , self .miny )]
130
130
n = closedset [ngoal .pind ]
131
- while n . parent is not None :
131
+ while n is not None :
132
132
rx .append (self .calc_grid_position (n .x , self .minx ))
133
133
ry .append (self .calc_grid_position (n .y , self .miny ))
134
134
n = n .parent
0 commit comments