@@ -84,6 +84,7 @@ def informed_rrt_star_search(self, animation=True):
8484 self .rewire (newNode , nearInds )
8585
8686 if self .is_near_goal (newNode ):
87+ if self .check_segment_collision (newNode .x , newNode .y , self .goal .x , self .goal .y ):
8788 solutionSet .add (newNode )
8889 lastIndex = len (self .node_list ) - 1
8990 tempPath = self .get_final_course (lastIndex )
@@ -240,19 +241,23 @@ def distance_squared_point_to_segment(v, w, p):
240241 projection = v + t * (w - v ) # Projection falls on the segment
241242 return (p - projection ).dot (p - projection )
242243
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 ):
247245 for (ox , oy , size ) in self .obstacle_list :
248246 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 ]),
251249 np .array ([ox , oy ]))
252- if dd <= 1.1 * size ** 2 :
250+ if dd <= size ** 2 :
253251 return False # collision
254252 return True
255253
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+
256261 def get_final_course (self , lastIndex ):
257262 path = [[self .goal .x , self .goal .y ]]
258263 while self .node_list [lastIndex ].parent is not None :
0 commit comments