@@ -84,6 +84,7 @@ def informed_rrt_star_search(self, animation=True):
84
84
self .rewire (newNode , nearInds )
85
85
86
86
if self .is_near_goal (newNode ):
87
+ if self .check_segment_collision (newNode .x , newNode .y , self .goal .x , self .goal .y ):
87
88
solutionSet .add (newNode )
88
89
lastIndex = len (self .node_list ) - 1
89
90
tempPath = self .get_final_course (lastIndex )
@@ -240,19 +241,23 @@ def distance_squared_point_to_segment(v, w, p):
240
241
projection = v + t * (w - v ) # Projection falls on the segment
241
242
return (p - projection ).dot (p - projection )
242
243
243
- def check_collision (self , nearNode , theta , d ):
244
- tmpNode = copy .deepcopy (nearNode )
245
- endx = tmpNode .x + math .cos (theta )* d
246
- endy = tmpNode .y + math .sin (theta )* d
244
+ def check_segment_collision (self , x1 , y1 , x2 , y2 ):
247
245
for (ox , oy , size ) in self .obstacle_list :
248
246
dd = self .distance_squared_point_to_segment (
249
- np .array ([tmpNode . x , tmpNode . y ]),
250
- np .array ([endx , endy ]),
247
+ np .array ([x1 , y1 ]),
248
+ np .array ([x2 , y2 ]),
251
249
np .array ([ox , oy ]))
252
- if dd <= 1.1 * size ** 2 :
250
+ if dd <= size ** 2 :
253
251
return False # collision
254
252
return True
255
253
254
+
255
+ def check_collision (self , nearNode , theta , d ):
256
+ tmpNode = copy .deepcopy (nearNode )
257
+ endx = tmpNode .x + math .cos (theta )* d
258
+ endy = tmpNode .y + math .sin (theta )* d
259
+ return self .check_segment_collision (tmpNode .x , tmpNode .y , endx , endy )
260
+
256
261
def get_final_course (self , lastIndex ):
257
262
path = [[self .goal .x , self .goal .y ]]
258
263
while self .node_list [lastIndex ].parent is not None :
0 commit comments