Skip to content

Commit d53ec93

Browse files
authored
Fix the problem that the length of candidate path is not correctly compared. Optimal path may be discarded. (AtsushiSakai#487)
1 parent d391cdb commit d53ec93

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

PathPlanning/ReedsSheppPath/reeds_shepp_path_planning.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def plot_arrow(x, y, yaw, length=1.0, width=0.5, fc="r", ec="k"):
4040

4141

4242
def mod2pi(x):
43-
v = np.mod(x, 2.0 * math.pi)
43+
# Be consistent with fmod in cplusplus here.
44+
v = np.mod(x, np.copysign(2.0 * math.pi, x))
4445
if v < -math.pi:
4546
v += 2.0 * math.pi
4647
else:
@@ -76,7 +77,7 @@ def set_path(paths, lengths, ctypes):
7677
for tpath in paths:
7778
typeissame = (tpath.ctypes == path.ctypes)
7879
if typeissame:
79-
if sum(tpath.lengths) - sum(path.lengths) <= 0.01:
80+
if sum(np.abs(tpath.lengths)) - sum(np.abs(path.lengths)) <= 0.01:
8081
return paths # not insert path
8182

8283
path.L = sum([abs(i) for i in lengths])

0 commit comments

Comments
 (0)