@@ -26,6 +26,13 @@ def __init__(self):
26
26
self .yaw = []
27
27
self .directions = []
28
28
29
+ def __repr__ (self ):
30
+ s = f"_Path: L={ self .L :.2g} , "
31
+ s += f"[{ ', ' .join (['{}={:.2g}' .format (c ,l ) for c , l in zip (self .ctypes , self .lengths )])} ]"
32
+ if len (self .x ) > 0 :
33
+ s += f", { len (self .x )} points on path"
34
+ return s
35
+
29
36
30
37
def plot_arrow (x , y , yaw , length = 1.0 , width = 0.5 , fc = "r" , ec = "k" ):
31
38
"""
@@ -214,6 +221,18 @@ def left_straight_right(x, y, phi):
214
221
215
222
216
223
def generate_path (q0 , q1 , max_curvature ):
224
+ """
225
+ Return a set of feasible paths
226
+
227
+ :param q0: initial configuration
228
+ :type q0: array_like(3)
229
+ :param q1: final configuration
230
+ :type q1: array_like(3)
231
+ :param max_curvature: maximum path curvature
232
+ :type max_curvature: float
233
+ :return: set of paths
234
+ :rtype: list of _Path
235
+ """
217
236
dx = q1 [0 ] - q0 [0 ]
218
237
dy = q1 [1 ] - q0 [1 ]
219
238
dth = q1 [2 ] - q0 [2 ]
@@ -222,6 +241,7 @@ def generate_path(q0, q1, max_curvature):
222
241
x = (c * dx + s * dy ) * max_curvature
223
242
y = (- s * dx + c * dy ) * max_curvature
224
243
244
+ # build a list of possible paths
225
245
paths = []
226
246
paths = straight_curve_straight (x , y , dth , paths )
227
247
paths = curve_straight_curve (x , y , dth , paths )
@@ -304,7 +324,7 @@ def generate_local_course(total_length, lengths, mode, max_curvature, step_size)
304
324
ind , l , m , max_curvature , ox , oy , oyaw , px , py , pyaw , directions )
305
325
306
326
# remove unused data
307
- while px [- 1 ] == 0.0 :
327
+ while abs ( px [- 1 ]) < 1e-10 :
308
328
px .pop ()
309
329
py .pop ()
310
330
pyaw .pop ()
@@ -321,8 +341,10 @@ def calc_paths(sx, sy, syaw, gx, gy, gyaw, maxc, step_size):
321
341
q0 = [sx , sy , syaw ]
322
342
q1 = [gx , gy , gyaw ]
323
343
344
+ # find set of feasible paths
324
345
paths = generate_path (q0 , q1 , maxc )
325
346
for path in paths :
347
+ # interpolate the path
326
348
x , y , yaw , directions = generate_local_course (
327
349
path .L , path .lengths , path .ctypes , maxc , step_size * maxc )
328
350
0 commit comments