diff --git a/InvertedPendulumCart/inverted_pendulum_mpc_control.py b/InvertedPendulumCart/inverted_pendulum_mpc_control.py index d807a688..caf0c23e 100644 --- a/InvertedPendulumCart/inverted_pendulum_mpc_control.py +++ b/InvertedPendulumCart/inverted_pendulum_mpc_control.py @@ -145,16 +145,16 @@ def plot_cart(xt, theta): by += radius * 2.0 angles = np.arange(0.0, math.pi * 2.0, math.radians(3.0)) - ox = [radius * math.cos(a) for a in angles] - oy = [radius * math.sin(a) for a in angles] + ox = np.array([radius * math.cos(a) for a in angles]) + oy = np.array([radius * math.sin(a) for a in angles]) rwx = np.copy(ox) + cart_w / 4.0 + xt rwy = np.copy(oy) + radius lwx = np.copy(ox) - cart_w / 4.0 + xt lwy = np.copy(oy) + radius - wx = np.copy(ox) + float(bx[0, -1]) - wy = np.copy(oy) + float(by[0, -1]) + wx = np.copy(ox) + bx[-1] + wy = np.copy(oy) + by[-1] plt.plot(flatten(cx), flatten(cy), "-b") plt.plot(flatten(bx), flatten(by), "-k") diff --git a/tests/test_inverted_pendulum_mpc_control.py b/tests/test_inverted_pendulum_mpc_control.py new file mode 100644 index 00000000..bf6c8576 --- /dev/null +++ b/tests/test_inverted_pendulum_mpc_control.py @@ -0,0 +1,15 @@ +from unittest import TestCase + +import sys +if 'cvxpy' in sys.modules: # pragma: no cover + sys.path.append("./InvertedPendulumCart/inverted_pendulum_mpc_control/") + + import inverted_pendulum_mpc_control as m + + print(__file__) + + class Test(TestCase): + + def test1(self): + m.show_animation = False + m.main()