Skip to content

Commit 26845f7

Browse files
committed
fix linux/macos inconsistency in unit test, added some comments/doco to help during the debugging
1 parent 8a39f31 commit 26845f7

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

roboticstoolbox/mobile/ReedsSheppPlanner.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -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

3037
def 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

216223
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+
"""
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

tests/test_mobile_planner.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_reedsshepp(self):
102102
path, status = rs.query(start, goal)
103103

104104
self.assertIsInstance(path, np.ndarray)
105-
self.assertEqual(path.shape, (66,3))
105+
self.assertEqual(path.shape, (65,3))
106106
self.assertEqual(status.__class__.__name__, "ReedsSheppStatus")
107107
self.assertTrue(hasattr(status, 'segments'))
108108
self.assertTrue(hasattr(status, 'length'))
@@ -172,5 +172,6 @@ def test_reedsshepp(self):
172172
# dx.plot()
173173
# dx.plot(path=path)
174174
if __name__ == '__main__': # pragma nocover
175+
175176
unittest.main()
176-
# pytest.main(['tests/test_SerialLink.py'])
177+
# pytest.main(['tests/test_SerialLink.py'])

0 commit comments

Comments
 (0)