Skip to content

Commit f642f21

Browse files
committed
cvxpy update to v1.0
1 parent a14d2fc commit f642f21

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

PathTracking/model_predictive_speed_and_steer_control/model_predictive_speed_and_steer_control.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,15 @@ def get_linear_model_matrix(v, phi, delta):
9494
B[2, 0] = DT
9595
B[3, 1] = DT * v / (WB * math.cos(delta) ** 2)
9696

97-
C = np.matrix(np.zeros((NX, 1)))
98-
C[0, 0] = DT * v * math.sin(phi) * phi
99-
C[1, 0] = - DT * v * math.cos(phi) * phi
100-
C[3, 0] = v * delta / (WB * math.cos(delta) ** 2)
97+
# C = np.matrix(np.zeros((NX, 1)))
98+
# C[0, 0] = DT * v * math.sin(phi) * phi
99+
# C[1, 0] = - DT * v * math.cos(phi) * phi
100+
# C[3, 0] = v * delta / (WB * math.cos(delta) ** 2)
101+
102+
C = np.zeros(NX)
103+
C[0] = DT * v * math.sin(phi) * phi
104+
C[1] = - DT * v * math.cos(phi) * phi
105+
C[3] = v * delta / (WB * math.cos(delta) ** 2)
101106

102107
return A, B, C
103108

@@ -254,8 +259,8 @@ def linear_mpc_control(xref, xbar, x0, dref):
254259
dref: reference steer angle
255260
"""
256261

257-
x = cvxpy.Variable(NX, T + 1)
258-
u = cvxpy.Variable(NU, T)
262+
x = cvxpy.Variable((NX, T + 1))
263+
u = cvxpy.Variable((NU, T))
259264

260265
cost = 0.0
261266
constraints = []
@@ -273,18 +278,18 @@ def linear_mpc_control(xref, xbar, x0, dref):
273278
if t < (T - 1):
274279
cost += cvxpy.quad_form(u[:, t + 1] - u[:, t], Rd)
275280
constraints += [cvxpy.abs(u[1, t + 1] - u[1, t])
276-
< MAX_DSTEER * DT]
281+
<= MAX_DSTEER * DT]
277282

278283
cost += cvxpy.quad_form(xref[:, T] - x[:, T], Qf)
279284

280285
constraints += [x[:, 0] == x0]
281286
constraints += [x[2, :] <= MAX_SPEED]
282287
constraints += [x[2, :] >= MIN_SPEED]
283-
constraints += [cvxpy.abs(u[0, :]) < MAX_ACCEL]
284-
constraints += [cvxpy.abs(u[1, :]) < MAX_STEER]
288+
constraints += [cvxpy.abs(u[0, :]) <= MAX_ACCEL]
289+
constraints += [cvxpy.abs(u[1, :]) <= MAX_STEER]
285290

286291
prob = cvxpy.Problem(cvxpy.Minimize(cost), constraints)
287-
prob.solve(verbose=False)
292+
prob.solve(solver=cvxpy.ECOS, verbose=False)
288293

289294
if prob.status == cvxpy.OPTIMAL or prob.status == cvxpy.OPTIMAL_INACCURATE:
290295
ox = get_nparray_from_matrix(x.value[0, :])

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Features:
9696

9797
- pandas
9898

99-
- [cvxpy 0.4.x](http://www.cvxpy.org/en/latest/)
99+
- [cvxpy](http://www.cvxpy.org/en/latest/)
100100

101101
# How to use
102102

0 commit comments

Comments
 (0)