Package: macad-gym
MACAD-Gymis a training platform for Multi-Agent Connected Autonomous
Driving (MACAD) built on top of the CARLA Autonomous Driving simulator.MACAD-Gym provides OpenAI Gym-compatible learning environments for various
driving scenarios for training Deep RL algorithms in homogeneous/heterogenous,
communicating/non-communicating and other multi-agent settings. New environments and scenarios
can be easily added using a simple, JSON-like configuration.Quick StartInstall MACAD-Gym usingpip install macad-gym.
If you have CARLA installed, you can get going using the following 3 lines of code. If not, follow theGetting started steps.importgymimportmacad_gymenv=gym.make("HomoNcomIndePOIntrxMASS3CTWN3-v0")# Your agent code hereAny RL library that supports the OpenAI-Gym API can be used to train agents in MACAD-Gym. TheMACAD-Agentsrepository provides sample agents as a starter.Usage guideGetting StartedLearning platform & agent interfaceCiting MACAD-GymDeveloper Contribution GuideGetting StartedAssumes an Ubuntu (16.04/18.04 or later) system.Install the system requirements:Miniconda/Anaconda 3.xwget -P ~ https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh; bash ~/Miniconda3-latest-Linux-x86_64.shcmake (sudo apt install cmake)zlib (sudo apt install zlib1g-dev)[optional] ffmpeg (sudo apt install ffmpeg)Setup CARLA (0.9.x)3.1mkdir ~/software && cd ~/software3.2 Example: Download the 0.9.4 release version from:HereExtract it into~/software/CARLA_0.9.43.3echo "export CARLA_SERVER=${HOME}/software/CARLA_0.9.4/CarlaUE4.sh" >> ~/.bashrcInstall MACAD-Gym:Option1 for users:pip install macad-gymOption2 for developers:Fork/Clone the repository to your workspace:git clone https://github.com/praveen-palanisamy/macad-gym.git && cd macad-gymCreate a new conda env named "macad-gym" and install the required packages:conda env create -f conda_env.ymlActivate themacad-gymconda python env:source activate macad-gymInstall themacad-gympackage:pip install -e .Install CARLA PythonAPI:pip install carla==0.9.4NOTE: Change the carla client PyPI package version number to match with your CARLA server versionLearning Platform and Agent InterfaceThe MACAD-Gym platform provides learning environments for training agents in both,
single-agent and multi-agent settings for various autonomous driving tasks and
scenarios that enables training agents in homogeneous/heterogeneous
The learning environments follows naming convention for the ID to be consistent
and to support versioned benchmarking of agent algorithms.
The naming convention is illustrated below withHeteCommCoopPOUrbanMgoalMAUSIDas an example:The number of training environments in MACAD-Gym is expected to grow over time
(PRs are very welcome!).EnvironmentsThe environment interface is simple and follows the widely adopted OpenAI-Gym
interface. You can create an instance of a learning environment using the
following 3 lines of code:importgymimportmacad_gymenv=gym.make("HomoNcomIndePOIntrxMASS3CTWN3-v0")Like any OpenAI Gym environment, you can obtain the observation space and action
spaces as shown below:>>>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))To get a list of available environments, you can use
thelist_available_envs()function as shown in the code snippet below:importgymimportmacad_gymmacad_gym.list_available_envs()This will print the available environments. Sample output is provided below for reference:Environment-ID:Shortdescription{'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 interfaceThe Agent-Environment interface is compatible with the OpenAI-Gym interface
thus, allowing for easy experimentation with existing RL agent algorithm
implementations and libraries. You can use any existing Deep RL library that supports the Open AI Gym API to train your agents.The basic agent-environment interaction loop is as follows: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 exampleArgs: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()Citing:If you find this work useful in your research, please cite:@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}}Citation in other Formats: (Click to View)MLAPalanisamy, Praveen. "Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning."arXiv preprint arXiv:1911.04175(2019).APAPalanisamy, P. (2019). Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning.arXiv preprint arXiv:1911.04175.ChicagoPalanisamy, Praveen. "Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning."arXiv preprint arXiv:1911.04175(2019).HarvardPalanisamy, P., 2019. Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning.arXiv preprint arXiv:1911.04175.VancouverPalanisamy P. Multi-Agent Connected Autonomous Driving using Deep Reinforcement Learning. arXiv preprint arXiv:1911.04175. 2019 Nov 11.BibTeXEndNoteRefManRefWorksNOTEs:MACAD-Gym supports multi-GPU setups and it will choose the GPU that is less loaded to launch the simulation needed for the RL training environmentMACAD-Gym is for CARLA 0.9.x & above . If you are
looking for an OpenAI Gym-compatible agent learning environment for CARLA 0.8.x (stable release),
usethis carla_gym environment.