Package: metadrive-simulator
MetaDrive: AI Research for Generalizable and Interpretable Machine Autonomy[Documentation|Colab Examples|Demo Video|Website|Paper|Relevant Projects]MetaDrive is a driving simulator with the following key features:Compositional: It supports generating infinite scenes with various road maps and traffic settings for the research of generalizable RL.Lightweight: It is easy to install and run. It can run up to +1000 FPS on a standard PC.Realistic: Accurate physics simulation and multiple sensory input including Lidar, RGB images, top-down semantic map and first-person view images.🛠 Quick StartInstall MetaDrive via:gitclonehttps://github.com/metadriverse/metadrive.gitcdmetadrive
pipinstall-e.orpipinstallmetadrive-simulatorNote that the program is tested on both Linux and Windows. Some control and display issues in MacOS wait to be solvedYou can verify the installation of MetaDrive via running the testing script:# Go to a folder where no sub-folder calls metadrivepython-mmetadrive.examples.profile_metadriveNote that please do not run the above command in a folder that has a sub-folder called./metadrive.🚕 ExamplesWe provideexamplesto demonstrate features and basic usages of MetaDrive after the local installation.
There is an.ipynbexample which can be directly opened in Colab.Also, you can try examples in the documentation directly in Colab! See more details inDocumentations.Single Agent EnvironmentRun the following command to launch a simple driving scenario with auto-drive mode on. Press W, A, S, D to drive the vehicle manually.python-mmetadrive.examples.drive_in_single_agent_envRun the following command to launch a safe driving scenario, which includes more complex obstacles and cost to be yielded.python-mmetadrive.examples.drive_in_safe_metadrive_envMulti-Agent EnvironmentYou can also launch an instance of Multi-Agent scenario as followspython-mmetadrive.examples.drive_in_multi_agent_env--envroundabout--envaccepts following parmeters:roundabout(default),intersection,tollgate,bottleneck,parkinglot,pgmap.
Adding--top_downcan launch top-down pygame renderer.Real EnvironmentRunning the following script enables driving in a scenario constructed from nuScenes dataset or Waymo dataset.python-mmetadrive.examples.drive_in_real_envThe default real-world dataset is nuScenes.
Use--waymoto visualize Waymo scenarios.
Traffic vehicles can not response to surrounding vchicles if directly replaying them.
Add argument--reactive_trafficto use an IDM policy control them and make them reactive.
Press keyrfor loading a new scenario, andborqfor switching perspective.Basic UsageTo build the RL environment in python script, you can simply code in the Farama Gymnasium format as:frommetadrive.envs.metadrive_envimportMetaDriveEnvenv=MetaDriveEnv(config={"use_render":True})obs,info=env.reset()foriinrange(1000):obs,reward,terminated,truncated,info=env.step(env.action_space.sample())ifterminatedortruncated:env.reset()env.close()🏫 DocumentationsPlease find more details in:https://metadrive-simulator.readthedocs.ioRunning Examples in DocThe documentation is built with.ipynbso every example can run locally
or with colab. For Colab running, on the Colab interface, click “GitHub,” enter the URL of MetaDrive:https://github.com/metadriverse/metadrive, and hit the search icon.
After running examples, you are expected to get the same output and visualization results as the documentation!For example, hitting the following icon opens the source.ipynbfile of the documentation section:Environments.📎 ReferencesIf you use MetaDrive in your own work, please cite:@article{li2022metadrive,
  title={Metadrive: Composing diverse driving scenarios for generalizable reinforcement learning},
  author={Li, Quanyi and Peng, Zhenghao and Feng, Lan and Zhang, Qihang and Xue, Zhenghai and Zhou, Bolei},
  journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
  year={2022}}🎉 Relevant ProjectsLearning to Simulate Self-driven Particles System with Coordinated Policy OptimizationZhenghao Peng, Quanyi Li, Chunxiao Liu, Bolei ZhouNeurIPS 2021[Paper]
[Code]
[Webpage]
[Poster]
[Talk]
[Results&Models]Safe Driving via Expert Guided Policy OptimizationZhenghao Peng*, Quanyi Li*, Chunxiao Liu, Bolei ZhouConference on Robot Learning (CoRL) 2021[Paper]
[Code]
[Webpage]
[Poster]Efficient Learning of Safe Driving Policy via Human-AI Copilot OptimizationQuanyi Li*, Zhenghao Peng*, Bolei ZhouICLR 2022[Paper]
[Code]
[Webpage]
[Poster]
[Talk]Human-AI Shared Control via Policy DissectionQuanyi Li, Zhenghao Peng, Haibin Wu, Lan Feng, Bolei ZhouNeurIPS 2022[Paper]
[Code]
[Webpage]And more:Yang, Yujie, Yuxuan Jiang, Yichen Liu, Jianyu Chen, and Shengbo Eben Li. "Model-Free Safe Reinforcement Learning through Neural Barrier Certificate." IEEE Robotics and Automation Letters (2023).Feng, Lan, Quanyi Li, Zhenghao Peng, Shuhan Tan, and Bolei Zhou. "TrafficGen: Learning to Generate Diverse and Realistic Traffic Scenarios." (ICRA 2023)Zhenghai Xue, Zhenghao Peng, Quanyi Li, Zhihan Liu, Bolei Zhou. "Guarded Policy Optimization with Imperfect Online Demonstrations." (ICLR 2023)AcknowledgementThe simulator can not be built without the help from Panda3D community and the following open-sourced projects:panda3d-simplepbr:https://github.com/Moguri/panda3d-simplepbrpanda3d-gltf:https://github.com/Moguri/panda3d-gltfRenderPipeline (RP):https://github.com/tobspr/RenderPipelineWater effect for RP:https://github.com/kergalym/RenderPipelineprocedural_panda3d_model_primitives:https://github.com/Epihaius/procedural_panda3d_model_primitivesDiamondSquare for terrain generation:https://github.com/buckinha/DiamondSquareKITSUNETSUKI-Asset-Tools:https://github.com/kitsune-ONE-team/KITSUNETSUKI-Asset-Tools