Skip to content

Commit bd5269b

Browse files
committed
inverted pendulum mpc control is added
1 parent 03e8969 commit bd5269b

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

InvertedPendulumCart/inverted_pendulum_mpc_control.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,16 @@ def plot_cart(xt, theta):
145145
by += radius * 2.0
146146

147147
angles = np.arange(0.0, math.pi * 2.0, math.radians(3.0))
148-
ox = [radius * math.cos(a) for a in angles]
149-
oy = [radius * math.sin(a) for a in angles]
148+
ox = np.array([radius * math.cos(a) for a in angles])
149+
oy = np.array([radius * math.sin(a) for a in angles])
150150

151151
rwx = np.copy(ox) + cart_w / 4.0 + xt
152152
rwy = np.copy(oy) + radius
153153
lwx = np.copy(ox) - cart_w / 4.0 + xt
154154
lwy = np.copy(oy) + radius
155155

156-
wx = np.copy(ox) + float(bx[0, -1])
157-
wy = np.copy(oy) + float(by[0, -1])
156+
wx = np.copy(ox) + bx[-1]
157+
wy = np.copy(oy) + by[-1]
158158

159159
plt.plot(flatten(cx), flatten(cy), "-b")
160160
plt.plot(flatten(bx), flatten(by), "-k")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from unittest import TestCase
2+
3+
import sys
4+
if 'cvxpy' in sys.modules: # pragma: no cover
5+
sys.path.append("./InvertedPendulumCart/inverted_pendulum_mpc_control/")
6+
7+
import inverted_pendulum_mpc_control as m
8+
9+
print(__file__)
10+
11+
class Test(TestCase):
12+
13+
def test1(self):
14+
m.show_animation = False
15+
m.main()

0 commit comments

Comments
 (0)