@@ -74,11 +74,11 @@ def planning(self, sx, sy, gx, gy):
74
74
print ("Open set is empty.." )
75
75
break
76
76
77
- c_id = min (
78
- open_set ,
79
- key = lambda o : open_set [o ].pind )
77
+ current = open_set .pop (list (open_set .keys ())[0 ])
80
78
81
- current = open_set [c_id ]
79
+ c_id = self .calc_grid_index (current )
80
+
81
+ closed_set [c_id ] = current
82
82
83
83
# show graph
84
84
if show_animation : # pragma: no cover
@@ -97,25 +97,19 @@ def planning(self, sx, sy, gx, gy):
97
97
ngoal .cost = current .cost
98
98
break
99
99
100
- # Remove the item from the open set
101
- del open_set [c_id ]
102
-
103
- random .shuffle (self .motion )
104
-
105
100
# expand_grid search grid based on motion model
106
101
for i , _ in enumerate (self .motion ):
107
102
node = self .Node (current .x + self .motion [i ][0 ],
108
103
current .y + self .motion [i ][1 ],
109
- current .cost + self .motion [i ][2 ], c_id + 1 , None )
104
+ current .cost + self .motion [i ][2 ], c_id , None )
110
105
n_id = self .calc_grid_index (node )
111
106
112
107
# If the node is not safe, do nothing
113
108
if not self .verify_node (node ):
114
109
continue
115
110
116
- if n_id not in closed_set :
111
+ if ( n_id not in closed_set ) and ( n_id not in open_set ) :
117
112
node .parent = current
118
- closed_set [n_id ] = node
119
113
open_set [n_id ] = node
120
114
121
115
rx , ry = self .calc_final_path (ngoal , closed_set )
@@ -186,8 +180,8 @@ def calc_obstacle_map(self, ox, oy):
186
180
print ("ywidth:" , self .ywidth )
187
181
188
182
# obstacle map generation
189
- self .obmap = [[False for _ in range (self .ywidth )]
190
- for _ in range (self .xwidth )]
183
+ self .obmap = [[False for i in range (self .ywidth )]
184
+ for i in range (self .xwidth )]
191
185
for ix in range (self .xwidth ):
192
186
x = self .calc_grid_position (ix , self .minx )
193
187
for iy in range (self .ywidth ):
0 commit comments