From a14d2fc9fe48842d456711502862ca8da93883c6 Mon Sep 17 00:00:00 2001 From: Atsushi Sakai Date: Sun, 15 Jul 2018 11:23:32 +0900 Subject: [PATCH] test is added --- .../Eta3SplinePath/eta3_spline_path.py | 38 +++++++++++-------- tests/test_eta3_spline_path.py | 10 +++++ 2 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 tests/test_eta3_spline_path.py diff --git a/PathPlanning/Eta3SplinePath/eta3_spline_path.py b/PathPlanning/Eta3SplinePath/eta3_spline_path.py index 25ffa70c..8dc11426 100644 --- a/PathPlanning/Eta3SplinePath/eta3_spline_path.py +++ b/PathPlanning/Eta3SplinePath/eta3_spline_path.py @@ -16,6 +16,8 @@ import matplotlib.pyplot as plt # NOTE: *_pose is a 3-array: 0 - x coord, 1 - y coord, 2 - orientation angle \theta +show_animation = True + class eta3_path(object): """ @@ -184,11 +186,13 @@ def test1(): for i, u in enumerate(ui): pos[:, i] = path.calc_path_point(u) - # plot the path - plt.plot(pos[0, :], pos[1, :]) - plt.pause(1.0) + if show_animation: + # plot the path + plt.plot(pos[0, :], pos[1, :]) + plt.pause(1.0) - plt.close("all") + if show_animation: + plt.close("all") def test2(): @@ -212,11 +216,13 @@ def test2(): for i, u in enumerate(ui): pos[:, i] = path.calc_path_point(u) - # plot the path - plt.plot(pos[0, :], pos[1, :]) - plt.pause(1.0) + if show_animation: + # plot the path + plt.plot(pos[0, :], pos[1, :]) + plt.pause(1.0) - plt.close("all") + if show_animation: + plt.close("all") def test3(): @@ -273,14 +279,16 @@ def test3(): pos[:, i] = path.calc_path_point(u) # plot the path - plt.figure('Path from Reference') - plt.plot(pos[0, :], pos[1, :]) - plt.xlabel('x') - plt.ylabel('y') - plt.title('Path') - plt.pause(1.0) - plt.show() + if show_animation: + plt.figure('Path from Reference') + plt.plot(pos[0, :], pos[1, :]) + plt.xlabel('x') + plt.ylabel('y') + plt.title('Path') + plt.pause(1.0) + + plt.show() def main(): diff --git a/tests/test_eta3_spline_path.py b/tests/test_eta3_spline_path.py new file mode 100644 index 00000000..33a4223d --- /dev/null +++ b/tests/test_eta3_spline_path.py @@ -0,0 +1,10 @@ + +from unittest import TestCase +from PathPlanning.Eta3SplinePath import eta3_spline_path as m + + +class Test(TestCase): + + def test1(self): + m.show_animation = False + m.main()