具有OpenAI Gym兼容接口的多智能体连接自动驾驶(MACAD)学习环境
macad-gym的Python项目详细描述
MACAD-Gym是一个多Agent连接自治的训练平台 驾驶(MACAD)建立在卡拉自动驾驶模拟器之上。在
MACAD Gym为各种 在同质/异类中训练深层RL算法的驱动场景, 通信/非通信和其他多代理设置。新的环境和方案 可以使用简单的、类似JSON的配置轻松添加。在
快速启动
使用pip install macad-gym
安装MACAD Gym。
如果安装了CARLA,可以使用以下3行代码开始工作。如果没有,请遵循
Getting started steps。在
importgymimportmacad_gymenv=gym.make("HomoNcomIndePOIntrxMASS3CTWN3-v0")# Your agent code here
任何支持OpenAI Gym API的RL库都可以用于在MACAD Gym中培训代理。MACAD-Agents存储库提供示例代理作为启动程序。在
使用指南
入门
Assumes an Ubuntu (16.04/18.04 or later) system.
- 在
安装系统要求:
- Miniconda/Anaconda 3.x版
wget -P ~ https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh; bash ~/Miniconda3-latest-Linux-x86_64.sh
- cmake(
sudo apt install cmake
) - zlib(
sudo apt install zlib1g-dev
) - [可选]ffmpeg(
sudo apt install ffmpeg
)
- Miniconda/Anaconda 3.x版
- 在
设置卡拉(0.9.x)
3.1
mkdir ~/software && cd ~/software
3.2示例:从:Here下载0.9.4版本 将其提取到
~/software/CARLA_0.9.4
3.3
在echo "export CARLA_SERVER=${HOME}/software/CARLA_0.9.4/CarlaUE4.sh" >> ~/.bashrc
- 在
安装MACAD Gym:
- Option1用于用户:
pip install macad-gym
- Option2面向开发人员:
- 将存储库分叉/克隆到您的工作区:
git clone https://github.com/praveen-palanisamy/macad-gym.git && cd macad-gym
- 创建一个名为“macad gym”的新conda env并安装所需的软件包:
conda env create -f conda_env.yml
- 激活
macad-gym
conda python环境:source activate macad-gym
- 安装
macad-gym
包:pip install -e .
- 安装CARLA PythonAPI:
pip install carla==0.9.4
在NOTE: Change the carla client PyPI package version number to match with your CARLA server version
- 将存储库分叉/克隆到您的工作区:
- Option1用于用户:
学习平台和代理接口
MACAD Gym平台为培训代理商提供学习环境,
针对各种自动驾驶任务和
能够在同质/异构环境中训练代理的场景
学习环境遵循ID一致性的命名约定
并支持代理算法的版本基准测试。
命名约定在下面用HeteCommCoopPOUrbanMgoalMAUSID
说明
例如:
随着时间的推移,麦卡德健身房的训练环境数量预计会增加 (PRs非常受欢迎!)。在
环境
环境界面简单,遵循广泛采用的OpenAI-Gym 接口。您可以使用 以下3行代码:
^{pr2}$像任何OpenAI健身房环境一样,你可以获得观察空间和动作 空间如下所示:
>>> print(env.observation_space) Dict(car1:Box(168, 168, 3), car2:Box(168, 168, 3), car3:Box(168, 168, 3)) >>> print(env.action_space) Dict(car1:Discrete(9), car2:Discrete(9), car3:Discrete(9))
要获取可用环境的列表,可以使用
list_available_envs()
函数,如下面的代码片段所示:
importgymimportmacad_gymmacad_gym.list_available_envs()
这将打印可用的环境。以下提供示例输出供参考:
Environment-ID: Short description {'HeteNcomIndePOIntrxMATLS1B2C1PTWN3-v0': 'Heterogeneous, Non-communicating, ''Independent,Partially-Observable ''Intersection Multi-Agent scenario ''with Traffic-Light Signal, 1-Bike, ''2-Car,1-Pedestrian in Town3, ''version 0', 'HomoNcomIndePOIntrxMASS3CTWN3-v0': 'Homogenous, Non-communicating, ''Independed, Partially-Observable ''Intersection Multi-Agent scenario with ''Stop-Sign, 3 Cars in Town3, version 0'}
代理接口
Agent环境接口与OpenAI-Gym接口兼容 因此,允许对现有的RL-agent算法进行简单的实验 实现和库。您可以使用任何现有的支持开放式AI-Gym API的Deep-RL库来培训您的代理。在
基本代理-环境交互循环如下:
importgymimportmacad_gymenv=gym.make("HomoNcomIndePOIntrxMASS3CTWN3-v0")configs=env.configsenv_config=configs["env"]actor_configs=configs["actors"]classSimpleAgent(object):def__init__(self,actor_configs):"""A simple, deterministic agent for an example Args: actor_configs: Actor config dict """self.actor_configs=actor_configsself.action_dict={}defget_action(self,obs):""" Returns `action_dict` containing actions for each agent in the env """foractor_idinself.actor_configs.keys():# ... Process obs of each agent and generate action ...ifenv_config["discrete_actions"]:self.action_dict[actor_id]=3# Drive forwardelse:self.action_dict[actor_id]=[1,0]# Full-throttlereturnself.action_dictagent=SimpleAgent(actor_configs)# Plug-in your agent or use MACAD-Agentsforepinrange(2):obs=env.reset()done={"__all__":False}step=0whilenotdone["__all__"]:obs,reward,done,info=env.step(agent.get_action(obs))print(f"Step#:{step} Rew:{reward} Done:{done}")step+=1env.close()
引用:
如果你发现这项工作对你的研究有用,请引用:
@misc{palanisamy2019multiagent,title={Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning},author={Praveen Palanisamy},year={2019},eprint={1911.04175},archivePrefix={arXiv},primaryClass={cs.LG}}
其他格式的引文:(单击查看)
在
MLA | Palanisamy, Praveen. "Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning." arXiv preprint arXiv:1911.04175 (2019). |
---|---|
APA | Palanisamy, P. (2019). Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning. arXiv preprint arXiv:1911.04175. |
Chicago | Palanisamy, Praveen. "Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning." arXiv preprint arXiv:1911.04175 (2019). |
Harvard | Palanisamy, P., 2019. Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning. arXiv preprint arXiv:1911.04175. |
Vancouver | Palanisamy P. Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning. arXiv preprint arXiv:1911.04175. 2019 Nov 11. |
NOTEs:
- 在
MACAD Gym支持多GPU设置,它将选择负载较低的GPU来启动RL训练环境所需的模拟
在 - 在
MACAD健身房是为卡拉准备的0.9.x&;以上。如果你是 正在为卡拉0.8.x(稳定版本)寻找OpenAI Gym兼容的代理学习环境, 使用this carla_gym environment。在
在
- 项目
标签: