Skip to content

Commit

Permalink
Show lane line in semantic camera (#569)
Browse files Browse the repository at this point in the history
* only show semantic

* optimize polygon

* fix

* good

* optimize line

* rename

* fix

* Add more

* filter crosswalk as well

* PGMap large

* semantic cam

* format

* expose map region size

* fix

* allow 2048 meters map

* terrain custimzed size

* fix camera fov

* fix

* format

* add readme

* run config

* auto run obs

* execute more

* fix

* execute rl_environment

* generate images online

* generate

* format

* generate more

* fix test

* Meshterrain to terrain

* fix test

* add examples

* adjust readme

* try build
  • Loading branch information
QuanyiLi committed Dec 2, 2023
1 parent b7b5b1e commit f9f1a79
Show file tree
Hide file tree
Showing 29 changed files with 787 additions and 646 deletions.
4 changes: 3 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ sphinx:
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: documentation/requirements.txt
- requirements: documentation/requirements.txt
- method: pip
path: .
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ python -m metadrive.examples.profile_metadrive

## 🚕 Examples
We provide [examples](https://github.com/metadriverse/metadrive/tree/main/metadrive/examples) to demonstrate features and basic usages of MetaDrive after the local installation.
Or you can run some examples directly in Colab. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/metadriverse/metadrive/blob/main/metadrive/examples/Basic_MetaDrive_Usages.ipynb)
There is an `.ipynb` example which can be directly opened in Colab. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/metadriverse/metadrive/blob/main/metadrive/examples/Basic_MetaDrive_Usages.ipynb)

Also, you can try examples in the documentation directly in Colab! See more details in [Documentations](#-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.
Expand Down Expand Up @@ -145,8 +147,17 @@ env.close()

## 🏫 Documentations

Find more details in: [MetaDrive](https://metadrive-simulator.readthedocs.io)
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](https://metadrive-simulator.readthedocs.io/en/latest/rl_environments.html).

[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/metadriverse/metadrive/blob/main/documentation/source/rl_environments.ipynb)

## 📎 References

Expand Down
52 changes: 48 additions & 4 deletions documentation/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
This folder contains files for the documentation: [https://metadrive-simulator.readthedocs.io/](https://metadrive-simulator.readthedocs.io/).
This folder contains files for the
documentation: [https://metadrive-simulator.readthedocs.io/](https://metadrive-simulator.readthedocs.io/).

To build documents locally, please run the following codes:

```
```bash
pip install sphinx sphinx_rtd_theme mst-nb
pip install sphinx-copybutton
cd metadrive/documentation
rm -rf build/ && make html
# or
rm -rf build/ && sphinx-build -j 4 source build
```

Expand All @@ -15,24 +18,65 @@ This tool can only check some external links. For checking cross-reference, usin
## Cross-Reference

### How to reference a section of an `.ipynb` file in an RST file?

Supposing you want to reference a section called TopDwnObservation in obs_action.ipynb, use

```
`TopDownObservation <obs_action.html#topdownobservation>`_
```

### How to reference a section of an `.rst` file in an `.ipynb` file?

Supposing you have a section called `Install MetaDrive` in `install.rst`, use

```
<a href="install.html#install-metadrive">Install MetaDrive</a>
```

### How to reference a section of an `.ipynb` file in an `.ipynb` file?
Supposing you have a section called `Top-down Renderer` in `top_down_render.ipynb`, use

Supposing you have a section called `Top-down Renderer` in `top_down_render.ipynb`, use

```
<a href="top_down_renderer.html#top-down-render">Top-down Renderer</a>
or
[Top-down Renderer](top_down_render.ipynb)
```
The second way can not refer to subtitle.

The second way can not refer to subtitle.

### Execution some files when building doc

The doc is set to disable executing all `.ipynb`.
For enabling executing certain files, set in the file metadata with:

```python
{
"mystnb": {
"execution_mode": "force"
}
}
```

For more details, see: https://myst-nb.readthedocs.io/en/latest/configuration.html

### Execution some cells in a file

If you only want to execute some cells, first set in the file metadata with

```python
{
"mystnb": {
"execution_mode": "auto"
}
}
```

It will auto run cells that doesn't run before.
And you need to skip all cells you don't want to run with cell tags:

```python
{"tags": ["skip-execution"]}
```
103 changes: 81 additions & 22 deletions documentation/source/action.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@
"cell_type": "code",
"execution_count": null,
"id": "0d6d0b30",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
"from metadrive.envs.metadrive_env import MetaDriveEnv\n",
Expand All @@ -105,7 +109,7 @@
" v.before_step([0, 0.5])\n",
" env.step([0,0])\n",
" frame=env.render(mode=\"topdown\", \n",
" no_window=True,\n",
" window=False,\n",
" screen_size=(800, 200),\n",
" camera_position=(60, 7))\n",
" frames.append(frame)\n",
Expand All @@ -118,7 +122,11 @@
"cell_type": "code",
"execution_count": 17,
"id": "855f689b",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -344,7 +352,11 @@
"cell_type": "code",
"execution_count": null,
"id": "c4766796",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
"from metadrive.envs.metadrive_env import MetaDriveEnv\n",
Expand All @@ -361,7 +373,7 @@
" # simulation\n",
" _,_,_,_,info = env.step([0.5, 1])\n",
" frame = env.render(mode=\"topdown\", \n",
" no_window=True,\n",
" window=False,\n",
" screen_size=(800, 200),\n",
" camera_position=(60, 15))\n",
" frames.append(frame)\n",
Expand All @@ -374,7 +386,11 @@
"cell_type": "code",
"execution_count": 25,
"id": "b59aa801",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -407,7 +423,11 @@
"cell_type": "code",
"execution_count": 23,
"id": "956e71cc",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
"from metadrive.envs.metadrive_env import MetaDriveEnv\n",
Expand Down Expand Up @@ -447,7 +467,7 @@
" # simulation\n",
" _,_,_,_,info = env.step([steering, 3])\n",
" frame= env.render(mode=\"topdown\", \n",
" no_window=True,\n",
" window=False,\n",
" text={\"command\": command},\n",
" screen_size=(700, 900),\n",
" camera_position=(60,-54))\n",
Expand All @@ -463,7 +483,11 @@
"cell_type": "code",
"execution_count": 24,
"id": "4f028600",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -622,7 +646,11 @@
"cell_type": "code",
"execution_count": 17,
"id": "9c7043c0",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
"from metadrive.envs.metadrive_env import MetaDriveEnv\n",
Expand All @@ -641,7 +669,7 @@
" # simulation\n",
" _,_,_,_,info = env.step([0, 3])\n",
" env.render(mode=\"topdown\", \n",
" no_window=True,\n",
" window=False,\n",
" screen_record=True,\n",
" screen_size=(700, 870),\n",
" camera_position=(60,-63)\n",
Expand All @@ -657,7 +685,11 @@
"cell_type": "code",
"execution_count": 18,
"id": "d278a9d9",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -688,7 +720,11 @@
"cell_type": "code",
"execution_count": 25,
"id": "b9d3df1d",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
"from metadrive.envs.metadrive_env import MetaDriveEnv\n",
Expand All @@ -705,7 +741,7 @@
" # simulation\n",
" _,_,_,_,info = env.step([0, 3])\n",
" env.render(mode=\"topdown\", \n",
" no_window=True,\n",
" window=False,\n",
" screen_record=True,\n",
" screen_size=(700, 870),\n",
" camera_position=(60,-63)\n",
Expand All @@ -721,7 +757,11 @@
"cell_type": "code",
"execution_count": 26,
"id": "73150b24",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -756,7 +796,11 @@
"cell_type": "code",
"execution_count": 28,
"id": "a19b2939",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
"from metadrive.engine.asset_loader import AssetLoader\n",
Expand All @@ -772,7 +816,7 @@
" for t in range(10000):\n",
" o, r, tm, tc, info = env.step([0, 0])\n",
" env.render(mode=\"top_down\",\n",
" no_window=True,\n",
" window=False,\n",
" screen_record=True,\n",
" screen_size=(700,700))\n",
" if info[\"replay_done\"]:\n",
Expand All @@ -786,7 +830,11 @@
"cell_type": "code",
"execution_count": 29,
"id": "223c7094",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -819,7 +867,11 @@
"cell_type": "code",
"execution_count": 5,
"id": "08efdb54",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [],
"source": [
"import numpy as np\n",
Expand Down Expand Up @@ -848,7 +900,7 @@
" for i in range(1, 150):\n",
" o, r, tm, tc, info = env.step([.0, -1])\n",
" env.render(mode=\"top_down\", \n",
" no_window=True,\n",
" window=False,\n",
" screen_record=True, \n",
" camera_position=(0,0),\n",
" screen_size=(500, 400))\n",
Expand All @@ -870,7 +922,11 @@
"cell_type": "code",
"execution_count": 6,
"id": "c40eee98",
"metadata": {},
"metadata": {
"tags": [
"skip-execution"
]
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -914,7 +970,10 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.7.13"
},
"mystnb": {
"execution_mode": "auto"
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions documentation/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

nbsphinx_execute = 'never'
nb_execution_mode = 'off'
nb_execution_timeout = 300

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down

0 comments on commit f9f1a79

Please sign in to comment.