Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into multigoal
Browse files Browse the repository at this point in the history
# Conflicts:
#	metadrive/component/vehicle/base_vehicle.py
  • Loading branch information
pengzhenghao committed Jul 6, 2024
2 parents 61dfd8f + 05ec6c8 commit 40afd75
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 230 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@
/documentation/**/**.gif
/documentation/source/img.png
/documentation/source/demo.png

# ignore documentation build output
**/filtered_dataset
**/semantics.png
11 changes: 0 additions & 11 deletions documentation/source/debug_mode.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,6 @@
"In addition to the errors raised from MetaDrive, sometimes the game engine, Panda3D, will throw errors and warnings about the rendering service. To enable the logging of Panda3D, set `env_config[\"debug_panda3d\"]=True`. Besides, you can turn on Panda3D's profiler via `env_config[\"pstats\"]=True` and launch the `pstats` in the terminal. It can be used to analyze your program in terms of the time consumed for different functions like rendering, physics and so on, which is very useful if you are developing some graphics related features."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7b3e2ecb",
"metadata": {},
"outputs": [],
"source": [
"# launch pstats (bash)\n",
"!pstats"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
20 changes: 9 additions & 11 deletions documentation/source/obs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"cell_type": "markdown",
"id": "72c167e8",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
Expand Down Expand Up @@ -415,7 +414,6 @@
"execution_count": 4,
"id": "ff7a70aa",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
Expand Down Expand Up @@ -544,7 +542,6 @@
"execution_count": 45,
"id": "3562290f",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
Expand Down Expand Up @@ -592,7 +589,6 @@
"execution_count": 12,
"id": "995d5314-92a7-4e68-8bb8-05f1bd8ab718",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
Expand All @@ -619,7 +615,6 @@
"execution_count": 13,
"id": "7f20c293-77f9-451c-a552-882def3d6257",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
Expand Down Expand Up @@ -712,7 +707,6 @@
"execution_count": 10,
"id": "9ea9966f-f123-40e8-a432-1ac19f396431",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
Expand Down Expand Up @@ -806,13 +800,16 @@
"from metadrive.envs.metadrive_env import MetaDriveEnv\n",
"from metadrive.obs.state_obs import LidarStateObservation\n",
"from metadrive.component.sensors.rgb_camera import RGBCamera\n",
"import os\n",
"test_doc = os.getenv('TEST_DOC')\n",
"sensor_size = (84, 60) if test_doc else (200, 100)\n",
"\n",
"env = MetaDriveEnv(config=dict(\n",
" use_render=False,\n",
" agent_observation=LidarStateObservation,\n",
" image_observation=True,\n",
" norm_pixel=False,\n",
" sensors=dict(rgb_camera=(RGBCamera, 512, 256)),\n",
" sensors=dict(rgb_camera=(RGBCamera, *sensor_size)),\n",
"))\n",
"\n",
"obs, info = env.reset()\n",
Expand All @@ -822,9 +819,10 @@
"image = env.engine.get_sensor(\"rgb_camera\").perceive(to_float=False)\n",
"image = image[..., [2, 1, 0]]\n",
"\n",
"import matplotlib.pyplot as plt\n",
"plt.imshow(image)\n",
"plt.show()"
"if not test_doc:\n",
" import matplotlib.pyplot as plt\n",
" plt.imshow(image)\n",
" plt.show()"
]
}
],
Expand All @@ -844,7 +842,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.7.13"
},
"mystnb": {
"execution_mode": "force"
Expand Down
14 changes: 14 additions & 0 deletions metadrive/engine/core/engine_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from metadrive.engine.logger import get_logger
from metadrive.utils.utils import is_mac, setup_logger
import logging
import subprocess
from metadrive.utils.utils import is_port_occupied

logger = get_logger()

Expand Down Expand Up @@ -121,9 +123,21 @@ def __init__(self, global_config):
self.pid = os.getpid()
EngineCore.global_config = global_config
self.mode = global_config["_render_mode"]
self.pstats_process = None
if self.global_config["pstats"]:
# pstats debug provided by panda3d
loadPrcFileData("", "want-pstats 1")
if not is_port_occupied(5185):
self.pstats_process = subprocess.Popen(['pstats'])
logger.info(
"pstats is launched successfully, tutorial is at: "
"https://docs.panda3d.org/1.10/python/optimization/using-pstats"
)
else:
logger.warning(
"pstats is already launched! tutorial is at: "
"https://docs.panda3d.org/1.10/python/optimization/using-pstats"
)

# Setup onscreen render
if self.global_config["use_render"]:
Expand Down
Loading

0 comments on commit 40afd75

Please sign in to comment.