1111import math
1212import random
1313import sys
14- sys .path .append ("../ReedsSheppPath/" )
14+ import os
15+ sys .path .append (os .path .dirname (os .path .abspath (__file__ )) +
16+ "/../PathPlanning/ReedsSheppPath/" )
1517
1618try :
1719 import reeds_shepp_path_planning
@@ -196,9 +198,9 @@ def find_near_nodes(self, newNode):
196198 nnode = len (self .nodeList )
197199 r = 50.0 * math .sqrt ((math .log (nnode ) / nnode ))
198200 # r = self.expandDis * 5.0
199- dlist = [(node .x - newNode .x ) ** 2
200- + (node .y - newNode .y ) ** 2
201- + (node .yaw - newNode .yaw ) ** 2
201+ dlist = [(node .x - newNode .x ) ** 2 +
202+ (node .y - newNode .y ) ** 2 +
203+ (node .yaw - newNode .yaw ) ** 2
202204 for node in self .nodeList ]
203205 nearinds = [dlist .index (i ) for i in dlist if i <= r ** 2 ]
204206 return nearinds
@@ -249,9 +251,9 @@ def DrawGraph(self, rnd=None):
249251 # input()
250252
251253 def GetNearestListIndex (self , nodeList , rnd ):
252- dlist = [(node .x - rnd .x ) ** 2
253- + (node .y - rnd .y ) ** 2
254- + (node .yaw - rnd .yaw ) ** 2 for node in nodeList ]
254+ dlist = [(node .x - rnd .x ) ** 2 +
255+ (node .y - rnd .y ) ** 2 +
256+ (node .yaw - rnd .yaw ) ** 2 for node in nodeList ]
255257 minind = dlist .index (min (dlist ))
256258
257259 return minind
@@ -285,18 +287,10 @@ def __init__(self, x, y, yaw):
285287 self .parent = None
286288
287289
288- def main ():
289- print ("Start rrt start planning" )
290+ def main (maxIter = 200 ):
291+ print ("Start " + __file__ )
290292
291293 # ====Search Path with RRT====
292- # obstacleList = [
293- # (5, 5, 1),
294- # (3, 6, 2),
295- # (3, 8, 2),
296- # (3, 10, 2),
297- # (7, 5, 2),
298- # (9, 5, 2)
299- # ] # [x,y,size(radius)]
300294 obstacleList = [
301295 (5 , 5 , 1 ),
302296 (4 , 6 , 1 ),
@@ -313,7 +307,9 @@ def main():
313307 start = [0.0 , 0.0 , np .deg2rad (0.0 )]
314308 goal = [6.0 , 7.0 , np .deg2rad (90.0 )]
315309
316- rrt = RRT (start , goal , randArea = [- 2.0 , 15.0 ], obstacleList = obstacleList )
310+ rrt = RRT (start , goal , randArea = [- 2.0 , 15.0 ],
311+ obstacleList = obstacleList ,
312+ maxIter = maxIter )
317313 path = rrt .Planning (animation = show_animation )
318314
319315 # Draw final path
0 commit comments