@@ -74,11 +74,11 @@ def planning(self, sx, sy, gx, gy):
7474 print ("Open set is empty.." )
7575 break
7676
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 ])
8078
81- current = open_set [c_id ]
79+ c_id = self .calc_grid_index (current )
80+
81+ closed_set [c_id ] = current
8282
8383 # show graph
8484 if show_animation : # pragma: no cover
@@ -97,25 +97,19 @@ def planning(self, sx, sy, gx, gy):
9797 ngoal .cost = current .cost
9898 break
9999
100- # Remove the item from the open set
101- del open_set [c_id ]
102-
103- random .shuffle (self .motion )
104-
105100 # expand_grid search grid based on motion model
106101 for i , _ in enumerate (self .motion ):
107102 node = self .Node (current .x + self .motion [i ][0 ],
108103 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 )
110105 n_id = self .calc_grid_index (node )
111106
112107 # If the node is not safe, do nothing
113108 if not self .verify_node (node ):
114109 continue
115110
116- if n_id not in closed_set :
111+ if ( n_id not in closed_set ) and ( n_id not in open_set ) :
117112 node .parent = current
118- closed_set [n_id ] = node
119113 open_set [n_id ] = node
120114
121115 rx , ry = self .calc_final_path (ngoal , closed_set )
@@ -186,8 +180,8 @@ def calc_obstacle_map(self, ox, oy):
186180 print ("ywidth:" , self .ywidth )
187181
188182 # 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 )]
191185 for ix in range (self .xwidth ):
192186 x = self .calc_grid_position (ix , self .minx )
193187 for iy in range (self .ywidth ):
0 commit comments