Skip to content

Commit

Permalink
inverted pendulum mpc control is added
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiSakai committed Feb 7, 2020
1 parent 03e8969 commit bd5269b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions InvertedPendulumCart/inverted_pendulum_mpc_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 15 additions & 0 deletions tests/test_inverted_pendulum_mpc_control.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit bd5269b

Please sign in to comment.