@@ -26,6 +26,13 @@ def __init__(self):
2626 self .yaw = []
2727 self .directions = []
2828
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+
2936
3037def plot_arrow (x , y , yaw , length = 1.0 , width = 0.5 , fc = "r" , ec = "k" ):
3138 """
@@ -214,6 +221,18 @@ def left_straight_right(x, y, phi):
214221
215222
216223def 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+ """
217236 dx = q1 [0 ] - q0 [0 ]
218237 dy = q1 [1 ] - q0 [1 ]
219238 dth = q1 [2 ] - q0 [2 ]
@@ -222,6 +241,7 @@ def generate_path(q0, q1, max_curvature):
222241 x = (c * dx + s * dy ) * max_curvature
223242 y = (- s * dx + c * dy ) * max_curvature
224243
244+ # build a list of possible paths
225245 paths = []
226246 paths = straight_curve_straight (x , y , dth , paths )
227247 paths = curve_straight_curve (x , y , dth , paths )
@@ -304,7 +324,7 @@ def generate_local_course(total_length, lengths, mode, max_curvature, step_size)
304324 ind , l , m , max_curvature , ox , oy , oyaw , px , py , pyaw , directions )
305325
306326 # remove unused data
307- while px [- 1 ] == 0.0 :
327+ while abs ( px [- 1 ]) < 1e-10 :
308328 px .pop ()
309329 py .pop ()
310330 pyaw .pop ()
@@ -321,8 +341,10 @@ def calc_paths(sx, sy, syaw, gx, gy, gyaw, maxc, step_size):
321341 q0 = [sx , sy , syaw ]
322342 q1 = [gx , gy , gyaw ]
323343
344+ # find set of feasible paths
324345 paths = generate_path (q0 , q1 , maxc )
325346 for path in paths :
347+ # interpolate the path
326348 x , y , yaw , directions = generate_local_course (
327349 path .L , path .lengths , path .ctypes , maxc , step_size * maxc )
328350
0 commit comments