An open-ended driving simulator with infinite scenes
Project description
MetaDrive: Composing Diverse Driving Scenarios for Generalizable RL
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 300 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 Start
Install MetaDrive via:
git clone https://github.com/metadriverse/metadrive.git
cd metadrive
pip install -e .
or
pip install metadrive-simulator
Note that the program is tested on both Linux and Windows. Some control and display issues in MacOS wait to be solved
You can verify the installation of MetaDrive via running the testing script:
# Go to a folder where no sub-folder calls metadrive
python -m metadrive.examples.profile_metadrive
Note that please do not run the above command in a folder that has a sub-folder called ./metadrive
.
🚕 Examples
We provide examples to demonstrate features and basic usages of MetaDrive after the local installation. Or you can run some examples directly in Colab.
Single Agent Environment
Run 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 -m metadrive.examples.drive_in_single_agent_env
Run the following command to launch a safe driving scenario, which includes more complex obstacles and cost to be yielded.
python -m metadrive.examples.drive_in_safe_metadrive_env
Multi-Agent Environment
You can also launch an instance of Multi-Agent scenario as follows
python -m metadrive.examples.drive_in_multi_agent_env --env roundabout
--env
accepts following parmeters: roundabout
(default), intersection
, tollgate
, bottleneck
, parkinglot
, pgmap
.
Adding --pygame_render
can launch top-down pygame renderer.
Real Environment
Running the following script enables driving in a scenario constructed from Waymo motion dataset.
python -m metadrive.examples.drive_in_waymo_env
Press key r
for loading a new scenario, and b
or q
for switching perspective.
Basic Usage
To build the RL environment in python script, you can simply code in the OpenAI gym format as:
import metadrive # Import this package to register the environment!
import gym
env = gym.make("MetaDrive-v0", config=dict(use_render=True))
# env = metadrive.MetaDriveEnv(config=dict(environment_num=100)) # Or build environment from class
env.reset()
for i in range(1000):
obs, reward, done, info = env.step(env.action_space.sample()) # Use random policy
env.render()
if done:
env.reset()
env.close()
🏫 Documentations
Find more details in: MetaDrive
📎 References
If 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 Projects
Learning to Simulate Self-driven Particles System with Coordinated Policy Optimization
Zhenghao Peng, Quanyi Li, Chunxiao Liu, Bolei Zhou
NeurIPS 2021
[Paper]
[Code]
[Webpage]
[Poster]
[Talk]
Safe Driving via Expert Guided Policy Optimization
Zhenghao Peng*, Quanyi Li*, Chunxiao Liu, Bolei Zhou
Conference on Robot Learning (CoRL) 2021
[Paper]
[Code]
[Webpage]
[Poster]
Efficient Learning of Safe Driving Policy via Human-AI Copilot Optimization
Quanyi Li*, Zhenghao Peng*, Bolei Zhou
ICLR 2022
[Paper]
[Code]
[Webpage]
[Poster]
[Talk]
Human-AI Shared Control via Policy Dissection
Quanyi Li, Zhenghao Peng, Haibin Wu, Lan Feng, Bolei Zhou
NeurIPS 2022
[Paper]
[Code]
[Webpage]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for metadrive-simulator-0.2.5.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a12f792580820f62db49448edfee9b78830cc2d8536334b3d436f3836ddfb236 |
|
MD5 | 9b5f6b7453380ffbc5cdfc2b551d8e4c |
|
BLAKE2b-256 | b09f8f6e135202aa5ed42578b297fd2b5aaee03d6180ca2bc02a74db4602340c |
Hashes for metadrive_simulator-0.2.5.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b2ffddec25327b5bdceab4862da8b309a7d6b448bfe9b4b7a8a992f841826ec |
|
MD5 | df78773cdc5956710a0acff3ec51f7f7 |
|
BLAKE2b-256 | d81819dbf86119d40e442ef4ff34ec9e8238b17770380758f3588216a6ffdaf1 |