Skip to content

Commit 62508ba

Browse files
committed
some animation is added
1 parent 57a6490 commit 62508ba

File tree

2 files changed

+69
-5
lines changed

2 files changed

+69
-5
lines changed

PathPlanning/Eta3SplinePath/eta3_spline_path.py

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
\eta^3 polynomials planner
44
55
author: Joe Dinius, Ph.D (https://jwdinius.github.io)
6+
Atsushi Sakai (@Atsushi_twi)
67
78
Ref:
89
@@ -162,10 +163,63 @@ def calc_point(self, u):
162163
return self.coeffs.dot(np.array([1, u, u**2, u**3, u**4, u**5, u**6, u**7]))
163164

164165

165-
def main():
166-
"""
167-
recreate path from reference (see Table 1)
168-
"""
166+
def test1():
167+
168+
for i in range(10):
169+
path_segments = []
170+
# segment 1: lane-change curve
171+
start_pose = [0, 0, 0]
172+
end_pose = [4, 3.0, 0]
173+
# NOTE: The ordering on kappa is [kappa_A, kappad_A, kappa_B, kappad_B], with kappad_* being the curvature derivative
174+
kappa = [0, 0, 0, 0]
175+
eta = [i, i, 0, 0, 0, 0]
176+
path_segments.append(eta3_path_segment(
177+
start_pose=start_pose, end_pose=end_pose, eta=eta, kappa=kappa))
178+
179+
path = eta3_path(path_segments)
180+
181+
# interpolate at several points along the path
182+
ui = np.linspace(0, len(path_segments), 1001)
183+
pos = np.empty((2, ui.size))
184+
for i, u in enumerate(ui):
185+
pos[:, i] = path.calc_path_point(u)
186+
187+
# plot the path
188+
plt.plot(pos[0, :], pos[1, :])
189+
plt.pause(1.0)
190+
191+
plt.close("all")
192+
193+
194+
def test2():
195+
196+
for i in range(10):
197+
path_segments = []
198+
# segment 1: lane-change curve
199+
start_pose = [0, 0, 0]
200+
end_pose = [4, 3.0, 0]
201+
# NOTE: The ordering on kappa is [kappa_A, kappad_A, kappa_B, kappad_B], with kappad_* being the curvature derivative
202+
kappa = [0, 0, 0, 0]
203+
eta = [0, 0, (i - 5) * 20, (5 - i) * 20, 0, 0]
204+
path_segments.append(eta3_path_segment(
205+
start_pose=start_pose, end_pose=end_pose, eta=eta, kappa=kappa))
206+
207+
path = eta3_path(path_segments)
208+
209+
# interpolate at several points along the path
210+
ui = np.linspace(0, len(path_segments), 1001)
211+
pos = np.empty((2, ui.size))
212+
for i, u in enumerate(ui):
213+
pos[:, i] = path.calc_path_point(u)
214+
215+
# plot the path
216+
plt.plot(pos[0, :], pos[1, :])
217+
plt.pause(1.0)
218+
219+
plt.close("all")
220+
221+
222+
def test3():
169223
path_segments = []
170224

171225
# segment 1: lane-change curve
@@ -224,8 +278,18 @@ def main():
224278
plt.xlabel('x')
225279
plt.ylabel('y')
226280
plt.title('Path')
281+
227282
plt.show()
228283

229284

285+
def main():
286+
"""
287+
recreate path from reference (see Table 1)
288+
"""
289+
test1()
290+
test2()
291+
test3()
292+
293+
230294
if __name__ == '__main__':
231295
main()

0 commit comments

Comments
 (0)