2121
2222
2323target_speed = 10.0 / 3.6
24- STEP_SIZE = 0.5
24+ STEP_SIZE = 0.1
2525
2626
2727class RRT ():
@@ -52,6 +52,8 @@ def try_goal_path(self):
5252 goal = Node (self .end .x , self .end .y , self .end .yaw )
5353
5454 newNode = self .steer (goal , len (self .nodeList ) - 1 )
55+ if newNode is None :
56+ return
5557
5658 if self .CollisionCheck (newNode , self .obstacleList ):
5759 # print("goal path is OK")
@@ -74,10 +76,14 @@ def Planning(self, animation=True):
7476
7577 newNode = self .steer (rnd , nind )
7678 # print(newNode.cost)
79+ if newNode is None :
80+ continue
7781
7882 if self .CollisionCheck (newNode , self .obstacleList ):
7983 nearinds = self .find_near_nodes (newNode )
8084 newNode = self .choose_parent (newNode , nearinds )
85+ if newNode is None :
86+ continue
8187
8288 self .nodeList .append (newNode )
8389 self .rewire (newNode , nearinds )
@@ -97,6 +103,8 @@ def Planning(self, animation=True):
97103
98104 def search_best_feasible_path (self , path_indexs ):
99105
106+ print ("Start search feasible path" )
107+
100108 best_time = float ("inf" )
101109
102110 # pure pursuit tracking
@@ -189,6 +197,9 @@ def choose_parent(self, newNode, nearinds):
189197 dlist = []
190198 for i in nearinds :
191199 tNode = self .steer (newNode , i )
200+ if tNode is None :
201+ continue
202+
192203 if self .CollisionCheck (tNode , self .obstacleList ):
193204 dlist .append (tNode .cost )
194205 else :
@@ -202,6 +213,8 @@ def choose_parent(self, newNode, nearinds):
202213 return newNode
203214
204215 newNode = self .steer (newNode , minind )
216+ if newNode is None :
217+ return None
205218
206219 return newNode
207220
@@ -223,6 +236,9 @@ def steer(self, rnd, nind):
223236 nearestNode .x , nearestNode .y , nearestNode .yaw ,
224237 rnd .x , rnd .y , rnd .yaw , unicycle_model .curvature_max , STEP_SIZE )
225238
239+ if px is None :
240+ return None
241+
226242 newNode = copy .deepcopy (nearestNode )
227243 newNode .x = px [- 1 ]
228244 newNode .y = py [- 1 ]
@@ -231,7 +247,7 @@ def steer(self, rnd, nind):
231247 newNode .path_x = px
232248 newNode .path_y = py
233249 newNode .path_yaw = pyaw
234- newNode .cost += sum (clen )
250+ newNode .cost += sum ([ abs ( c ) for c in clen ] )
235251 newNode .parent = nind
236252
237253 return newNode
@@ -308,6 +324,9 @@ def rewire(self, newNode, nearinds):
308324 nearNode = self .nodeList [i ]
309325 tNode = self .steer (nearNode , nnode - 1 )
310326
327+ if tNode is None :
328+ continue
329+
311330 obstacleOK = self .CollisionCheck (tNode , self .obstacleList )
312331 imporveCost = nearNode .cost > tNode .cost
313332
0 commit comments