Skip to content

Commit a14d2fc

Browse files
committed
test is added
1 parent 1c10aaa commit a14d2fc

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

PathPlanning/Eta3SplinePath/eta3_spline_path.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
# NOTE: *_pose is a 3-array: 0 - x coord, 1 - y coord, 2 - orientation angle \theta
1818

19+
show_animation = True
20+
1921

2022
class eta3_path(object):
2123
"""
@@ -184,11 +186,13 @@ def test1():
184186
for i, u in enumerate(ui):
185187
pos[:, i] = path.calc_path_point(u)
186188

187-
# plot the path
188-
plt.plot(pos[0, :], pos[1, :])
189-
plt.pause(1.0)
189+
if show_animation:
190+
# plot the path
191+
plt.plot(pos[0, :], pos[1, :])
192+
plt.pause(1.0)
190193

191-
plt.close("all")
194+
if show_animation:
195+
plt.close("all")
192196

193197

194198
def test2():
@@ -212,11 +216,13 @@ def test2():
212216
for i, u in enumerate(ui):
213217
pos[:, i] = path.calc_path_point(u)
214218

215-
# plot the path
216-
plt.plot(pos[0, :], pos[1, :])
217-
plt.pause(1.0)
219+
if show_animation:
220+
# plot the path
221+
plt.plot(pos[0, :], pos[1, :])
222+
plt.pause(1.0)
218223

219-
plt.close("all")
224+
if show_animation:
225+
plt.close("all")
220226

221227

222228
def test3():
@@ -273,14 +279,16 @@ def test3():
273279
pos[:, i] = path.calc_path_point(u)
274280

275281
# plot the path
276-
plt.figure('Path from Reference')
277-
plt.plot(pos[0, :], pos[1, :])
278-
plt.xlabel('x')
279-
plt.ylabel('y')
280-
plt.title('Path')
281-
plt.pause(1.0)
282-
283-
plt.show()
282+
283+
if show_animation:
284+
plt.figure('Path from Reference')
285+
plt.plot(pos[0, :], pos[1, :])
286+
plt.xlabel('x')
287+
plt.ylabel('y')
288+
plt.title('Path')
289+
plt.pause(1.0)
290+
291+
plt.show()
284292

285293

286294
def main():

tests/test_eta3_spline_path.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
from unittest import TestCase
3+
from PathPlanning.Eta3SplinePath import eta3_spline_path as m
4+
5+
6+
class Test(TestCase):
7+
8+
def test1(self):
9+
m.show_animation = False
10+
m.main()

0 commit comments

Comments
 (0)