来自cvxpy的quad_form()抛出了IndexError

时间:2018-06-13 15:19:31

标签: cvxpy

我正在尝试从Python Robotics github存储库运行此code。但我得到了以下错误。

model_predictive_speed_and_steer_control.py 

start!!

Traceback (most recent call last):
  File "model_predictive_speed_and_steer_control.py", line 543, in <module>
    main()
  File "model_predictive_speed_and_steer_control.py", line 520, in main
    t, x, y, yaw, v, d, a = do_simulation(cx, cy, cyaw, ck, sp, dl)
  File "model_predictive_speed_and_steer_control.py", line 403, in do_simulation
    xref, x0, dref, oa, odelta)
  File "model_predictive_speed_and_steer_control.py", line 235, in iterative_linear_mpc_control
    oa, od, ox, oy, oyaw, ov = linear_mpc_control(xref, xbar, x0, dref)
  File "model_predictive_speed_and_steer_control.py", line 262, in linear_mpc_control
    cost += cvxpy.quad_form(u[:, t], R)
  File "/usr/local/lib/python2.7/dist-packages/cvxpy/expressions/expression.py", line 315, in __getitem__
    return cvxtypes.index()(self, key)
  File "/usr/local/lib/python2.7/dist-packages/cvxpy/atoms/affine/index.py", line 48, in __init__
    self.key = ku.validate_key(key, expr.shape)
  File "/usr/local/lib/python2.7/dist-packages/cvxpy/utilities/key_utils.py", line 49, in validate_key
    raise IndexError("Too many indices for expression.")  
IndexError: Too many indices for expression.

我也更新了'cvxpy'模块。

1 个答案:

答案 0 :(得分:0)

看起来python代码适用于CVXPY的旧版本(1.0之前版本)。您可以找到更改here的内容。

我建议你要么

  • 将CVXPT降级为早期版本(0.4.x)
  • 使用this script升级1.0版本的python文件。