@@ -192,43 +192,42 @@ def setup_planning(self):
192192        return  etheta , cMin , xCenter , C , cBest 
193193
194194    def  setup_sample (self , iterations , foundGoal , cMin , xCenter , C , cBest ):
195-         print ("Batch: " , iterations )
196-         # Using informed rrt star way of computing the samples 
197-         self .r  =  2.0 
198-         if  iterations  !=  0 :
199-             if  foundGoal :
200-                 # a better way to do this would be to make number of samples 
201-                 # a function of cMin 
202-                 m  =  200 
203-                 self .samples  =  dict ()
204-                 self .samples [self .goalId ] =  self .goal 
205-             else :
206-                 m  =  100 
207-             cBest  =  self .g_scores [self .goalId ]
208-             self .samples .update (self .informedSample (
209-                 m , cBest , cMin , xCenter , C ))
210-             return  cBest 
211195
196+         if  len (self .vertex_queue ) ==  0  and  len (self .edge_queue ) ==  0 :
197+             print ("Batch: " , iterations )
198+             # Using informed rrt star way of computing the samples 
199+             self .r  =  2.0 
200+             if  iterations  !=  0 :
201+                 if  foundGoal :
202+                     # a better way to do this would be to make number of samples 
203+                     # a function of cMin 
204+                     m  =  200 
205+                     self .samples  =  dict ()
206+                     self .samples [self .goalId ] =  self .goal 
207+                 else :
208+                     m  =  100 
209+                 cBest  =  self .g_scores [self .goalId ]
210+                 self .samples .update (self .informedSample (
211+                     m , cBest , cMin , xCenter , C ))
212+ 
213+             # make the old vertices the new vertices 
214+             self .old_vertices  +=  self .tree .vertices .keys ()
215+             # add the vertices to the vertex queue 
216+             for  nid  in  self .tree .vertices .keys ():
217+                 if  nid  not  in self .vertex_queue :
218+                     self .vertex_queue .append (nid )
212219        return  cBest 
213220
214221    def  plan (self , animation = True ):
215222
216223        etheta , cMin , xCenter , C , cBest  =  self .setup_planning ()
217224        iterations  =  0 
218-         plan  =  []
219225
220226        foundGoal  =  False 
221227        # run until done 
222228        while  (iterations  <  self .maxIter ):
223-             if  len (self .vertex_queue ) ==  0  and  len (self .edge_queue ) ==  0 :
224-                 cBest  =  self .setup_sample (iterations ,
225-                                           foundGoal , cMin , xCenter , C , cBest )
226-                 # make the old vertices the new vertices 
227-                 self .old_vertices  +=  self .tree .vertices .keys ()
228-                 # add the vertices to the vertex queue 
229-                 for  nid  in  self .tree .vertices .keys ():
230-                     if  nid  not  in self .vertex_queue :
231-                         self .vertex_queue .append (nid )
229+             cBest  =  self .setup_sample (iterations ,
230+                                       foundGoal , cMin , xCenter , C , cBest )
232231            # expand the best vertices until an edge is better than the vertex 
233232            # this is done because the vertex cost represents the lower bound 
234233            # on the edge cost 
@@ -304,6 +303,10 @@ def plan(self, animation=True):
304303            iterations  +=  1 
305304
306305        print ("Finding the path" )
306+         return  self .find_final_path ()
307+ 
308+     def  find_final_path (self ):
309+         plan  =  []
307310        plan .append (self .goal )
308311        currId  =  self .goalId 
309312        while  (currId  !=  self .startId ):
@@ -312,6 +315,7 @@ def plan(self, animation=True):
312315
313316        plan .append (self .start )
314317        plan  =  plan [::- 1 ]  # reverse the plan 
318+ 
315319        return  plan 
316320
317321    def  remove_queue (self , lastEdge , bestEdge ):
0 commit comments