inverted pendulum mpc control is added

This commit is contained in:
Atsushi Sakai
2020-02-07 20:45:15 +09:00
parent 03e8969e9d
commit bd5269b3d2
2 changed files with 19 additions and 4 deletions

View File

@@ -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")

View File

@@ -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()