Skip to main content

the fork of metadrive

Project description



MetaDrive: an Open-source Driving Simulator for AI and Autonomy Research

build Documentation GitHub license GitHub contributors Downloads


MetaDrive is a driving simulator with the following key features:

  • Compositional: It supports synthesising infinite scenes with various road maps and traffic settings or loading real-world driving logs for the research of generalizable RL.
  • Lightweight: It is easy to install and run on Linux/Windows/MacOS with sensor simulation support. It can run up to +1000 FPS on a standard PC.
  • Realistic: Accurate physics simulation and multiple sensory input including point cloud, RGB/Depth/Semantic 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 .

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. There is an .ipynb example which can be directly opened in Colab. Open In Colab

Also, you can try examples in the documentation directly in Colab! See more details in Documentations.

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 --top_down can launch top-down pygame renderer.

Real Environment

Running the following script enables driving in a scenario constructed from nuScenes dataset or Waymo dataset.

python -m metadrive.examples.drive_in_real_env

The default real-world dataset is nuScenes. Use --waymo to visualize Waymo scenarios. Traffic vehicles can not response to surrounding vchicles if directly replaying them. Add argument --reactive_traffic to use an IDM policy control them and make them reactive. 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 Farama Gymnasium format as:

from metadrive.envs.metadrive_env import MetaDriveEnv

env = MetaDriveEnv(config={"use_render": True})
obs, info = env.reset()
for i in range(1000):
    obs, reward, terminated, truncated, info = env.step(env.action_space.sample())
    if terminated or truncated:
        env.reset()
env.close()

🏫 Documentations

Please find more details in: https://metadrive-simulator.readthedocs.io

Running Examples in Doc

The documentation is built with .ipynb so 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 .ipynb file of the documentation section: Environments.

Open In Colab

📎 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}
}

Acknowledgement

The simulator can not be built without the help from Panda3D community and the following open-sourced projects:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jethro_metadrive-0.5.1.tar.gz (54.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jethro_metadrive-0.5.1-py3-none-any.whl (55.0 MB view details)

Uploaded Python 3

File details

Details for the file jethro_metadrive-0.5.1.tar.gz.

File metadata

  • Download URL: jethro_metadrive-0.5.1.tar.gz
  • Upload date:
  • Size: 54.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for jethro_metadrive-0.5.1.tar.gz
Algorithm Hash digest
SHA256 28ebff8bf2caa41bba1dd4352e4af99869cbb0d50bed448e15020b9750ac2b3f
MD5 8bcbbe25b73c32f510225df15cf977fe
BLAKE2b-256 6ddda3856a03f8f4fb7782c12842fc84ad0d49cd02c9f4941ae950a57e618363

See more details on using hashes here.

File details

Details for the file jethro_metadrive-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for jethro_metadrive-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19ff57ab8e2be5ad90f6b06e7c2e7e2b1b2921355d7e259420010ed32d4f3e77
MD5 cd3d65c0897862689d5d8c81e0fef573
BLAKE2b-256 217c624e0b06c084dc63e008562c0015e04e12e044c030955eaeb9401b57bc2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page