- 1. 准备工作
- 1.1 配置环境:
- 1.2 调试代码
- 2.代码解析:
- 2.1 setup.py
- 2.1 ACNet.py
- 3.报错合集:
论文名称:PRIMAL: Pathfinding via Reinforcement and Imitation Multi-Agent Learning
论文地址:https://arxiv.org/abs/1809.03531
代码地址:https://github.com/gsartoretti/PRIMAL
相关链接:无人驾驶动态避障策略调研 | 机器人动态避障策略 | 行人轨迹预测 | 机器人导航,三篇强化学习用于多智能体路径规划的论文
- 先新建一个环境:
conda create --name PRIMAL python=3.6 - 新建一个requirements.txt文件,把要安装的包都放进去,再运行 pip install -r requirements安装包:
Cython==0.28.4 gym==0.9.4 Tensorflow==1.13.0 Numpy==1.16.0 matplotlib imageio tk networkx
注:源代码中是python3.4 + tf 1.3 + numpy 1.13,但是因为我的pycharm版本较高,不能兼容低版本python,因此我配的是python 3.6;py3.6无法兼容1.3版本的tensorflow,因此我又换成了1.13版本的tf。
3. 如果安装失败,也可以一个一个安装(我采用的方法)
注:直接pip或者conda安装不了gym时,可以尝试以下两种方法:conda install -c conda-forge gym=0.9.4 或者 pip install gym -i https://pypi.tuna.tsinghua.edu.cn/simple
安装tensorflow出问题时,可以执行以下两句 conda install cudatoolkit=10.0 conda install tensorflow==1.13.1
4. 安装完成后,可以使用conda list命令检查是否都安装上了:
-
安装readme文件中的步骤一步一步来:
① 命令行窗口进入cd od_mstar3文件夹,python setup.py build_ext --inplace;报错了error: Unable to find vcvarsall.bat
网上搜了一下,发现是需要安装Visual Studio,并且在安装时需要勾选 C++组件。如果安装时没有勾选,应当在工具栏中重新安装,之后重启就有vcvarsall模块了。参考文章:已安装vs2017 仍然报错Unable to find vcvarsall.bat -
然而,装了之后还是报错 o(╥﹏╥)o,参照:关于error: Unable to find vcvarsall.bat,我将msvc9compiler.py文件中的find_vcvarsall函数return改成 return r"C:Program Files (x86)Microsoft Visual Studio2017CommunityVCAuxiliaryBuildvcvarsall.bat"
其他参考文章:Unable to find vcvarsall.bat? -
改好vcvarsall.bat的bug后,又有了一个新bug: fatal error C1083: 无法打开包括文件: “boost/graph/graph_traits.hpp”: No such file or directory。 网上查了一下,这是C++里的BGL库,需要自己下载安装。寻路时会用到它。Boost C++ Libraries 编译安装,oost下载安装编译配置使用指南(含Windows和Linux)
① 在官网中下载了 boost_1_53_.zip,解压运行bootstrap.bat的时候报错了 boost 编译时出错处理:Failed to build Boost.Build engine。查阅了很多资料,还是没解决,于是决定下载最新版本的boost工具包。
安装时再次报错,fatal error C1083: 无法打开包括文件: “corecrt.h,Windows 原生 cmd 窗口下编译 C++(cl命令)出现的问题及解决方法② 朋友安装的Visual Studio 2022,能够顺利装上boost,因此我也重新安装了vs2022。啊!终于可以啦!!
boost工具安装教程,官方安装教程。
setup.py是调用cpython,用 Python 的语法混合编写 Python 和 C/C++ 代码,提升 Python 速度
调用 C/C++ 代码 教程,Cython 基本用法 。
本代码中是运行cpython_od_matar.pyx这个文件,其中的find_path(world, init_pos, goals, inflation, time_limit)函数是使用ODrM*算法进行探索。
输入输出:
world - matrix specifying obstacles, 1 for obstacle, 0 for free
init_pos - [[x, y], ...] specifying start position for each robot
goals - [[x, y], ...] specifying goal position for each robot
inflation - inflation factor for heuristic
time_limit - time until failure in seconds
returns:
[[[x1, y1], ...], [[x2, y2], ...], ...] path in the joint
configuration space
2.1 ACNet.py
ACNet.py中的_build_net()函数对应着论文中的网络结构:
- 报错 Connection to Python debugger failed: Socket operation on nonsocket: configureBlocking
- ImportError: DLL load failed: 找不到指定的模块。 解决办法:重新安装numpy和tensorflow



