2023-05-05 19:20:08 +01:00
|
|
|
# ScenarioNet
|
2023-05-19 13:51:18 +01:00
|
|
|
|
2023-06-17 17:19:40 +01:00
|
|
|
**Open-Source Platform for Large-Scale Traffic Scenario Simulation and Modeling**
|
|
|
|
|
|
2023-06-22 12:17:20 +01:00
|
|
|
[**Webpage**](https://metadriverse.github.io/scenarionet/) |
|
2023-06-17 17:19:40 +01:00
|
|
|
[**Code**](https://github.com/metadriverse/scenarionet) |
|
2023-06-23 19:50:40 +01:00
|
|
|
[**Video**](https://youtu.be/3bOqswXP6OA) |
|
2023-06-22 12:17:20 +01:00
|
|
|
[**Paper**](http://arxiv.org/abs/2306.12241) |
|
2023-08-08 18:18:33 +01:00
|
|
|
[**Documentation**](https://scenarionet.readthedocs.io/en/latest/) |
|
2023-06-17 17:19:40 +01:00
|
|
|
|
|
|
|
|
ScenarioNet allows users to load scenarios from real-world dataset like Waymo, nuPlan, nuScenes, l5 and synthetic
|
|
|
|
|
dataset such as procedural generated ones and safety-critical ones generated by adversarial attack.
|
2023-08-25 18:35:46 +01:00
|
|
|
The built database provides tools for building training and test sets for ML applications.
|
2023-06-17 17:19:40 +01:00
|
|
|
|
|
|
|
|
Powered by [MetaDrive Simulator](https://github.com/metadriverse/metadrive), the scenarios can be reconstructed for
|
|
|
|
|
various applications like AD stack test, reinforcement learning, imitation learning, scenario generation and so on.
|
|
|
|
|
|
2023-08-25 18:35:46 +01:00
|
|
|

|
2023-06-17 17:19:40 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
|
|
```
|
2023-07-03 13:50:33 +01:00
|
|
|
# create environment
|
|
|
|
|
conda create -n scenarionet python=3.9
|
|
|
|
|
conda activate scenarionet
|
|
|
|
|
|
|
|
|
|
# Install MetaDrive Simulator
|
|
|
|
|
git clone git@github.com:metadriverse/metadrive.git
|
|
|
|
|
cd metadrive
|
|
|
|
|
pip install -e.
|
|
|
|
|
|
|
|
|
|
# Install ScenarioNet
|
2023-05-19 13:51:18 +01:00
|
|
|
git clone git@github.com:metadriverse/scenarionet.git
|
|
|
|
|
cd scenarionet
|
|
|
|
|
pip install -e .
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
We provide some explanation and demo for all scripts here.
|
2023-06-10 18:56:33 +01:00
|
|
|
**You are encouraged to try them on your own, add ```-h``` or ```--help``` argument to know more details about these
|
|
|
|
|
scripts.**
|
2023-05-19 13:51:18 +01:00
|
|
|
|
|
|
|
|
### Convert
|
|
|
|
|
|
2023-07-03 13:50:33 +01:00
|
|
|
**Waymo**: the following script can convert Waymo tfrecord (version: v1.2, data_bin: training_20s) to Metadrive scenario
|
|
|
|
|
description and store them at directory ./waymo
|
2023-05-19 13:51:18 +01:00
|
|
|
|
|
|
|
|
```
|
|
|
|
|
python -m scenarionet.convert_waymo -d waymo --raw_data_path /path/to/tfrecords --num_workers=16
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**nuPlan**: the following script will convert nuPlan split containing .db files to Metadrive scenario description and
|
|
|
|
|
store them at directory ./nuplan
|
|
|
|
|
|
|
|
|
|
```
|
2023-05-19 13:56:36 +01:00
|
|
|
python -m scenarionet.convert_nuplan -d nuplan -raw_data_path /path/to/.db files --num_workers=16
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**nuScenes**: as nuScenes split can be read by specifying version like v1.0-mini and v1.0-training, the following script
|
|
|
|
|
will convert all scenarios in that split
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
python -m scenarionet.convert_nuscenes -d nuscenes --version v1.0-mini --num_workers=16
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**PG**: the following script can generate 10000 scenarios stored at directory ./pg
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
python -m scenarionet.scripts.convert_pg -d pg --num_workers=16 --num_scenarios=10000
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Merge & move
|
2023-06-10 18:56:33 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
For merging two or more database, use
|
2023-06-10 18:56:33 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
2023-08-25 18:35:46 +01:00
|
|
|
python -m scenarionet.merge -d /destination/path --from /database1 /2 ...
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
2023-06-10 18:56:33 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
As a database contains a path mapping, one should move database folder with the following script instead of ```cp```
|
2023-06-10 18:56:33 +01:00
|
|
|
command.
|
|
|
|
|
Using ```--copy_raw_data``` will copy the raw scenario file into target directory and cancel the virtual mapping.
|
|
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
2023-06-10 18:56:33 +01:00
|
|
|
python -m scenarionet.copy_database --to /destination/path --from /source/path
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Verify
|
2023-06-10 18:56:33 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
The following scripts will check whether all scenarios exist or can be loaded into simulator.
|
2023-06-10 18:56:33 +01:00
|
|
|
The missing or broken scenarios will be recorded and stored into the error file. Otherwise, no error file will be
|
|
|
|
|
generated.
|
2023-05-19 13:51:18 +01:00
|
|
|
With teh error file, one can build a new database excluding or including the broken or missing scenarios.
|
2023-05-19 13:56:36 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
**Existence check**
|
2023-06-10 18:56:33 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
2023-06-10 18:56:33 +01:00
|
|
|
python -m scenarionet.check_existence -d /database/to/check --error_file_path /error/file/path
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
2023-06-10 18:56:33 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
**Runnable check**
|
2023-06-10 18:56:33 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
2023-06-10 18:56:33 +01:00
|
|
|
python -m scenarionet.check_simulation -d /database/to/check --error_file_path /error/file/path
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
2023-06-10 18:56:33 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
**Generating new database**
|
2023-06-10 18:56:33 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
2023-05-19 14:00:52 +01:00
|
|
|
python -m scenarionet.generate_from_error_file -d /new/database/path --file /error/file/path
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### visualization
|
|
|
|
|
|
|
|
|
|
Visualizing the simulated scenario
|
2023-06-10 18:56:33 +01:00
|
|
|
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
2023-08-25 18:35:46 +01:00
|
|
|
python -m scenarionet.sim -d /path/to/database --render --scenario_index
|
2023-05-19 13:51:18 +01:00
|
|
|
```
|
|
|
|
|
|