11
11
import math
12
12
import random
13
13
import sys
14
- sys .path .append ("../ReedsSheppPath/" )
14
+ import os
15
+ sys .path .append (os .path .dirname (os .path .abspath (__file__ )) +
16
+ "/../PathPlanning/ReedsSheppPath/" )
15
17
16
18
try :
17
19
import reeds_shepp_path_planning
@@ -196,9 +198,9 @@ def find_near_nodes(self, newNode):
196
198
nnode = len (self .nodeList )
197
199
r = 50.0 * math .sqrt ((math .log (nnode ) / nnode ))
198
200
# 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
202
204
for node in self .nodeList ]
203
205
nearinds = [dlist .index (i ) for i in dlist if i <= r ** 2 ]
204
206
return nearinds
@@ -249,9 +251,9 @@ def DrawGraph(self, rnd=None):
249
251
# input()
250
252
251
253
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 ]
255
257
minind = dlist .index (min (dlist ))
256
258
257
259
return minind
@@ -285,18 +287,10 @@ def __init__(self, x, y, yaw):
285
287
self .parent = None
286
288
287
289
288
- def main ():
289
- print ("Start rrt start planning" )
290
+ def main (maxIter = 200 ):
291
+ print ("Start " + __file__ )
290
292
291
293
# ====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)]
300
294
obstacleList = [
301
295
(5 , 5 , 1 ),
302
296
(4 , 6 , 1 ),
@@ -313,7 +307,9 @@ def main():
313
307
start = [0.0 , 0.0 , np .deg2rad (0.0 )]
314
308
goal = [6.0 , 7.0 , np .deg2rad (90.0 )]
315
309
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 )
317
313
path = rrt .Planning (animation = show_animation )
318
314
319
315
# Draw final path
0 commit comments