@@ -33,7 +33,7 @@ def __init__(self, x, y):
3333 self .parent = None
3434
3535 def __init__ (self , start , goal , obstacle_list , rand_area ,
36- expand_dis = 3.0 , path_resolution = 1.0 , goal_sample_rate = 5 , max_iter = 500 ):
36+ expand_dis = 3.0 , path_resolution = 0.5 , goal_sample_rate = 5 , max_iter = 500 ):
3737 """
3838 Setting Parameter
3939
@@ -76,8 +76,9 @@ def planning(self, animation=True):
7676 self .draw_graph (rnd_node )
7777
7878 if self .calc_dist_to_goal (self .node_list [- 1 ].x , self .node_list [- 1 ].y ) <= self .expand_dis :
79- print ("Goal!!" )
80- return self .generate_final_course (len (self .node_list ) - 1 )
79+ final_node = self .steer (self .node_list [- 1 ], self .end , self .expand_dis )
80+ if self .check_collision (final_node , self .obstacle_list ):
81+ return self .generate_final_course (len (self .node_list ) - 1 )
8182
8283 if animation and i % 5 :
8384 self .draw_graph (rnd_node )
@@ -141,7 +142,7 @@ def draw_graph(self, rnd=None):
141142 plt .plot (rnd .x , rnd .y , "^k" )
142143 for node in self .node_list :
143144 if node .parent :
144- plt .plot (node .path_x , node .path_y , "-xg " )
145+ plt .plot (node .path_x , node .path_y , "-g " )
145146
146147 for (ox , oy , size ) in self .obstacle_list :
147148 self .plot_circle (ox , oy , size )
@@ -200,7 +201,8 @@ def main(gx=6.0, gy=10.0):
200201 (3 , 8 , 2 ),
201202 (3 , 10 , 2 ),
202203 (7 , 5 , 2 ),
203- (9 , 5 , 2 )
204+ (9 , 5 , 2 ),
205+ (8 , 10 , 1 )
204206 ] # [x, y, radius]
205207 # Set Initial parameters
206208 rrt = RRT (start = [0 , 0 ],
0 commit comments