diff --git a/experiments/test_notebook.ipynb b/experiments/test_notebook.ipynb index 581e331c0e5da9f8e7fe6d75f3d711eddfc73ca4..6e9d00ef29571bbd74716b5ae3632df9ff3e8e94 100644 --- a/experiments/test_notebook.ipynb +++ b/experiments/test_notebook.ipynb @@ -1,958 +1,527 @@ { - "cells": [ - { - "cell_type": "markdown", - "id": "34460db1", - "metadata": {}, - "source": [ - "# Creating a new planner in nuPlan <a name=\"introduction\"></a>\n" - ] - }, - { - "cell_type": "markdown", - "id": "f0189156", - "metadata": {}, - "source": [ - "## Setup" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "id": "373ffd1c", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/tmp/ipykernel_49264/4095267831.py:5: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display\n", - " from IPython.core.display import display, HTML\n" - ] - } - ], - "source": [ - "# Useful imports\n", - "import asyncio\n", - "import os\n", - "import hydra\n", - "import logging\n", - "import nest_asyncio\n", - "from IPython.core.display import display, HTML\n", - "from bokeh.io import output_notebook" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "id": "13c00121", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "<div class=\"bk-root\">\n", - " <a href=\"https://bokeh.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n", - " <span id=\"32674\">Loading BokehJS ...</span>\n", - " </div>\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/javascript": "(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n // Clean up Bokeh references\n if (id != null && id in Bokeh.index) {\n Bokeh.index[id].model.document.clear();\n delete Bokeh.index[id];\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim();\n if (id in Bokeh.index) {\n Bokeh.index[id].model.document.clear();\n delete Bokeh.index[id];\n }\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n const el = document.getElementById(\"32674\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.3.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\nif (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(\"32674\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", - "application/vnd.bokehjs_load.v0+json": "" - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "<style>.output_result { max-width:100% !important; }</style>" - ], - "text/plain": [ - "<IPython.core.display.HTML object>" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "<style>.container { width:100% !important; }</style>" - ], - "text/plain": [ - "<IPython.core.display.HTML object>" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "nest_asyncio.apply()\n", - "output_notebook()\n", - "display(HTML(\"<style>.output_result { max-width:100% !important; }</style>\"))\n", - "display(HTML(\"<style>.container { width:100% !important; }</style>\"))" - ] - }, - { - "cell_type": "markdown", - "id": "128b0d15", - "metadata": {}, - "source": [ - "# Simulating the planner <a name=\"simulation\"></a>" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "id": "aff526c3", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "env: NUPLAN_DATA_ROOT=../../../datasets/nuplan/dataset\n", - "env: NUPLAN_MAPS_ROOT=../../data/nuplan/maps\n", - "env: NUPLAN_EXP_ROOT=../../data/nuplan/exp\n", - "env: NUPLAN_DEVKIT_ROOT=../../nuplan-devkit/\n" - ] - }, - { - "data": { - "text/plain": [ - "'/home/ehdykhne/nuplan-devkit/experiments'" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "%env NUPLAN_DATA_ROOT=../../../datasets/nuplan/dataset\n", - "%env NUPLAN_MAPS_ROOT=../../data/nuplan/maps\n", - "%env NUPLAN_EXP_ROOT=../../data/nuplan/exp\n", - "%env NUPLAN_DEVKIT_ROOT=../../nuplan-devkit/\n", - "\n", - "%pwd" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [], - "source": [ - "import hydra\n", - "import pytorch_lightning as pl\n", - "from omegaconf import DictConfig, OmegaConf\n", - "\n", - "from nuplan.common.utils.s3_utils import is_s3_path\n", - "from nuplan.planning.script.builders.simulation_builder import build_simulations\n", - "from nuplan.planning.script.builders.simulation_callback_builder import (\n", - " build_callbacks_worker,\n", - " build_simulation_callbacks,\n", - ")\n", - "from nuplan.planning.script.utils import (\n", - " run_runners,\n", - " set_default_path,\n", - " set_up_common_builder,\n", - ")\n", - "from nuplan.planning.simulation.planner.abstract_planner import AbstractPlanner\n", - "\n", - "logging.basicConfig(level=logging.INFO)\n", - "logger = logging.getLogger(__name__)\n", - "\n", - "# If set, use the env. variable to overwrite the default dataset and experiment paths\n", - "set_default_path()\n", - "\n", - "# If set, use the env. variable to overwrite the Hydra config\n", - "CONFIG_PATH = os.getenv(\"NUPLAN_HYDRA_CONFIG_PATH\", \"config/simulation\")\n", - "\n", - "if os.environ.get(\"NUPLAN_HYDRA_CONFIG_PATH\") is not None:\n", - " CONFIG_PATH = os.path.join(\"../../../../\", CONFIG_PATH)\n", - "\n", - "if os.path.basename(CONFIG_PATH) != \"simulation\":\n", - " CONFIG_PATH = os.path.join(CONFIG_PATH, \"simulation\")\n", - "CONFIG_NAME = \"default_simulation\"" - ] - }, - { - "cell_type": "markdown", - "id": "db337ceb", - "metadata": {}, - "source": [ - "## Prepare the simulation config" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "id": "11b08c6d", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "default_simulation\n" - ] - } - ], - "source": [ - "from tutorials.utils.tutorial_utils import construct_simulation_hydra_paths\n", - "\n", - "# Location of paths with all simulation configs\n", - "BASE_CONFIG_PATH = os.path.join(\n", - " os.getenv(\"NUPLAN_TUTORIAL_PATH\", \"\"), \"../nuplan/planning/script\"\n", - ")\n", - "simulation_hydra_paths = construct_simulation_hydra_paths(BASE_CONFIG_PATH)\n", - "\n", - "# Create a temporary directory to store the simulation artifacts\n", - "\n", - "scenario_types = [\n", - " # \"accelerating_at_traffic_light_with_lead\",\n", - " # \"crossed_by_bike\",\n", - " # \"crossed_by_vehicle\",\n", - " # \"on_intersection\",\n", - " # \"on_stopline_crosswalk\",\n", - " # \"on_stopline_stop_sign\",\n", - " # \"on_stopline_traffic_light\",\n", - " # \"on_traffic_light_intersection\",\n", - " # \"starting_protected_cross_turn\",\n", - " # \"starting_protected_noncross_turn\",\n", - " # \"starting_right_turn\",\n", - " # \"starting_straight_stop_sign_intersection_traversal\",\n", - " # \"starting_straight_traffic_light_intersection_traversal\",\n", - " # \"starting_u_turn\",\n", - " # \"starting_unprotected_cross_turn\",\n", - " # \"starting_unprotected_noncross_turn\",\n", - " # \"stationary_at_crosswalk\",\n", - " # \"stationary_at_traffic_light_with_lead\",\n", - " # \"stationary_at_traffic_light_without_lead\",\n", - " # \"traversing_crosswalk\",\n", - " # \"traversing_intersection\",\n", - " \"traversing_traffic_light_intersection\",\n", - "]\n", - "scenario_builder = \"val\" # [nuplan (uses trainval), nuplan_mini, test, val, train_boston, train_pittsburgh, train_singapore]\n", - "DATASET_PARAMS = [\n", - " f\"scenario_builder={scenario_builder}\",\n", - " \"scenario_filter=all_scenarios\", # [all_scenarios, val14_split]\n", - " f\"scenario_filter.scenario_types={scenario_types}\", # there are 70 scenario types in the trainingset and 58 in the validation set including \"unknown\" which make up the majority\n", - " # \"scenario_filter.ego_displacement_minimum_m=10\", # use scenarios where the ego vehicle moves at least 10m\n", - " # 'scenario_filter.remove_invalid_goals=true', # remove scenarios where the goal is not invalid\n", - " # 'scenario_filter.ego_start_speed_threshold=5', # Exclusive threshold that the ego's speed must rise above (meters per second) for scenario to be kept\n", - " # 'scenario_filter.stop_speed_threshold=10', # Inclusive threshold that the ego's speed must fall below (meters per second) for scenario to be kept:\n", - " \"scenario_filter.map_names=[us-pa-pittsburgh-hazelwood]\", # [sg-one-north, us-ma-boston, us-pa-pittsburgh-hazelwood, us-nv-las-vegas-strip]\n", - " # \"scenario_filter.num_scenarios_per_type=200\", # use 10 scenarios per scenario type\n", - " \"scenario_filter.scenario_tokens=['60e03a4199bd5fbd']\", # List of scenarios to include (token)\n", - " # 'scenario_filter.log_names=[\"2021.08.24.18.07.48_veh-45_01504_01722\"]', # specific scenrios to simulate\n", - " \"scenario_filter.limit_total_scenarios=0.05\", # use n total scenarios if int, or if float smaller than 1, use n as a fraction of total scenarios (changes sampling frequency, unchanged leaves the frequency at 20Hz)\n", - "]\n", - "ckpt_dir = \"/home/ehdykhne/nuplan-devkit/experiments/pretrained_checkpoints/urbandriver_checkpoint.ckpt\"\n", - "# Initialize configuration management system\n", - "hydra.core.global_hydra.GlobalHydra.instance().clear() # reinitialize hydra if already initialized\n", - "hydra.initialize(config_path=simulation_hydra_paths.config_path)\n", - "\n", - "# Compose the configuration\n", - "print(simulation_hydra_paths.config_name)\n", - "cfg = hydra.compose(\n", - " config_name=simulation_hydra_paths.config_name,\n", - " overrides=[\n", - " \"+simulation=closed_loop_multiagent\",\n", - " \"model=urban_driver_open_loop_model\",\n", - " \"planner=ml_planner\",\n", - " # f\"planner.pdm_hybrid_planner.checkpoint_path={ckpt_dir}\" ,\n", - " \"planner.ml_planner.model_config=${model}\",\n", - " f\"planner.ml_planner.checkpoint_path={ckpt_dir}\",\n", - " \"observation.model_config=${model}\",\n", - " f\"observation.checkpoint_path={ckpt_dir}\",\n", - " \"worker=sequential\",\n", - " \"+occlusion=true\",\n", - " \"+occlusion.manager_type=wedge\", # options: [range, shadow, wedge]\n", - " \"hydra.searchpath=[pkg://tuplan_garage.planning.script.config.common, pkg://tuplan_garage.planning.script.config.simulation, pkg://nuplan.planning.script.config.common, pkg://nuplan.planning.script.experiments]\",\n", - " *DATASET_PARAMS,\n", - " ],\n", - ")\n", - "\n", - "output_folder = cfg.output_dir" - ] - }, - { - "cell_type": "markdown", - "id": "88231b74", - "metadata": {}, - "source": [ - "## Launch simulation (within the notebook)" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "id": "161cc166", - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Global seed set to 0\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2023-12-20 03:28:05,856 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/main_callback_builder.py:20} Building MultiMainCallback...\n", - "2023-12-20 03:28:05,876 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/main_callback_builder.py:35} Building MultiMainCallback: 4...DONE!\n", - "2023-12-20 03:28:06,031 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/worker_pool_builder.py:19} Building WorkerPool...\n", - "2023-12-20 03:28:06,031 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/utils/multithreading/worker_pool.py:101} Worker: Sequential\n", - "2023-12-20 03:28:06,031 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/utils/multithreading/worker_pool.py:102} Number of nodes: 1\n", - "Number of CPUs per node: 1\n", - "Number of GPUs per node: 0\n", - "Number of threads across all nodes: 1\n", - "2023-12-20 03:28:06,031 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/worker_pool_builder.py:27} Building WorkerPool...DONE!\n", - "2023-12-20 03:28:06,032 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/folder_builder.py:32} Building experiment folders...\n", - "2023-12-20 03:28:06,032 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/folder_builder.py:35} \n", - "\n", - "\tFolder where all results are stored: ../../data/nuplan/exp/exp/simulation/closed_loop_multiagent/2023.12.20.03.28.05\n", - "\n", - "2023-12-20 03:28:06,033 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/folder_builder.py:70} Building experiment folders...DONE!\n", - "2023-12-20 03:28:06,033 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/simulation_callback_builder.py:52} Building AbstractCallback...\n", - "2023-12-20 03:28:06,033 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/simulation_callback_builder.py:68} Building AbstractCallback: 0...DONE!\n", - "2023-12-20 03:28:06,033 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:49} Building simulations...\n", - "2023-12-20 03:28:06,033 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:55} Extracting scenarios...\n", - "2023-12-20 03:28:06,033 INFO {/home/ehdykhne/nuplan-devkit/nuplan/common/utils/distributed_scenario_filter.py:83} Building Scenarios in mode DistributedMode.SINGLE_NODE\n", - "2023-12-20 03:28:06,033 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/scenario_building_builder.py:18} Building AbstractScenarioBuilder...\n", - "2023-12-20 03:28:06,050 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/scenario_building_builder.py:21} Building AbstractScenarioBuilder...DONE!\n", - "2023-12-20 03:28:06,050 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/scenario_filter_builder.py:35} Building ScenarioFilter...\n", - "2023-12-20 03:28:06,051 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/scenario_filter_builder.py:44} Building ScenarioFilter...DONE!\n", - "2023-12-20 03:28:06,468 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:76} Building metric engines...\n", - "2023-12-20 03:28:06,484 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:78} Building metric engines...DONE\n", - "2023-12-20 03:28:06,485 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:82} Building simulations from 1 scenarios...\n" - ] - }, - { - "ename": "MissingMandatoryValue", - "evalue": "Missing mandatory value: observation.model_config\n full_key: observation.model_config\n object_type=dict", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mMissingMandatoryValue\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m/home/ehdykhne/nuplan-devkit/experiments/test_notebook.ipynb Cell 11\u001b[0m line \u001b[0;36m9\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwisedave.eng.uwaterloo.ca/home/ehdykhne/nuplan-devkit/experiments/test_notebook.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=1'>2</a>\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mnuplan\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mcommon\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mactor_state\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mtracked_objects_types\u001b[39;00m \u001b[39mimport\u001b[39;00m (\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwisedave.eng.uwaterloo.ca/home/ehdykhne/nuplan-devkit/experiments/test_notebook.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=2'>3</a>\u001b[0m AGENT_TYPES,\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwisedave.eng.uwaterloo.ca/home/ehdykhne/nuplan-devkit/experiments/test_notebook.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=3'>4</a>\u001b[0m STATIC_OBJECT_TYPES,\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwisedave.eng.uwaterloo.ca/home/ehdykhne/nuplan-devkit/experiments/test_notebook.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=4'>5</a>\u001b[0m TrackedObjectType,\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwisedave.eng.uwaterloo.ca/home/ehdykhne/nuplan-devkit/experiments/test_notebook.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=5'>6</a>\u001b[0m )\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwisedave.eng.uwaterloo.ca/home/ehdykhne/nuplan-devkit/experiments/test_notebook.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'>8</a>\u001b[0m \u001b[39m# Run the simulation loop (real-time visualization not yet supported, see next section for visualization)\u001b[39;00m\n\u001b[0;32m----> <a href='vscode-notebook-cell://ssh-remote%2Bwisedave.eng.uwaterloo.ca/home/ehdykhne/nuplan-devkit/experiments/test_notebook.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=8'>9</a>\u001b[0m runners, common_builder, cfg \u001b[39m=\u001b[39m build_simulation_runners(cfg)\n\u001b[1;32m <a href='vscode-notebook-cell://ssh-remote%2Bwisedave.eng.uwaterloo.ca/home/ehdykhne/nuplan-devkit/experiments/test_notebook.ipynb#X12sdnNjb2RlLXJlbW90ZQ%3D%3D?line=9'>10</a>\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39mlen\u001b[39m(runners))\n", - "File \u001b[0;32m~/nuplan-devkit/nuplan/planning/script/run_simulation.py:59\u001b[0m, in \u001b[0;36mbuild_simulation_runners\u001b[0;34m(cfg, planners)\u001b[0m\n\u001b[1;32m 56\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39misinstance\u001b[39m(planners, AbstractPlanner):\n\u001b[1;32m 57\u001b[0m planners \u001b[39m=\u001b[39m [planners]\n\u001b[0;32m---> 59\u001b[0m runners \u001b[39m=\u001b[39m build_simulations(\n\u001b[1;32m 60\u001b[0m cfg\u001b[39m=\u001b[39;49mcfg,\n\u001b[1;32m 61\u001b[0m callbacks\u001b[39m=\u001b[39;49mcallbacks,\n\u001b[1;32m 62\u001b[0m worker\u001b[39m=\u001b[39;49mcommon_builder\u001b[39m.\u001b[39;49mworker,\n\u001b[1;32m 63\u001b[0m pre_built_planners\u001b[39m=\u001b[39;49mplanners,\n\u001b[1;32m 64\u001b[0m callbacks_worker\u001b[39m=\u001b[39;49mcallbacks_worker_pool,\n\u001b[1;32m 65\u001b[0m )\n\u001b[1;32m 67\u001b[0m \u001b[39mif\u001b[39;00m common_builder\u001b[39m.\u001b[39mprofiler:\n\u001b[1;32m 68\u001b[0m \u001b[39m# Stop simulation construction profiling\u001b[39;00m\n\u001b[1;32m 69\u001b[0m common_builder\u001b[39m.\u001b[39mprofiler\u001b[39m.\u001b[39msave_profiler(profiler_name)\n", - "File \u001b[0;32m~/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:106\u001b[0m, in \u001b[0;36mbuild_simulations\u001b[0;34m(cfg, worker, callbacks, callbacks_worker, pre_built_planners)\u001b[0m\n\u001b[1;32m 101\u001b[0m simulation_time_controller: AbstractSimulationTimeController \u001b[39m=\u001b[39m instantiate(\n\u001b[1;32m 102\u001b[0m cfg\u001b[39m.\u001b[39msimulation_time_controller, scenario\u001b[39m=\u001b[39mscenario\n\u001b[1;32m 103\u001b[0m )\n\u001b[1;32m 105\u001b[0m \u001b[39m# Perception\u001b[39;00m\n\u001b[0;32m--> 106\u001b[0m observations: AbstractObservation \u001b[39m=\u001b[39m build_observations(cfg\u001b[39m.\u001b[39;49mobservation, scenario\u001b[39m=\u001b[39;49mscenario)\n\u001b[1;32m 108\u001b[0m \u001b[39m# Occlusions\u001b[39;00m\n\u001b[1;32m 109\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39m'\u001b[39m\u001b[39mocclusion\u001b[39m\u001b[39m'\u001b[39m \u001b[39min\u001b[39;00m cfg\u001b[39m.\u001b[39mkeys() \u001b[39mand\u001b[39;00m cfg\u001b[39m.\u001b[39mocclusion:\n", - "File \u001b[0;32m~/nuplan-devkit/nuplan/planning/script/builders/observation_builder.py:36\u001b[0m, in \u001b[0;36mbuild_observations\u001b[0;34m(observation_cfg, scenario)\u001b[0m\n\u001b[1;32m 34\u001b[0m observation: AbstractObservation \u001b[39m=\u001b[39m instantiate(config, model\u001b[39m=\u001b[39mmodel, scenario\u001b[39m=\u001b[39mscenario)\n\u001b[1;32m 35\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m---> 36\u001b[0m observation \u001b[39m=\u001b[39m cast(AbstractObservation, instantiate(observation_cfg, scenario\u001b[39m=\u001b[39;49mscenario))\n\u001b[1;32m 38\u001b[0m \u001b[39mreturn\u001b[39;00m observation\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/hydra/_internal/instantiate/_instantiate2.py:180\u001b[0m, in \u001b[0;36minstantiate\u001b[0;34m(config, *args, **kwargs)\u001b[0m\n\u001b[1;32m 177\u001b[0m _recursive_ \u001b[39m=\u001b[39m config\u001b[39m.\u001b[39mpop(_Keys\u001b[39m.\u001b[39mRECURSIVE, \u001b[39mTrue\u001b[39;00m)\n\u001b[1;32m 178\u001b[0m _convert_ \u001b[39m=\u001b[39m config\u001b[39m.\u001b[39mpop(_Keys\u001b[39m.\u001b[39mCONVERT, ConvertMode\u001b[39m.\u001b[39mNONE)\n\u001b[0;32m--> 180\u001b[0m \u001b[39mreturn\u001b[39;00m instantiate_node(config, \u001b[39m*\u001b[39;49margs, recursive\u001b[39m=\u001b[39;49m_recursive_, convert\u001b[39m=\u001b[39;49m_convert_)\n\u001b[1;32m 181\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 182\u001b[0m \u001b[39mraise\u001b[39;00m InstantiationException(\n\u001b[1;32m 183\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mTop level config has to be OmegaConf DictConfig, plain dict, or a Structured Config class or instance\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 184\u001b[0m )\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/hydra/_internal/instantiate/_instantiate2.py:242\u001b[0m, in \u001b[0;36minstantiate_node\u001b[0;34m(node, convert, recursive, *args)\u001b[0m\n\u001b[1;32m 240\u001b[0m target \u001b[39m=\u001b[39m _resolve_target(node\u001b[39m.\u001b[39mget(_Keys\u001b[39m.\u001b[39mTARGET))\n\u001b[1;32m 241\u001b[0m kwargs \u001b[39m=\u001b[39m {}\n\u001b[0;32m--> 242\u001b[0m \u001b[39mfor\u001b[39;00m key, value \u001b[39min\u001b[39;00m node\u001b[39m.\u001b[39;49mitems():\n\u001b[1;32m 243\u001b[0m \u001b[39mif\u001b[39;00m key \u001b[39mnot\u001b[39;00m \u001b[39min\u001b[39;00m exclude_keys:\n\u001b[1;32m 244\u001b[0m \u001b[39mif\u001b[39;00m recursive:\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/omegaconf/dictconfig.py:548\u001b[0m, in \u001b[0;36mDictConfig.items\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 547\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mitems\u001b[39m(\u001b[39mself\u001b[39m) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m AbstractSet[Tuple[DictKeyType, Any]]:\n\u001b[0;32m--> 548\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mitems_ex(resolve\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m, keys\u001b[39m=\u001b[39;49m\u001b[39mNone\u001b[39;49;00m)\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/omegaconf/dictconfig.py:574\u001b[0m, in \u001b[0;36mDictConfig.items_ex\u001b[0;34m(self, resolve, keys)\u001b[0m\n\u001b[1;32m 572\u001b[0m \u001b[39mfor\u001b[39;00m key \u001b[39min\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mkeys():\n\u001b[1;32m 573\u001b[0m \u001b[39mif\u001b[39;00m resolve:\n\u001b[0;32m--> 574\u001b[0m value \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m[key]\n\u001b[1;32m 575\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 576\u001b[0m value \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m\u001b[39m__dict__\u001b[39m[\u001b[39m\"\u001b[39m\u001b[39m_content\u001b[39m\u001b[39m\"\u001b[39m][key]\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/omegaconf/dictconfig.py:373\u001b[0m, in \u001b[0;36mDictConfig.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 369\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_format_and_raise(\n\u001b[1;32m 370\u001b[0m key\u001b[39m=\u001b[39mkey, value\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m, cause\u001b[39m=\u001b[39me, type_override\u001b[39m=\u001b[39mConfigKeyError\n\u001b[1;32m 371\u001b[0m )\n\u001b[1;32m 372\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mException\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n\u001b[0;32m--> 373\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_format_and_raise(key\u001b[39m=\u001b[39;49mkey, value\u001b[39m=\u001b[39;49m\u001b[39mNone\u001b[39;49;00m, cause\u001b[39m=\u001b[39;49me)\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/omegaconf/base.py:190\u001b[0m, in \u001b[0;36mNode._format_and_raise\u001b[0;34m(self, key, value, cause, type_override)\u001b[0m\n\u001b[1;32m 187\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m_format_and_raise\u001b[39m(\n\u001b[1;32m 188\u001b[0m \u001b[39mself\u001b[39m, key: Any, value: Any, cause: \u001b[39mException\u001b[39;00m, type_override: Any \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m 189\u001b[0m ) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m--> 190\u001b[0m format_and_raise(\n\u001b[1;32m 191\u001b[0m node\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m,\n\u001b[1;32m 192\u001b[0m key\u001b[39m=\u001b[39;49mkey,\n\u001b[1;32m 193\u001b[0m value\u001b[39m=\u001b[39;49mvalue,\n\u001b[1;32m 194\u001b[0m msg\u001b[39m=\u001b[39;49m\u001b[39mstr\u001b[39;49m(cause),\n\u001b[1;32m 195\u001b[0m cause\u001b[39m=\u001b[39;49mcause,\n\u001b[1;32m 196\u001b[0m type_override\u001b[39m=\u001b[39;49mtype_override,\n\u001b[1;32m 197\u001b[0m )\n\u001b[1;32m 198\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mFalse\u001b[39;00m\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/omegaconf/_utils.py:821\u001b[0m, in \u001b[0;36mformat_and_raise\u001b[0;34m(node, key, value, msg, cause, type_override)\u001b[0m\n\u001b[1;32m 818\u001b[0m ex\u001b[39m.\u001b[39mref_type \u001b[39m=\u001b[39m ref_type\n\u001b[1;32m 819\u001b[0m ex\u001b[39m.\u001b[39mref_type_str \u001b[39m=\u001b[39m ref_type_str\n\u001b[0;32m--> 821\u001b[0m _raise(ex, cause)\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/omegaconf/_utils.py:719\u001b[0m, in \u001b[0;36m_raise\u001b[0;34m(ex, cause)\u001b[0m\n\u001b[1;32m 717\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 718\u001b[0m ex\u001b[39m.\u001b[39m__cause__ \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[0;32m--> 719\u001b[0m \u001b[39mraise\u001b[39;00m ex\u001b[39m.\u001b[39mwith_traceback(sys\u001b[39m.\u001b[39mexc_info()[\u001b[39m2\u001b[39m])\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/omegaconf/dictconfig.py:367\u001b[0m, in \u001b[0;36mDictConfig.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 360\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 361\u001b[0m \u001b[39mAllow map style access\u001b[39;00m\n\u001b[1;32m 362\u001b[0m \u001b[39m:param key:\u001b[39;00m\n\u001b[1;32m 363\u001b[0m \u001b[39m:return:\u001b[39;00m\n\u001b[1;32m 364\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 366\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 367\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_get_impl(key\u001b[39m=\u001b[39;49mkey, default_value\u001b[39m=\u001b[39;49m_DEFAULT_MARKER_)\n\u001b[1;32m 368\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mAttributeError\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n\u001b[1;32m 369\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_format_and_raise(\n\u001b[1;32m 370\u001b[0m key\u001b[39m=\u001b[39mkey, value\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m, cause\u001b[39m=\u001b[39me, type_override\u001b[39m=\u001b[39mConfigKeyError\n\u001b[1;32m 371\u001b[0m )\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/omegaconf/dictconfig.py:445\u001b[0m, in \u001b[0;36mDictConfig._get_impl\u001b[0;34m(self, key, default_value)\u001b[0m\n\u001b[1;32m 443\u001b[0m \u001b[39mraise\u001b[39;00m\n\u001b[1;32m 444\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39misinstance\u001b[39m(node, Node)\n\u001b[0;32m--> 445\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_resolve_with_default(\n\u001b[1;32m 446\u001b[0m key\u001b[39m=\u001b[39;49mkey, value\u001b[39m=\u001b[39;49mnode, default_value\u001b[39m=\u001b[39;49mdefault_value\n\u001b[1;32m 447\u001b[0m )\n", - "File \u001b[0;32m~/miniconda3/envs/nuplan/lib/python3.9/site-packages/omegaconf/basecontainer.py:58\u001b[0m, in \u001b[0;36mBaseContainer._resolve_with_default\u001b[0;34m(self, key, value, default_value)\u001b[0m\n\u001b[1;32m 56\u001b[0m \u001b[39mif\u001b[39;00m default_value \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m _DEFAULT_MARKER_:\n\u001b[1;32m 57\u001b[0m \u001b[39mreturn\u001b[39;00m default_value\n\u001b[0;32m---> 58\u001b[0m \u001b[39mraise\u001b[39;00m MissingMandatoryValue(\u001b[39m\"\u001b[39m\u001b[39mMissing mandatory value: $FULL_KEY\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m 60\u001b[0m resolved_node \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_maybe_resolve_interpolation(\n\u001b[1;32m 61\u001b[0m parent\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m,\n\u001b[1;32m 62\u001b[0m key\u001b[39m=\u001b[39mkey,\n\u001b[1;32m 63\u001b[0m value\u001b[39m=\u001b[39mvalue,\n\u001b[1;32m 64\u001b[0m throw_on_resolution_failure\u001b[39m=\u001b[39m\u001b[39mTrue\u001b[39;00m,\n\u001b[1;32m 65\u001b[0m )\n\u001b[1;32m 67\u001b[0m \u001b[39mreturn\u001b[39;00m _get_value(resolved_node)\n", - "\u001b[0;31mMissingMandatoryValue\u001b[0m: Missing mandatory value: observation.model_config\n full_key: observation.model_config\n object_type=dict" - ] - } - ], - "source": [ - "from nuplan.planning.script.run_simulation import build_simulation_runners\n", - "from nuplan.common.actor_state.tracked_objects_types import (\n", - " AGENT_TYPES,\n", - " STATIC_OBJECT_TYPES,\n", - " TrackedObjectType,\n", - ")\n", - "\n", - "# Run the simulation loop (real-time visualization not yet supported, see next section for visualization)\n", - "runners, common_builder, cfg = build_simulation_runners(cfg)\n", - "print(len(runners))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "223284d4", - "metadata": {}, - "outputs": [], - "source": [ - "runner = runners[0]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "907ad940", - "metadata": {}, - "outputs": [], - "source": [ - "from nuplan.common.actor_state.agent import Agent\n", - "from nuplan.common.actor_state.oriented_box import OrientedBox\n", - "from nuplan.common.actor_state.scene_object import SceneObjectMetadata\n", - "from nuplan.common.actor_state.state_representation import StateSE2, StateVector2D\n", - "\n", - "inserted_agent = Agent(\n", - " tracked_object_type=TrackedObjectType.VEHICLE,\n", - " oriented_box=OrientedBox(StateSE2(588006, 4475692, 3 * 3.14 / 2), 5, 2, 2),\n", - " velocity=StateVector2D(0, 0),\n", - " metadata=SceneObjectMetadata(1623707858950113, \"inserted\", -2, \"inserted\"),\n", - " angular_velocity=0.0,\n", - ")\n", - "\n", - "inserted_goal = StateSE2(664433, 3997200, -3.14 / 2)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "90b79421", - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "SimulationIteration(time_point=TimePoint(time_us=1629835531599647), index=0)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835531699630), index=1)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835531799606), index=2)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835531899580), index=3)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835531999558), index=4)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835532099540), index=5)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835532199531), index=6)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835532299528), index=7)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835532399538), index=8)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835532499556), index=9)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835532599591), index=10)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835532699635), index=11)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835532799685), index=12)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835532899739), index=13)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835532999792), index=14)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835533099829), index=15)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835533199847), index=16)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835533299851), index=17)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835533399850), index=18)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835533499841), index=19)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835533599833), index=20)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835533699826), index=21)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835533799821), index=22)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835533899806), index=23)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835533999786), index=24)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835534099765), index=25)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835534199752), index=26)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835534299749), index=27)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835534399745), index=28)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835534499734), index=29)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835534599723), index=30)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835534699724), index=31)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835534799744), index=32)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835534899772), index=33)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835534999804), index=34)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835535099830), index=35)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835535199858), index=36)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835535299888), index=37)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835535399911), index=38)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835535499938), index=39)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835535599965), index=40)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835535699993), index=41)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835535800025), index=42)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835535900058), index=43)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835536000094), index=44)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835536100125), index=45)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835536200154), index=46)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835536300175), index=47)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835536400178), index=48)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835536500171), index=49)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835536600149), index=50)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835536700130), index=51)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835536800113), index=52)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835536900110), index=53)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537000120), index=54)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537100121), index=55)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537200104), index=56)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537300060), index=57)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537400002), index=58)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537499934), index=59)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537599859), index=60)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537699780), index=61)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537799705), index=62)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537899628), index=63)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835537999551), index=64)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835538099487), index=65)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835538199452), index=66)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835538299436), index=67)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835538399432), index=68)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835538499436), index=69)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835538599444), index=70)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835538699450), index=71)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835538799450), index=72)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835538899454), index=73)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835538999467), index=74)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835539099487), index=75)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835539199516), index=76)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835539299555), index=77)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835539399609), index=78)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835539499672), index=79)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835539599734), index=80)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835539699783), index=81)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835539799823), index=82)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835539899874), index=83)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835539999925), index=84)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835540099971), index=85)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835540200003), index=86)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835540300020), index=87)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835540400020), index=88)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835540500001), index=89)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835540599971), index=90)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835540699938), index=91)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835540799901), index=92)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835540899866), index=93)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835540999840), index=94)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835541099823), index=95)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835541199809), index=96)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835541299795), index=97)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835541399784), index=98)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835541499773), index=99)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835541599756), index=100)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835541699733), index=101)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835541799723), index=102)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835541899729), index=103)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835541999733), index=104)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835542099733), index=105)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835542199727), index=106)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835542299713), index=107)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835542399695), index=108)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835542499677), index=109)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835542599678), index=110)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835542699684), index=111)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835542799675), index=112)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835542899667), index=113)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835542999662), index=114)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835543099650), index=115)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835543199627), index=116)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835543299613), index=117)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835543399599), index=118)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835543499579), index=119)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835543599557), index=120)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835543699528), index=121)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835543799502), index=122)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835543899471), index=123)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835543999445), index=124)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835544099425), index=125)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835544199410), index=126)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835544299398), index=127)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835544399395), index=128)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835544499410), index=129)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835544599440), index=130)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835544699482), index=131)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835544799526), index=132)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835544899577), index=133)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835544999632), index=134)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835545099698), index=135)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835545199783), index=136)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835545299862), index=137)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835545399937), index=138)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835545500003), index=139)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835545600067), index=140)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835545700134), index=141)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835545800202), index=142)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835545900265), index=143)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835546000325), index=144)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835546100389), index=145)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835546200439), index=146)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835546300467), index=147)\n", - "SimulationIteration(time_point=TimePoint(time_us=1629835546400479), index=148)\n" - ] - } - ], - "source": [ - "runner.simulation.callback.on_simulation_start(runner.simulation.setup)\n", - "\n", - "# Initialize all simulations\n", - "runner._initialize()\n", - "\n", - "while runner.simulation.is_simulation_running():\n", - " if runner.simulation._time_controller.get_iteration().index == 40:\n", - " runner.simulation._observations.add_agent_to_scene(\n", - " inserted_agent, inserted_goal, iteration.time_point\n", - " )\n", - "\n", - " # Execute specific callback\n", - " runner.simulation.callback.on_step_start(runner.simulation.setup, runner.planner)\n", - "\n", - " # Perform step\n", - " planner_input = runner._simulation.get_planner_input()\n", - "\n", - " # Execute specific callback\n", - " runner._simulation.callback.on_planner_start(\n", - " runner.simulation.setup, runner.planner\n", - " )\n", - "\n", - " # Plan path based on all planner's inputs\n", - " trajectory = runner.planner.compute_trajectory(planner_input)\n", - "\n", - " # Propagate simulation based on planner trajectory\n", - " runner._simulation.callback.on_planner_end(\n", - " runner.simulation.setup, runner.planner, trajectory\n", - " )\n", - "\n", - " iteration = runner.simulation._time_controller.get_iteration()\n", - " print(iteration)\n", - " runner.simulation.propagate(trajectory)\n", - "\n", - " # Execute specific callback\n", - " runner.simulation.callback.on_step_end(\n", - " runner.simulation.setup, runner.planner, runner.simulation.history.last()\n", - " )\n", - "\n", - "runner.simulation.callback.on_simulation_end(\n", - " runner.simulation.setup, runner.planner, runner.simulation.history\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e6c22f5f", - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:bokeh.server.server:Starting Bokeh server version 2.4.3 (running on Tornado 6.3.3)\n", - "WARNING:bokeh.server.util:Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. Use non-wildcard values to restrict access explicitly\n", - "INFO:bokeh.server.tornado:User authentication hooks NOT provided (default user enabled)\n" - ] - }, - { - "data": { - "application/vnd.bokehjs_exec.v0+json": "", - "text/html": [ - "<script id=\"1003\">\n", - " (function() {\n", - " const xhr = new XMLHttpRequest()\n", - " xhr.responseType = 'blob';\n", - " xhr.open('GET', \"http://localhost:5007/autoload.js?bokeh-autoload-element=1003&bokeh-absolute-url=http://localhost:5007&resources=none\", true);\n", - " xhr.onload = function (event) {\n", - " const script = document.createElement('script');\n", - " const src = URL.createObjectURL(event.target.response);\n", - " script.src = src;\n", - " document.body.appendChild(script);\n", - " };\n", - " xhr.send();\n", - " })();\n", - "</script>" - ] - }, - "metadata": { - "application/vnd.bokehjs_exec.v0+json": { - "server_id": "4e32f1587dbb4021aa719af2ebd5c66c" - } - }, - "output_type": "display_data" - } - ], - "source": [ - "from tutorials.utils.tutorial_utils import visualize_history\n", - "\n", - "visualize_history(runner.simulation._history, runner.scenario, bokeh_port=5007)" - ] - }, - { - "cell_type": "markdown", - "id": "ee650f8f", - "metadata": {}, - "source": [ - "## Prepare the nuBoard config" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "887a51e2", - "metadata": {}, - "outputs": [], - "source": [ - "# Location of path with all nuBoard configs\n", - "CONFIG_PATH = \"../nuplan/planning/script/config/nuboard\"\n", - "CONFIG_NAME = \"default_nuboard\"\n", - "\n", - "# Initialize configuration management system\n", - "hydra.core.global_hydra.GlobalHydra.instance().clear() # reinitialize hydra if already initialized\n", - "hydra.initialize(config_path=CONFIG_PATH)\n", - "\n", - "# Compose the configuration\n", - "cfg = hydra.compose(\n", - " config_name=CONFIG_NAME,\n", - " overrides=[\n", - " \"scenario_builder=nuplan_mini\", # set the database (same as simulation) used to fetch data for visualization\n", - " f\"simulation_path={[output_folder]}\", # nuboard file path(s), if left empty the user can open the file inside nuBoard\n", - " ],\n", - ")" - ] - }, - { - "cell_type": "markdown", - "id": "f5149ddd", - "metadata": {}, - "source": [ - "## Launch nuBoard (open in new tab - recommended)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "67b67b86", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:bokeh.server.server:Starting Bokeh server version 2.4.3 (running on Tornado 6.3.3)\n", - "WARNING:bokeh.server.util:Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. Use non-wildcard values to restrict access explicitly\n", - "INFO:bokeh.server.tornado:User authentication hooks NOT provided (default user enabled)\n" - ] - }, - { - "data": { - "application/vnd.bokehjs_exec.v0+json": "", - "text/html": [ - "<script id=\"1004\">\n", - " (function() {\n", - " const xhr = new XMLHttpRequest()\n", - " xhr.responseType = 'blob';\n", - " xhr.open('GET', \"http://localhost:5008/autoload.js?bokeh-autoload-element=1004&bokeh-absolute-url=http://localhost:5008&resources=none\", true);\n", - " xhr.onload = function (event) {\n", - " const script = document.createElement('script');\n", - " const src = URL.createObjectURL(event.target.response);\n", - " script.src = src;\n", - " document.body.appendChild(script);\n", - " };\n", - " xhr.send();\n", - " })();\n", - "</script>" - ] - }, - "metadata": { - "application/vnd.bokehjs_exec.v0+json": { - "server_id": "e48d21b8a0bf4c38ae3872f42acd7845" - } - }, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2023-12-20 03:21:53,988 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:53,988 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:53,988 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Error creating dataset. Could not read schema from 'data/nuplan/exp/exp/simulation/open_loop_boxes/2023.12.08.20.13.45/log.txt'. Is this a 'parquet' file?: Could not open Parquet input source 'data/nuplan/exp/exp/simulation/open_loop_boxes/2023.12.08.20.13.45/log.txt': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:53,989 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Error creating dataset. Could not read schema from 'run_sim_closed_loop/training_raster_experiment/train_default_raster/2023.11.14.22.55.23/hparams.yaml'. Is this a 'parquet' file?: Could not open Parquet input source 'run_sim_closed_loop/training_raster_experiment/train_default_raster/2023.11.14.22.55.23/hparams.yaml': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:53,989 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:53,989 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:53,989 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:53,990 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Error creating dataset. Could not read schema from 'pretrained_checkpoints/gc_pgp_checkpoint.ckpt'. Is this a 'parquet' file?: Could not open Parquet input source 'pretrained_checkpoints/gc_pgp_checkpoint.ckpt': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:53,990 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:53,991 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:172} Minimum frame time=0.017 s\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Rendering a scenario: 100%|██████████| 1/1 [00:00<00:00, 16.72it/s]\n", - "WARNING:bokeh.core.validation.check:W-1000 (MISSING_RENDERERS): Plot has no renderers: Figure(id='1006', ...)\n", - "INFO:tornado.access:200 GET / (10.40.112.28) 1064.44ms\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2023-12-20 03:21:55,045 INFO {/home/ehdykhne/miniconda3/envs/nuplan/lib/python3.9/site-packages/tornado/web.py:2344} 200 GET / (10.40.112.28) 1064.44ms\n", - "2023-12-20 03:21:55,045 INFO {/home/ehdykhne/nuplan-devkit/tutorials/utils/tutorial_utils.py:267} Done rendering!\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:tornado.access:101 GET /ws (10.40.112.28) 0.63ms\n", - "INFO:bokeh.server.views.ws:WebSocket connection opened\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2023-12-20 03:21:55,836 INFO {/home/ehdykhne/miniconda3/envs/nuplan/lib/python3.9/site-packages/tornado/web.py:2344} 101 GET /ws (10.40.112.28) 0.63ms\n", - "2023-12-20 03:21:55,838 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:55,839 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:55,839 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Error creating dataset. Could not read schema from 'data/nuplan/exp/exp/simulation/open_loop_boxes/2023.12.08.20.13.45/log.txt'. Is this a 'parquet' file?: Could not open Parquet input source 'data/nuplan/exp/exp/simulation/open_loop_boxes/2023.12.08.20.13.45/log.txt': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:55,839 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Error creating dataset. Could not read schema from 'run_sim_closed_loop/training_raster_experiment/train_default_raster/2023.11.14.22.55.23/hparams.yaml'. Is this a 'parquet' file?: Could not open Parquet input source 'run_sim_closed_loop/training_raster_experiment/train_default_raster/2023.11.14.22.55.23/hparams.yaml': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:55,839 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:55,840 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:55,840 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:55,840 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Error creating dataset. Could not read schema from 'pretrained_checkpoints/gc_pgp_checkpoint.ckpt'. Is this a 'parquet' file?: Could not open Parquet input source 'pretrained_checkpoints/gc_pgp_checkpoint.ckpt': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:55,840 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", - "2023-12-20 03:21:55,842 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:172} Minimum frame time=0.017 s\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Rendering a scenario: 100%|██████████| 1/1 [00:00<00:00, 62.71it/s]\n", - "WARNING:bokeh.core.validation.check:W-1000 (MISSING_RENDERERS): Plot has no renderers: Figure(id='3857', ...)\n", - "INFO:tornado.access:200 GET / (10.40.112.28) 552.37ms\n", - "INFO:bokeh.server.views.ws:ServerConnection created\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2023-12-20 03:21:56,388 INFO {/home/ehdykhne/miniconda3/envs/nuplan/lib/python3.9/site-packages/tornado/web.py:2344} 200 GET / (10.40.112.28) 552.37ms\n", - "2023-12-20 03:21:56,515 INFO {/home/ehdykhne/nuplan-devkit/tutorials/utils/tutorial_utils.py:267} Done rendering!\n", - "2023-12-20 03:22:29,636 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 89\n", - "2023-12-20 03:22:30,035 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 89\n", - "2023-12-20 03:22:36,802 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 98\n", - "2023-12-20 03:22:36,871 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 101\n", - "2023-12-20 03:22:37,039 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 101\n", - "2023-12-20 03:22:37,303 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 106\n", - "2023-12-20 03:22:37,669 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 123\n", - "2023-12-20 03:22:37,869 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 131\n", - "2023-12-20 03:22:37,936 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 134\n", - "2023-12-20 03:22:38,040 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 134\n", - "2023-12-20 03:22:38,119 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 137\n", - "2023-12-20 03:22:38,637 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 128\n", - "2023-12-20 03:22:38,671 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 124\n", - "2023-12-20 03:22:38,722 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 121\n", - "2023-12-20 03:22:38,903 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 116\n", - "2023-12-20 03:22:39,009 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 111\n", - "2023-12-20 03:22:39,040 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 109\n", - "2023-12-20 03:22:39,040 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:902} Processing render queue for frame 109\n", - "2023-12-20 03:22:39,075 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 107\n", - "2023-12-20 03:22:39,136 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 104\n", - "2023-12-20 03:22:39,207 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 101\n", - "2023-12-20 03:22:39,270 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 98\n", - "2023-12-20 03:22:39,336 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 95\n", - "2023-12-20 03:22:39,372 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 93\n", - "2023-12-20 03:22:39,407 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 91\n", - "2023-12-20 03:22:39,441 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 89\n", - "2023-12-20 03:22:39,880 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 65\n", - "2023-12-20 03:22:39,937 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 61\n", - "2023-12-20 03:22:39,941 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 60\n", - "2023-12-20 03:22:39,978 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 57\n", - "2023-12-20 03:22:40,020 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 54\n", - "2023-12-20 03:22:40,040 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:902} Processing render queue for frame 54\n", - "2023-12-20 03:22:42,130 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 101\n", - "2023-12-20 03:22:42,197 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 90\n", - "2023-12-20 03:22:42,245 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 84\n", - "2023-12-20 03:22:42,297 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 77\n", - "2023-12-20 03:22:42,398 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 69\n", - "2023-12-20 03:22:42,447 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 66\n", - "2023-12-20 03:22:42,496 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 63\n", - "2023-12-20 03:22:42,597 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 56\n", - "2023-12-20 03:22:42,646 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 52\n", - "2023-12-20 03:22:42,813 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 39\n", - "2023-12-20 03:22:42,952 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 27\n", - "2023-12-20 03:22:43,018 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 21\n", - "2023-12-20 03:22:43,042 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 21\n", - "2023-12-20 03:22:43,097 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 15\n", - "2023-12-20 03:22:44,043 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 15\n", - "2023-12-20 03:22:44,746 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 2\n", - "2023-12-20 03:22:44,813 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 4\n", - "2023-12-20 03:22:44,914 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 10\n", - "2023-12-20 03:22:44,962 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 15\n", - "2023-12-20 03:22:45,014 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 20\n", - "2023-12-20 03:22:45,043 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:902} Processing render queue for frame 20\n", - "2023-12-20 03:22:45,066 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 24\n", - "2023-12-20 03:22:45,831 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 30\n", - "2023-12-20 03:22:46,044 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 30\n", - "2023-12-20 03:22:46,970 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 10\n", - "2023-12-20 03:22:46,996 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 13\n", - "2023-12-20 03:22:47,044 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 13\n", - "2023-12-20 03:22:47,045 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 17\n", - "2023-12-20 03:22:47,147 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 24\n", - "2023-12-20 03:22:47,249 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 29\n", - "2023-12-20 03:22:47,583 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 33\n", - "2023-12-20 03:22:48,045 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 33\n", - "2023-12-20 03:22:49,548 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 104\n", - "2023-12-20 03:22:50,045 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 104\n", - "2023-12-20 03:22:55,451 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 127\n", - "2023-12-20 03:22:55,530 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 109\n", - "2023-12-20 03:22:56,051 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 109\n", - "2023-12-20 03:22:57,098 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 10\n", - "2023-12-20 03:22:57,164 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 26\n", - "2023-12-20 03:22:57,215 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 34\n", - "2023-12-20 03:22:57,262 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 40\n", - "2023-12-20 03:22:58,052 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 40\n", - "2023-12-20 03:22:59,208 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 139\n", - "2023-12-20 03:22:59,240 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 132\n", - "2023-12-20 03:22:59,271 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 127\n", - "2023-12-20 03:22:59,337 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 121\n", - "2023-12-20 03:22:59,370 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 119\n", - "2023-12-20 03:22:59,405 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 116\n", - "2023-12-20 03:22:59,438 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 113\n", - "2023-12-20 03:22:59,471 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 110\n", - "2023-12-20 03:22:59,505 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 107\n", - "2023-12-20 03:22:59,538 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 104\n", - "2023-12-20 03:22:59,574 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 100\n", - "2023-12-20 03:22:59,605 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 97\n", - "2023-12-20 03:22:59,671 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 92\n", - "2023-12-20 03:22:59,705 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 88\n", - "2023-12-20 03:22:59,742 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 84\n", - "2023-12-20 03:23:00,056 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 84\n", - "2023-12-20 03:23:01,715 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 4\n", - "2023-12-20 03:23:01,846 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 12\n", - "2023-12-20 03:23:02,001 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:575} Frame deferred: 26\n", - "2023-12-20 03:23:02,059 INFO {/home/ehdykhne/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:897} Frame dropped 26\n" - ] - } - ], - "source": [ - "from tutorials.utils.tutorial_utils import visualize_history\n", - "\n", - "visualize_history(runner.simulation._history, runner.scenario, bokeh_port=5008)" - ] - } + "cells": [ + { + "cell_type": "markdown", + "id": "34460db1", + "metadata": {}, + "source": [ + "# Creating a new planner in nuPlan <a name=\"introduction\"></a>\n" + ] + }, + { + "cell_type": "markdown", + "id": "f0189156", + "metadata": {}, + "source": [ + "## Setup" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "373ffd1c", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/tmp/ipykernel_182532/4095267831.py:5: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display\n", + " from IPython.core.display import display, HTML\n" + ] + } + ], + "source": [ + "# Useful imports\n", + "import os\n", + "import hydra\n", + "import nest_asyncio\n", + "from IPython.core.display import display, HTML\n", + "from bokeh.io import output_notebook\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "13c00121", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "<div class=\"bk-root\">\n", + " <a href=\"https://bokeh.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n", + " <span id=\"1001\">Loading BokehJS ...</span>\n", + " </div>\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/javascript": "(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n // Clean up Bokeh references\n if (id != null && id in Bokeh.index) {\n Bokeh.index[id].model.document.clear();\n delete Bokeh.index[id];\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim();\n if (id in Bokeh.index) {\n Bokeh.index[id].model.document.clear();\n delete Bokeh.index[id];\n }\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n const el = document.getElementById(\"1001\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.3.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\nif (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", + "application/vnd.bokehjs_load.v0+json": "" + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "<style>.output_result { max-width:100% !important; }</style>" ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.18" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} \ No newline at end of file + "text/plain": [ + "<IPython.core.display.HTML object>" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "<style>.container { width:100% !important; }</style>" + ], + "text/plain": [ + "<IPython.core.display.HTML object>" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "nest_asyncio.apply()\n", + "output_notebook()\n", + "display(HTML(\"<style>.output_result { max-width:100% !important; }</style>\"))\n", + "display(HTML(\"<style>.container { width:100% !important; }</style>\"))" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "39408ef5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'/media/sacardoz/Storage/nuplan-devkit/experiments'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%pwd" + ] + }, + { + "cell_type": "markdown", + "id": "128b0d15", + "metadata": {}, + "source": [ + "# Simulating the planner <a name=\"simulation\"></a>" + ] + }, + { + "cell_type": "markdown", + "id": "db337ceb", + "metadata": {}, + "source": [ + "## Prepare the simulation config" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "11b08c6d", + "metadata": {}, + "outputs": [], + "source": [ + "from tutorials.utils.tutorial_utils import construct_simulation_hydra_paths\n", + "\n", + "# Location of paths with all simulation configs\n", + "BASE_CONFIG_PATH = os.path.join(os.getenv('NUPLAN_TUTORIAL_PATH', ''), '../nuplan/planning/script')\n", + "simulation_hydra_paths = construct_simulation_hydra_paths(BASE_CONFIG_PATH)\n", + "\n", + "# Create a temporary directory to store the simulation artifacts\n", + "\n", + "DATASET_PARAMS = [\n", + " 'scenario_builder=nuplan_mini', # use nuplan mini database (2.5h of 8 autolabeled logs in Las Vegas)\n", + " 'scenario_filter=one_continuous_log', # simulate only one log\n", + " \"scenario_filter.log_names=['2021.06.14.16.48.02_veh-12_04057_04438']\",\n", + " 'scenario_filter.limit_total_scenarios=1', # use 1 total scenarios\n", + "]\n", + "ckpt_dir = '/home/sacardoz/checkpoints/urbandriver_checkpoint.ckpt'\n", + "hybrid_ckpt = '/home/sacardoz/checkpoints/pdm_offset_checkpoint.ckpt'\n", + "#'/home/sacardoz/checkpoints/urbandriver_checkpoint.ckpt'\n", + "#\"/home/sacardoz/tutorial_vector_framework/training_simple_vector_experiment/train_default_simple_vector/2023.11.23.09.55.21/best_model/epoch.ckpt\"\n", + "#\"/home/sacardoz/training_raster_experiment/train_default_raster/2023.11.23.07.36.36/best_model/epoch.ckpt\"\n", + "# Initialize configuration management system\n", + "hydra.core.global_hydra.GlobalHydra.instance().clear() # reinitialize hydra if already initialized\n", + "hydra.initialize(config_path=simulation_hydra_paths.config_path)\n", + "\n", + "# Compose the configuration\n", + "cfg = hydra.compose(config_name=simulation_hydra_paths.config_name, overrides=[\n", + " '+simulation=closed_loop_multiagent',\n", + " 'model=urban_driver_open_loop_model',\n", + " 'planner=pdm_hybrid_planner',\n", + " f\"planner.pdm_hybrid_planner.checkpoint_path={hybrid_ckpt}\" ,\n", + " 'observation.model_config=${model}',\n", + " f'observation.checkpoint_path={ckpt_dir}',\n", + " f'observation.planner_type=pdm_hybrid',\n", + " f'observation.pdm_hybrid_ckpt={hybrid_ckpt}',\n", + " f'observation.occlusions=true',\n", + " 'worker=sequential',\n", + " '+occlusion=true',\n", + " '+occlusion.manager_type=wedge', #options: [range, shadow, wedge]\n", + " \"hydra.searchpath=[pkg://tuplan_garage.planning.script.config.common, pkg://tuplan_garage.planning.script.config.simulation, pkg://nuplan.planning.script.config.common, pkg://nuplan.planning.script.experiments]\",\n", + " *DATASET_PARAMS,\n", + "])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "161cc166", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Global seed set to 0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2023-12-22 01:30:59,903 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/main_callback_builder.py:20} Building MultiMainCallback...\n", + "2023-12-22 01:30:59,903 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/main_callback_builder.py:20} Building MultiMainCallback...\n", + "2023-12-22 01:30:59,933 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/main_callback_builder.py:35} Building MultiMainCallback: 4...DONE!\n", + "2023-12-22 01:30:59,933 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/main_callback_builder.py:35} Building MultiMainCallback: 4...DONE!\n", + "2023-12-22 01:31:00,169 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/worker_pool_builder.py:19} Building WorkerPool...\n", + "2023-12-22 01:31:00,169 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/worker_pool_builder.py:19} Building WorkerPool...\n", + "2023-12-22 01:31:00,170 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/utils/multithreading/worker_pool.py:101} Worker: Sequential\n", + "2023-12-22 01:31:00,170 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/utils/multithreading/worker_pool.py:101} Worker: Sequential\n", + "2023-12-22 01:31:00,170 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/utils/multithreading/worker_pool.py:102} Number of nodes: 1\n", + "Number of CPUs per node: 1\n", + "Number of GPUs per node: 0\n", + "Number of threads across all nodes: 1\n", + "2023-12-22 01:31:00,170 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/utils/multithreading/worker_pool.py:102} Number of nodes: 1\n", + "Number of CPUs per node: 1\n", + "Number of GPUs per node: 0\n", + "Number of threads across all nodes: 1\n", + "2023-12-22 01:31:00,170 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/worker_pool_builder.py:27} Building WorkerPool...DONE!\n", + "2023-12-22 01:31:00,170 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/worker_pool_builder.py:27} Building WorkerPool...DONE!\n", + "2023-12-22 01:31:00,171 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/folder_builder.py:32} Building experiment folders...\n", + "2023-12-22 01:31:00,171 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/folder_builder.py:32} Building experiment folders...\n", + "2023-12-22 01:31:00,171 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/folder_builder.py:35} \n", + "\n", + "\tFolder where all results are stored: /media/sacardoz/Storage/nuplan/exp/exp/simulation/closed_loop_multiagent/2023.12.22.01.30.59\n", + "\n", + "2023-12-22 01:31:00,171 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/folder_builder.py:35} \n", + "\n", + "\tFolder where all results are stored: /media/sacardoz/Storage/nuplan/exp/exp/simulation/closed_loop_multiagent/2023.12.22.01.30.59\n", + "\n", + "2023-12-22 01:31:00,176 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/folder_builder.py:70} Building experiment folders...DONE!\n", + "2023-12-22 01:31:00,176 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/folder_builder.py:70} Building experiment folders...DONE!\n", + "2023-12-22 01:31:00,176 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_callback_builder.py:52} Building AbstractCallback...\n", + "2023-12-22 01:31:00,176 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_callback_builder.py:52} Building AbstractCallback...\n", + "2023-12-22 01:31:00,177 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_callback_builder.py:68} Building AbstractCallback: 0...DONE!\n", + "2023-12-22 01:31:00,177 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_callback_builder.py:68} Building AbstractCallback: 0...DONE!\n", + "2023-12-22 01:31:00,177 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:49} Building simulations...\n", + "2023-12-22 01:31:00,177 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:49} Building simulations...\n", + "2023-12-22 01:31:00,177 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:55} Extracting scenarios...\n", + "2023-12-22 01:31:00,177 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:55} Extracting scenarios...\n", + "2023-12-22 01:31:00,178 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/common/utils/distributed_scenario_filter.py:83} Building Scenarios in mode DistributedMode.SINGLE_NODE\n", + "2023-12-22 01:31:00,178 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/common/utils/distributed_scenario_filter.py:83} Building Scenarios in mode DistributedMode.SINGLE_NODE\n", + "2023-12-22 01:31:00,178 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/scenario_building_builder.py:18} Building AbstractScenarioBuilder...\n", + "2023-12-22 01:31:00,178 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/scenario_building_builder.py:18} Building AbstractScenarioBuilder...\n", + "2023-12-22 01:31:00,197 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/scenario_building_builder.py:21} Building AbstractScenarioBuilder...DONE!\n", + "2023-12-22 01:31:00,197 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/scenario_building_builder.py:21} Building AbstractScenarioBuilder...DONE!\n", + "2023-12-22 01:31:00,197 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/scenario_filter_builder.py:35} Building ScenarioFilter...\n", + "2023-12-22 01:31:00,197 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/scenario_filter_builder.py:35} Building ScenarioFilter...\n", + "2023-12-22 01:31:00,198 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/scenario_filter_builder.py:44} Building ScenarioFilter...DONE!\n", + "2023-12-22 01:31:00,198 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/scenario_filter_builder.py:44} Building ScenarioFilter...DONE!\n", + "2023-12-22 01:31:00,218 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:76} Building metric engines...\n", + "2023-12-22 01:31:00,218 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:76} Building metric engines...\n", + "2023-12-22 01:31:00,239 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:78} Building metric engines...DONE\n", + "2023-12-22 01:31:00,239 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:78} Building metric engines...DONE\n", + "2023-12-22 01:31:00,239 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:82} Building simulations from 1 scenarios...\n", + "2023-12-22 01:31:00,239 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:82} Building simulations from 1 scenarios...\n", + "2023-12-22 01:31:00,354 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/model_builder.py:18} Building TorchModuleWrapper...\n", + "2023-12-22 01:31:00,354 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/model_builder.py:18} Building TorchModuleWrapper...\n", + "2023-12-22 01:31:00,383 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/model_builder.py:21} Building TorchModuleWrapper...DONE!\n", + "2023-12-22 01:31:00,383 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/model_builder.py:21} Building TorchModuleWrapper...DONE!\n", + "2023-12-22 01:31:00,505 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:142} Building simulations...DONE!\n", + "2023-12-22 01:31:00,505 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/script/builders/simulation_builder.py:142} Building simulations...DONE!\n" + ] + } + ], + "source": [ + "from nuplan.planning.script.run_simulation import build_simulation_runners\n", + "from nuplan.common.actor_state.tracked_objects_types import AGENT_TYPES, STATIC_OBJECT_TYPES, TrackedObjectType\n", + "\n", + "# Run the simulation loop (real-time visualization not yet supported, see next section for visualization)\n", + "runners, common_builder, cfg = build_simulation_runners(cfg)" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "223284d4", + "metadata": {}, + "outputs": [], + "source": [ + "runner = runners[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "907ad940", + "metadata": {}, + "outputs": [], + "source": [ + "from nuplan.common.actor_state.agent import Agent\n", + "from nuplan.common.actor_state.oriented_box import OrientedBox\n", + "from nuplan.common.actor_state.scene_object import SceneObjectMetadata\n", + "from nuplan.common.actor_state.state_representation import StateSE2, StateVector2D\n", + "\n", + "inserted_agent = Agent(tracked_object_type=TrackedObjectType.VEHICLE,\n", + " oriented_box=OrientedBox(StateSE2(664433, 3997400, -3.14 / 2), 5, 2, 2),\n", + " velocity=StateVector2D(0, 0),\n", + " metadata=SceneObjectMetadata(1623707858950113, \"inserted\", -2, \"inserted\"),\n", + " angular_velocity=0.0)\n", + "\n", + "inserted_goal = StateSE2(664433, 3997000, -3.14 / 2)" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "90b79421", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "SimulationIteration(time_point=TimePoint(time_us=1623707846350127), index=0)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707846450055), index=1)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707846549980), index=2)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707846649908), index=3)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707846749828), index=4)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707846849751), index=5)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707846949678), index=6)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707847049600), index=7)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707847149533), index=8)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707847249494), index=9)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707847349489), index=10)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707847449511), index=11)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707847549545), index=12)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707847649595), index=13)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707847749661), index=14)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707847849740), index=15)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707847949830), index=16)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707848049917), index=17)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707848149996), index=18)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707848250061), index=19)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707848350125), index=20)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707848450201), index=21)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707848550285), index=22)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707848650366), index=23)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707848750437), index=24)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707848850498), index=25)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707848950550), index=26)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707849050609), index=27)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707849150663), index=28)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707849250694), index=29)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707849350712), index=30)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707849450721), index=31)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707849550719), index=32)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707849650719), index=33)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707849750708), index=34)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707849850693), index=35)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707849950680), index=36)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707850050657), index=37)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707850150617), index=38)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707850250579), index=39)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707850350533), index=40)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707850450476), index=41)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707850550409), index=42)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707850650331), index=43)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707850750249), index=44)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707850850165), index=45)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707850950074), index=46)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707851049984), index=47)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707851149906), index=48)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707851249854), index=49)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707851349817), index=50)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707851449795), index=51)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707851549788), index=52)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707851649785), index=53)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707851749789), index=54)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707851849798), index=55)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707851949814), index=56)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707852049839), index=57)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707852149873), index=58)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707852249912), index=59)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707852349958), index=60)\n", + "SimulationIteration(time_point=TimePoint(time_us=1623707852450015), index=61)\n" + ] + } + ], + "source": [ + "runner.simulation.callback.on_simulation_start(runner.simulation.setup)\n", + "\n", + "# Initialize all simulations\n", + "runner._initialize()\n", + "\n", + "while runner.simulation.is_simulation_running():\n", + "\n", + " if runner.simulation._time_controller.get_iteration().index == 10:\n", + " runner.simulation._observations.add_agent_to_scene(inserted_agent, inserted_goal, iteration.time_point)\n", + "\n", + " # Execute specific callback\n", + " runner.simulation.callback.on_step_start(runner.simulation.setup, runner.planner)\n", + "\n", + " # Perform step\n", + " planner_input = runner._simulation.get_planner_input()\n", + "\n", + " # Execute specific callback\n", + " runner._simulation.callback.on_planner_start(runner.simulation.setup, runner.planner)\n", + "\n", + " # Plan path based on all planner's inputs\n", + " trajectory = runner.planner.compute_trajectory(planner_input)\n", + "\n", + " # Propagate simulation based on planner trajectory\n", + " runner._simulation.callback.on_planner_end(runner.simulation.setup, runner.planner, trajectory)\n", + "\n", + " iteration = runner.simulation._time_controller.get_iteration()\n", + " print(iteration)\n", + " runner.simulation.propagate(trajectory)\n", + "\n", + " # Execute specific callback\n", + " runner.simulation.callback.on_step_end(runner.simulation.setup, runner.planner, runner.simulation.history.last())\n", + "\n", + "runner.simulation.callback.on_simulation_end(runner.simulation.setup, runner.planner, runner.simulation.history)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e6c22f5f", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:bokeh.server.server:Starting Bokeh server version 2.4.3 (running on Tornado 6.3.3)\n", + "WARNING:bokeh.server.util:Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. Use non-wildcard values to restrict access explicitly\n", + "INFO:bokeh.server.tornado:User authentication hooks NOT provided (default user enabled)\n" + ] + }, + { + "data": { + "application/vnd.bokehjs_exec.v0+json": "", + "text/html": [ + "<script id=\"1003\">\n", + " (function() {\n", + " const xhr = new XMLHttpRequest()\n", + " xhr.responseType = 'blob';\n", + " xhr.open('GET', \"http://localhost:5000/autoload.js?bokeh-autoload-element=1003&bokeh-absolute-url=http://localhost:5000&resources=none\", true);\n", + " xhr.onload = function (event) {\n", + " const script = document.createElement('script');\n", + " const src = URL.createObjectURL(event.target.response);\n", + " script.src = src;\n", + " document.body.appendChild(script);\n", + " };\n", + " xhr.send();\n", + " })();\n", + "</script>" + ] + }, + "metadata": { + "application/vnd.bokehjs_exec.v0+json": { + "server_id": "e02ac0e6136c41bc81ee6791378262dd" + } + }, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2023-12-22 01:27:36,238 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Error creating dataset. Could not read schema from 'run_sim_closed_loop/training_raster_experiment/train_default_raster/2023.11.14.22.55.23/hparams.yaml'. Is this a 'parquet' file?: Could not open Parquet input source 'run_sim_closed_loop/training_raster_experiment/train_default_raster/2023.11.14.22.55.23/hparams.yaml': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", + "2023-12-22 01:27:36,239 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", + "2023-12-22 01:27:36,240 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", + "2023-12-22 01:27:36,240 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Error creating dataset. Could not read schema from 'pretrained_checkpoints/gc_pgp_checkpoint.ckpt'. Is this a 'parquet' file?: Could not open Parquet input source 'pretrained_checkpoints/gc_pgp_checkpoint.ckpt': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", + "2023-12-22 01:27:36,241 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", + "2023-12-22 01:27:36,241 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", + "2023-12-22 01:27:36,241 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", + "2023-12-22 01:27:36,242 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/nuboard/base/experiment_file_data.py:140} Could not open Parquet input source '<Buffer>': Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file.\n", + "2023-12-22 01:27:36,244 INFO {/media/sacardoz/Storage/nuplan-devkit/nuplan/planning/nuboard/base/simulation_tile.py:172} Minimum frame time=0.017 s\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Rendering a scenario: 100%|██████████| 1/1 [00:00<00:00, 84.37it/s]\n", + "WARNING:bokeh.core.validation.check:W-1000 (MISSING_RENDERERS): Plot has no renderers: Figure(id='1005', ...)\n", + "INFO:tornado.access:200 GET /autoload.js?bokeh-autoload-element=1003&bokeh-absolute-url=http://localhost:5000&resources=none (::1) 919.22ms\n", + "INFO:bokeh.server.views.ws:WebSocket connection opened\n", + "INFO:tornado.access:101 GET /ws?id=935f7e47-d5c0-410b-9cdd-a988d9f0ac32&origin=da2f890a-eb18-4637-9199-dd0f06169aef&swVersion=4&extensionId=&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app&purpose=notebookRenderer (::1) 0.68ms\n", + "INFO:bokeh.server.views.ws:ServerConnection created\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2023-12-22 01:27:37,148 INFO {/home/sacardoz/miniconda3/envs/nuplan/lib/python3.9/site-packages/tornado/web.py:2344} 200 GET /autoload.js?bokeh-autoload-element=1003&bokeh-absolute-url=http://localhost:5000&resources=none (::1) 919.22ms\n", + "2023-12-22 01:27:37,155 INFO {/media/sacardoz/Storage/nuplan-devkit/tutorials/utils/tutorial_utils.py:267} Done rendering!\n", + "2023-12-22 01:27:37,174 INFO {/home/sacardoz/miniconda3/envs/nuplan/lib/python3.9/site-packages/tornado/web.py:2344} 101 GET /ws?id=935f7e47-d5c0-410b-9cdd-a988d9f0ac32&origin=da2f890a-eb18-4637-9199-dd0f06169aef&swVersion=4&extensionId=&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app&purpose=notebookRenderer (::1) 0.68ms\n" + ] + } + ], + "source": [ + "from tutorials.utils.tutorial_utils import visualize_history\n", + "visualize_history(runner.simulation._history, runner.scenario, bokeh_port=5000)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.18" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/nuplan/planning/script/config/simulation/observation/ml_planner_agents_observation.yaml b/nuplan/planning/script/config/simulation/observation/ml_planner_agents_observation.yaml index 2bb358eca1eaf47d149919b33bc96e68f4e9a555..fe8ec0e940ea7c0bbc517e3454c7a71b4b7f42e4 100644 --- a/nuplan/planning/script/config/simulation/observation/ml_planner_agents_observation.yaml +++ b/nuplan/planning/script/config/simulation/observation/ml_planner_agents_observation.yaml @@ -4,3 +4,5 @@ _convert_: 'all' model_config: ??? # Dictionary key from existing planner model config (e.g. reactive_agents_model) checkpoint_path: ??? # Path to trained model checkpoint occlusions: false # Boolean to determine whether occlusions should be enabled +planner_type: "ml" # String to determine planner type (one of "ml", "idm", "pdm_closed", "pdm_hybrid") +pdm_hybrid_ckpt: null # Path to trained PDM hybrid model checkpoint diff --git a/nuplan/planning/simulation/observation/ml_planner_agents.py b/nuplan/planning/simulation/observation/ml_planner_agents.py index 3ebcc4e6702469e156f7493418891fce094e56c8..576658531ba150038ff41d75365319011926fac7 100644 --- a/nuplan/planning/simulation/observation/ml_planner_agents.py +++ b/nuplan/planning/simulation/observation/ml_planner_agents.py @@ -17,21 +17,66 @@ from nuplan.planning.simulation.observation.observation_type import Observation from nuplan.planning.simulation.observation.observation_type import DetectionsTracks from nuplan.planning.simulation.occlusion.wedge_occlusion_manager import WedgeOcclusionManager from nuplan.planning.simulation.planner.abstract_planner import PlannerInitialization, PlannerInput +from nuplan.planning.simulation.planner.idm_planner import IDMPlanner + from nuplan.planning.simulation.planner.ml_planner.ml_planner import MLPlanner from nuplan.planning.simulation.simulation_time_controller.simulation_iteration import SimulationIteration from nuplan.planning.training.modeling.torch_module_wrapper import TorchModuleWrapper +from nuplan.planning.simulation.trajectory.trajectory_sampling import TrajectorySampling + +from tuplan_garage.planning.training.modeling.models.pdm_offset_model import PDMOffsetModel +from tuplan_garage.planning.simulation.planner.pdm_planner.pdm_closed_planner import PDMClosedPlanner +from tuplan_garage.planning.simulation.planner.pdm_planner.pdm_hybrid_planner import PDMHybridPlanner + +from tuplan_garage.planning.simulation.planner.pdm_planner.proposal.batch_idm_policy import BatchIDMPolicy OPEN_LOOP_DETECTION_TYPES = [TrackedObjectType.PEDESTRIAN, TrackedObjectType.BICYCLE, \ TrackedObjectType.CZONE_SIGN, TrackedObjectType.BARRIER, \ TrackedObjectType.TRAFFIC_CONE, TrackedObjectType.GENERIC_OBJECT] +IDM_AGENT_CONFIG = { + "target_velocity": 10, # Desired velocity in free traffic [m/s] + "min_gap_to_lead_agent": 1.0, # Minimum relative distance to lead vehicle [m] + "headway_time": 1.5, # Desired time headway. The minimum possible time to the vehicle in front [s] + "accel_max": 1.0, # Maximum acceleration [m/s^2] + "decel_max": 3.0, # Maximum deceleration (positive value) [m/s^2] + "planned_trajectory_samples": 16, # Number of trajectory samples to generate + "planned_trajectory_sample_interval": 0.5, # The sampling time interval between samples [s] + "occupancy_map_radius": 40, # The range around the ego to add objects to be considered [m] +} + + +PDM_CLOSED_AGENT_CONFIG = { + "trajectory_sampling": TrajectorySampling(num_poses=80, interval_length= 0.1), + "proposal_sampling": TrajectorySampling(num_poses=40, interval_length= 0.1), + "idm_policies": BatchIDMPolicy(speed_limit_fraction= [0.2,0.4,0.6,0.8,1.0], + fallback_target_velocity= 15.0, + min_gap_to_lead_agent= 1.0, + headway_time= 1.5, + accel_max= 1.5, + decel_max= 3.0), + "lateral_offsets": [-1.0, 1.0], + "map_radius": 50, +} + +PDM_HYBRID_AGENT_CONFIG = { + "model":PDMOffsetModel(trajectory_sampling=TrajectorySampling(num_poses=16, interval_length=0.5), + history_sampling=TrajectorySampling(num_poses=10, interval_length=0.2), + planner=None, + centerline_samples=120, + centerline_interval=1.0, + hidden_dim=512), + "correction_horizon":2.0, +} + + class MLPlannerAgents(AbstractObservation): """ Simulate agents based on an ML model. """ - def __init__(self, model: TorchModuleWrapper, scenario: AbstractScenario, occlusions: bool) -> None: + def __init__(self, model: TorchModuleWrapper, scenario: AbstractScenario, occlusions: bool, planner_type: str, pdm_hybrid_ckpt: str) -> None: """ Initializes the MLPlannerAgents class. :param model: Model to use for inference. @@ -39,6 +84,8 @@ class MLPlannerAgents(AbstractObservation): """ self.current_iteration = 0 self.model = model + self.planner_type = planner_type + self.pdm_hybrid_ckpt = pdm_hybrid_ckpt self._scenario = scenario self._occlusions = occlusions self._ego_state_history: Dict = {} @@ -274,9 +321,22 @@ class MLPlannerAgents(AbstractObservation): self._agents[agent.metadata.track_token]['planner'].initialize(planner_init) def _build_agent_record(self, agent: Agent, timepoint_record: TimePoint): + + if self.planner_type == "ml": + planner = MLPlanner(self.model) + elif self.planner_type == "idm": + planner = IDMPlanner(**IDM_AGENT_CONFIG) + elif self.planner_type == "pdm_closed": + planner = PDMClosedPlanner(**PDM_CLOSED_AGENT_CONFIG) + elif self.planner_type == "pdm_hybrid": + assert self.pdm_hybrid_ckpt, "Must provide checkpoint path for PDM hybrid planner." + planner = PDMHybridPlanner(**PDM_CLOSED_AGENT_CONFIG, **PDM_HYBRID_AGENT_CONFIG, checkpoint_path=self.pdm_hybrid_ckpt) + else: + raise ValueError("Invalid planner type.") + return {'ego_state': self._build_ego_state_from_agent(agent, timepoint_record), \ 'metadata': agent.metadata, - 'planner': MLPlanner(self.model), + 'planner': planner, 'occlusion': WedgeOcclusionManager(self._scenario) if self._occlusions else None} def _get_historical_agent_goal(self, agent: Agent, iteration_index: int):