当前位置:网站首页>PRIMAL: Pathfinding via Reinforcement and Imitation Multi-Agent Learning Code Analysis
PRIMAL: Pathfinding via Reinforcement and Imitation Multi-Agent Learning Code Analysis
2022-08-04 21:08:00 【strawberry47】
目录
论文名称:PRIMAL: Pathfinding via Reinforcement and Imitation Multi-Agent Learning
论文地址:https://arxiv.org/abs/1809.03531
代码地址:https://github.com/gsartoretti/PRIMAL
相关链接:Research on the dynamic obstacle avoidance strategy of unmanned driving | Robot dynamic obstacle avoidance strategy | 行人轨迹预测 | 机器人导航,Three papers on reinforcement learning for multi-agent path planning
1. 准备工作
1.1 配置环境:
- Create a new environment first:
conda create --name PRIMAL python=3.6
- 新建一个
requirements.txt
文件,Put all the packages you want to install in there,再运行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,So I got itpython 3.6;py3.6无法兼容1.3版本的tensorflow,So I replaced it again1.13版本的tf.
3. 如果安装失败,You can also install them one by one(我采用的方法)
注:直接pip或者conda安装不了gym时,可以尝试以下两种方法:conda install -c conda-forge gym=0.9.4
或者 pip install gym -i https://pypi.tuna.tsinghua.edu.cn/simple
安装tensorflow出问题时,The following two sentences can be executed conda install cudatoolkit=10.0
conda install tensorflow==1.13.1
4. 安装完成后,可以使用conda list
command to check if both are installed:
1.2 调试代码
安装
readme
The steps in the file come step by step:
① 命令行窗口进入cd od_mstar3
文件夹,python setup.py build_ext --inplace
;报错了error: Unable to find vcvarsall.bat
网上搜了一下,发现是需要安装Visual Studio,And it needs to be checked during installation C++组件.如果安装时没有勾选,应当Reinstall in the toolbar,After restarting therevcvarsall模块了.参考文章:已安装vs2017 仍然报错Unable to find vcvarsall.bat然而,After installing it, it still gives an error o(╥﹏╥)o,参照:关于error: Unable to find vcvarsall.bat,我将
msvc9compiler.py
文件中的find_vcvarsall
函数return改成return r"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.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库,需要自己下载安装.It is used for pathfinding.Boost C++ Libraries 编译安装,oostDownload, install, compile, configure and use the guide(含Windows和Linux)
① 在官网中下载了boost_1_53_.zip
,解压运行bootstrap.bat
的时候报错了 boost Compile-time error handling:Failed to build Boost.Build engine.查阅了很多资料,还是没解决,于是决定下载最新版本的boost工具包.
Error again during installation,fatal error C1083: 无法打开包括文件: “corecrt.h
,Windows 原生 cmd Compile under the window C++(cl命令)出现的问题及解决方法② Installed by a friendVisual Studio 2022,can be installed smoothlyboost,So I also reinstalledvs2022.啊!终于可以啦!!
1.3 linux环境安装boost:
!!!!linux环境直接使用sudo apt-get install boost
命令就可以安装了! https://stackoverflow.com/questions/12578499/how-to-install-boost-on-ubuntu
2.代码解析:
2.1 setup.py
As requested by the author,This file should be run first~setup.py
是调用cpython
,用 Python 的语法混合编写 Python 和 C/C++ 代码,提升 Python 速度
调用 C/C++ 代码 教程,Cython 基本用法 .
This code is runningcpython_od_matar.pyx
这个文件,其中的find_path(world, init_pos, goals, inflation, time_limit)
函数是使用ODrM算法进行探索.ODrMEquivalent to experts,generate a high-quality paths.
输入输出:
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.2 A3C_RNN.py
因为pycharm在服务器运行jupyterThe file is a bit cumbersome,我将DRLMAPF_A3C_RNN.ipynb
文件改成了A3C_RNN.py
文件.This part is responsible训练模型
2.3 ACNet.py
ACNet.py
中的_build_net()
The function corresponds to the network structure in the paper:
2.4 mapf_gym环境
2.4.1 mapf_gym与mapf_gym_cap区别
继承了gym
库,Used to build the environment
奇怪的是,它与mapf_gym_cap.py
The code is almost the same,只是_observe()
Functions are not the same:mapf_gym
中限制了mag
(agent距离goal的位置)的大小,It must be the limited field of view:
githubThe explanation for these two documents in :mapf_gym
:Multi-agent path planning gym environment, in which agents learn collective path planningmapf_gym_cap.py
:Multi-agent path planning gym environment, with capped goal distance state value for validation in larger environments
看了一下代码,It is called during trainingmapf_gym
,测试的时候是mapf_gym_cap.py
Running these two codes directly will give an errorNameError: name 'coordinationRatio' is not defined
,没查到coordinationRatio这个函数是干什么的,I put the corresponding codeprint(coordinationRatio(env))
注释掉了.
2.4.2 搭建环境
A3C_RNN.py
中创建环境:gym=mapf_gym.MAPFEnv(num_agents=n, world0=world[0],goals0=world[1])
2.5 mapgenerator.py
利用tk()
库,生成环境,即手动设置obstacle,agent的位置
2.6 primal_testing.py
加载模型,进行测试,报错[Errno 2] No such file or directory: 'saved_environments/4_agents_10_size_0_density_id_0_environment.npy'
,I can't find where to generate this file.
2.7 unittest
报错:pyglet.canvas.xlib.NoSuchDisplayException: Cannot connect to "None"
,It is said on the Internet that you can run it directly in the terminal
But,run in terminal,也报错your graphic drives do not support OpenGL 2.0
,网上查了一下,得有GPU才行.
① 试试这个方法:Image rendering in virtual formserver端启动虚拟化的图形渲染;没有用...
② 再试试这个pyglet.canvas.xlib.NoSuchDisplayException: Cannot connect to “None” ,It is also necessary to install half of it and find itGPU才行
Look at the code again,I found that the author commented it out at the beginningfrom gym.envs.classic_control import rendering
这个包,So I also commented out... But after commenting out,You can't see the graphical interface.
GroupLock.py
Responsible for multithreading:
Python多线程编程(一):threading 模块 Thread Class usage details
Python 多线程编程(二):threading 模块中 Lock Class usage details
【python】详解threading模块:Condition类的使用(三)
3.报错合集:
- 报错 Connection to Python debugger failed: Socket operation on nonsocket: configureBlocking
ImportError: DLL load failed: 找不到指定的模块.
解决办法:重新安装numpy和tensorflow- 运行
mapgenerator.py
代码时报错:TclError: no display name and no $DISPLAY environment variable
,解决办法 Specify the display device manually: ① 终端输入printenv grep DISPLAY
,查看版本,My output here islocalhost:10.0
;② 再将root = Tk()
改成root = Tk(screenName = ':10.0')
③ import的部分加上import matplotlib
,matplotlib.use('Agg')
边栏推荐
- STP基本配置及802.1D生成树协议的改进
- LINQ to SQL (Group By/Having/Count/Sum/Min/Max/Avg操作符)
- Spss-一元回归实操
- vim clear last search highlighting
- QT(41)-多线程-QTThread-同步QSemaphore-互斥QMutex
- [21 days learning challenge - kernel notes] (2), based in the device tree
- Tear down the underlying mechanism of the five JOINs of SparkSQL
- 使用百度EasyDL实现森林火灾预警识别
- About the state transfer problem of SAP e-commerce cloud Spartacus UI SSR
- composition-api
猜你喜欢
【debug】postgres数据存储错乱
嵌入式分享合集28
Spss-系统聚类软件实操
Matlab画图2
Tear down the underlying mechanism of the five JOINs of SparkSQL
xss课堂内容复现
PRIMAL: Pathfinding via Reinforcement and Imitation Multi-Agent Learning 代码解析
Oreo domain name authorization verification system v1.0.6 public open source version website source code
五分钟入门文本处理三剑客grep awk sed
OD-Model【6】:YOLOv2
随机推荐
matlab 画图
Getting Started with Lattice Passwords
[2022 Nioke Duo School 5 A Question Don't Starve] DP
遇到MapStruct后,再也不手写PO,DTO,VO对象之间的转换了
密码学系列之:PEM和PKCS7,PKCS8,PKCS12
Cryptography Series: PEM and PKCS7, PKCS8, PKCS12
Web3时代的战争
Feign 与 OpenFeign
如何用好建造者模式
命名路由、组件中name的作用
用 Excel 爬取网络数据的四个小案例
Spss-一元回归实操
如何进行AI业务诊断,快速识别降本提效增长点?
web漏洞扫描器-awvs
3、IO流之字节流和字符流
Tear down the underlying mechanism of the five JOINs of SparkSQL
LayaBox---TypeScript---Example
C语言知识大全(一)——C语言概述,数据类型
【2022杭电多校5 1003 Slipper】多个超级源点+最短路
bracket matching