1

我正在尝试在 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")产生同样的问题。

4

1 回答 1

0

您可以远程解决(需要互联网连接):

m = GEKKO(remote=True)

或者设置Windows APMonitor 服务器Linux APMonitor 服务器并在该服务器(例如 IP 地址 10.0.0.10)上解决:

m = GEKKO(remote=True,server='http://10.0.0.10')

问题是 NVIDIA Jetson TX2 六核 ARMv8 64 位 CPU 没有兼容的可执行文件,否则 Python 没有选择正确的可执行文件。您可以通过将 apm_arm 可执行文件定位到 Lib/site-packages/gekko/bin 或从当前支持的本地可执行文件下载来查看 apm_arm 可执行文件是否会在您的计算机上运行:

  • Windows(32 位或 64 位):apm.exe
  • Linux(64 位):apm
  • MacOS(64 位):apm_mac
  • Linux ARM(树莓派):apm_arm

如果它没有运行或不在此列表中,那么我建议使用remote=True本地服务器或公开可用的服务器。我在 GitHub 上的 GEKKO 存储库中添加了 NVIDIA Jetson TX2 本地可执行文件作为功能请求

于 2019-09-18T04:23:17.913 回答