我正在尝试在 python 2 或 3 中运行 gekko。我只是按照更改参数的教程进行操作,然后使用 scipy.integrate 来模拟我的 MPC。它适用于我的一台计算机,但不适用于我的 NVIDIA Jetson TX2。运行 m.solve(disp=False) 时出现“Exec 格式错误”。
两台电脑都有python2和python3。由于我也在运行 ROS,所以我想使用 python2 来运行脚本。最初我认为可能是使用 python2 解释导致问题,所以我编写了另一个脚本,利用子进程将我的 mpc 和模拟器解释为 python3。但是,这个问题仍然存在。问题似乎在 gekko 包中。我确信这是一个环境错误,因为该脚本在我的个人计算机上运行良好。目前我正在运行 Ubuntu 16.04。
def example_MPC(t_init, x, u_init):
m = GEKKO(remote=False)
dt = 0.5
m.time = np.linspace(t_init,10+t_init,21)
#...
m.solve(disp=False) # <-- The error appears on this line
#...
return p.value[1]
这是来自终端的错误消息:
Traceback (most recent call last):
File "ode_solver.py", line 53, in <module>
simulation()
File "ode_solver.py", line 34, in simulation
u[i] = example_MPC(t[i-1], v0, u[i-1])
File ".../src/MPC_test.py", line 34, in example_MPC
m.solve(disp=False)
File "/home/nvidia/.local/lib/python3.5/site-packages/gekko/gekko.py", line 1880, in solve
env = {"PATH" : self._path }, universal_newlines=True)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
编辑:
我找到了 apm 文件夹位置。当我尝试运行apm时
./apm
该命令给了我这个:
-bash: ./apm: cannot execute binary file: Exec format error
我假设这意味着在我的 TX2 上,apm 运行不正常。
如果我设置m = GEKKO(remote=True)
,它的工作原理。但是,MPC 不能实时运行,这对我来说绝对是个问题。
我现在正试图在本地桌面上解决这个问题。服务器参数只是本地IP地址吗?我设置:
m = GEKKO(remote=True, server="192.168.1.136")
它返回:
Traceback (most recent call last):
File ".../src/ode_solver.py", line 53, in <module>
simulation()
File ".../src/ode_solver.py", line 34, in simulation
u[i] = example_MPC(t[i-1], v0, u[i-1])
File ".../src/MPC_test.py", line 34, in example_MPC
m.solve(disp=False)
File ".../.local/lib/python2.7/site-packages/gekko/gekko.py", line 1992, in solve
raise ImportError('Results files not found. APM did not find a solution or the server is unreachable.')
ImportError: Results files not found. APM did not find a solution or the server is unreachable.
设置m = GEKKO(remote=True, server="http://192.168.1.136")
产生同样的问题。