Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 0d434310 authored by Sebastian Maierhofer's avatar Sebastian Maierhofer
Browse files

update readme and some minor changes

parent cd299969
## Core latex/pdflatex auxiliary files:
*.aux
*.lof
*.log
*.lot
*.fls
*.out
*.toc
*.fmt
*.fot
*.cb
*.cb2
## PyCharm project:
.idea
## Intermediate documents:
*.dvi
*-converted-to.*
# these rules might exclude image files for figures etc.
*.ps
# *.eps
# *.pdf
## Generated if empty string is given at "Please type another file name for output:"
.pdf
## Bibliography auxiliary files (bibtex/biblatex/biber):
*.bbl
*.bcf
*.blg
*-blx.aux
*-blx.bib
*.brf
*.run.xml
## Build tool auxiliary files:
*.fdb_latexmk
*.synctex
*.synctex(busy)
*.synctex.gz
*.synctex.gz(busy)
*.pdfsync
## Auxiliary and intermediate files from other packages:
# algorithms
*.alg
*.loa
# achemso
acs-*.bib
# amsthm
*.thm
# beamer
*.nav
*.snm
*.vrb
# cprotect
*.cpt
# fixme
*.lox
# feynmf/feynmp
*.mf
*.mp
*.t[1-9]
*.t[1-9][0-9]
*.tfm
*.[1-9]
*.[1-9][0-9]
#(r)(e)ledmac/(r)(e)ledpar
*.end
*.?end
*.[1-9]
*.[1-9][0-9]
*.[1-9][0-9][0-9]
*.[1-9]R
*.[1-9][0-9]R
*.[1-9][0-9][0-9]R
*.eledsec[1-9]
*.eledsec[1-9]R
*.eledsec[1-9][0-9]
*.eledsec[1-9][0-9]R
*.eledsec[1-9][0-9][0-9]
*.eledsec[1-9][0-9][0-9]R
# glossaries
*.acn
*.acr
*.glg
*.glo
*.gls
*.glsdefs
# gnuplottex
*-gnuplottex-*
# gregoriotex
*.gaux
*.gtex
# hyperref
*.brf
# knitr
*-concordance.tex
# TODO Comment the next line if you want to keep your tikz graphics files
*.tikz
*-tikzDictionary
# listings
*.lol
# makeidx
*.idx
*.ilg
*.ind
*.ist
# minitoc
*.maf
*.mlf
*.mlt
*.mtc
*.mtc[0-9]
*.mtc[1-9][0-9]
# minted
_minted*
*.pyg
# morewrites
*.mw
# mylatexformat
*.fmt
# nomencl
*.nlo
# sagetex
*.sagetex.sage
*.sagetex.py
*.sagetex.scmd
# scrwfile
*.wrt
# sympy
*.sout
*.sympy
sympy-plots-for-*.tex/
# pdfcomment
*.upa
*.upb
# pythontex
*.pytxcode
pythontex-files-*/
# thmtools
*.loe
# TikZ & PGF
*.dpth
*.md5
*.auxlock
# todonotes
*.tdo
# easy-todo
*.lod
# xindy
*.xdy
# xypic precompiled matrices
*.xyc
# endfloat
*.ttt
*.fff
# Latexian
TSWLatexianTemp*
## Editors:
# WinEdt
*.bak
*.sav
# Texpad
.texpadtmp
# Kile
*.backup
# KBibTeX
*~[0-9]*
# windows folder shortcuts
*.lnk
# auto folder when using emacs and auctex
/auto/*
# python
*__pycache__/
## Byte-compiled / optimized / DLL files
__pycache__/
.ipynb_checkpoints
*.py[cod]
*.cache
*pytest_cache/
*.egg-info
# pytest
.coverage
......@@ -18,7 +18,7 @@ from math import atan2
import matplotlib.pyplot as plt
from IPython import display
from ipywidgets import widgets
from IPython.display import display
#from IPython.display import display
# import CommonRoad-io modules
from commonroad.visualization.draw_dispatch_cr import draw_object
......@@ -265,7 +265,8 @@ def start_search(scenario, planning_problem, automata, motion_planner, initial_m
draw_it(collision_object, draw_params={'collision': {'facecolor': 'magenta'}})
# visualize current trajectory
fig.canvas.draw()
if flag_plot_intermediate_results is True:
fig.canvas.draw()
# wait till process_search terminates
process_search.join()
......
......@@ -29,9 +29,9 @@ The codes are written in Python 3.7 and tested on Ubuntu 18.04.
You can either install the softwares on your own machine, use a virtual machine image or run a docker image.
1. (Works on Ubuntu) Please follow the installation guide below if you are using your own machine.
2. (`Recommended` for Ubuntu, Mac OS & Windows) Alternatively, you can use the virtual machine image provide by us, in which all the necessary modules are installed already. You can down the virtual machine image via [this](https://syncandshare.lrz.de/dlpw/fi2BN8NUepqiQzfG3LzWYf4J/Virtual_Machine.zip) link and run it in Virtual Box. The downloading password and default login password are both `commonroad`.
3. (Works on Ubuntu, Mac OS with OS X El Capitan 10.11 or later, Windows 10 64-bit: Pro, Enterprise, or Education, Build 15063 or later) Also, you can run a docker image provided by Tom Dörr. After installing docker, you can run the image using command
1. Own machine (Works on Ubuntu): Please follow the installation guide below if you are using your own machine.
2. Virtual machine (`Recommended` for Ubuntu, Mac OS & Windows): Alternatively, you can use the virtual machine image provide by us, in which all the necessary modules are installed already. You can down the virtual machine image via [this](https://syncandshare.lrz.de/dlpw/fi2BN8NUepqiQzfG3LzWYf4J/Virtual_Machine.zip) link and run it in Virtual Box. The downloading password and default login password are both `commonroad`.
3. Docker (Works on Ubuntu, Mac OS with OS X El Capitan 10.11 or later, Windows 10 64-bit: Pro, Enterprise, or Education, Build 15063 or later): Also, you can run a docker image provided by Tom Dörr. After installing docker, you can run the image using command
```sh
docker run -it -p 9000:8888 --mount src="$(pwd)",target=/commonroad-search,type=bind tomdoerr/commonroad-search
......@@ -66,6 +66,7 @@ Install `Jupyter Notebook` and supplementary modules:
$ conda install jupyter
$ conda install ipykernel
$ pip install ipython-autotime
$ pip install PyYAML
$ conda install ipywidgets
$ conda install sphinx
$ conda install scipy
......@@ -111,6 +112,7 @@ Open `GSMP/motion_automata/automata/MotionPlanner.py`. Write your own heuristic
```
There are already two search algorithms, namely `A*` and `Greedy Best First Search`, implemented as examples for you. You are free to refer to them for some inspiration.
The `A*` is not working perfecly and should only serve as code reference how a heuristic can be developed.
## Troubleshooting
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Batch Processing"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is a script that helps you to batch process your code to solve for solution to different scenarios. It is composed of a configuration file (.yaml) and the codes below. Before you run this code, you should make sure the configuration file is set correctly. Here are the explanation for each of the parameters in the configuration file:\n",
"* input_path: the input directory of CommonRoad scenarios that you indend to solve.\n",
"* output_path: the output directory of the solution files.\n",
"* overwrite: the falg to determine whether to overwrite existing solution files.\n",
"* timeout: timeout time for your motion planner, unit in seconds\n",
"* trajectory_planner_path: input directory where the module containing the function to execute your motion planner is located\n",
"* trajectory_planner_module_name: name of the module taht contains the function to execute your motion planner\n",
"* trajectory_planner_function_name: name of the function that executes your motion planner\n",
"* default: the parameters specified under this will be applied to all scenarios. if you wish to specify a different paramter for specific scenarios, simply copy the section and replace 'default' with the id of your scenario.\n",
"* vehicle_model: model of the vehicle, its value could be PM, KS, ST and MB.\n",
"* vehicle_type type of the vehicle, its value could be FORD_ESCORT, BMW_320i and VW_VANAGON.\n",
"* cost_function: identifier of cost function. Please refer to [Cost Functions](https://gitlab.lrz.de/tum-cps/commonroad-cost-functions/blob/master/costFunctions_commonRoad.pdf) for more information."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Helper functions"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import pathlib\n",
"import multiprocessing\n",
"import yaml\n",
"import sys\n",
"import warnings\n",
"\n",
"from commonroad.common.file_reader import CommonRoadFileReader\n",
"from commonroad.common.solution_writer import CommonRoadSolutionWriter, VehicleModel, VehicleType, CostFunction\n",
"\n",
"def parse_vehicle_model(model):\n",
" if model == 'PM':\n",
" cr_model = VehicleModel.PM\n",
" elif model == 'ST':\n",
" cr_model = VehicleModel.ST\n",
" elif model == 'KS':\n",
" cr_model = VehicleModel.KS\n",
" elif model == 'MB':\n",
" cr_model = VehicleModel.MB\n",
" else:\n",
" raise ValueError('Selected vehicle model is not valid: {}.'.format(model))\n",
" return cr_model\n",
"\n",
"\n",
"def parse_vehicle_type(type):\n",
" if type == 'FORD_ESCORT':\n",
" cr_type = VehicleType.FORD_ESCORT\n",
" cr_type_id = 1\n",
" elif type == 'BMW_320i':\n",
" cr_type = VehicleType.BMW_320i\n",
" cr_type_id = 2\n",
" elif type == 'VW_VANAGON':\n",
" cr_type = VehicleType.VW_VANAGON\n",
" cr_type_id = 3\n",
" else:\n",
" raise ValueError('Selected vehicle type is not valid: {}.'.format(type))\n",
" \n",
" return cr_type, cr_type_id\n",
"\n",
"\n",
"def parse_cost_function(cost):\n",
" if cost == 'JB1':\n",
" cr_cost = CostFunction.JB1\n",
" elif cost == 'SA1':\n",
" cr_cost = CostFunction.SA1\n",
" elif cost == 'WX1':\n",
" cr_cost = CostFunction.WX1\n",
" elif cost == 'SM1':\n",
" cr_cost = CostFunction.SM1\n",
" elif cost == 'SM2':\n",
" cr_cost = CostFunction.SM2\n",
" elif cost == 'SM3':\n",
" cr_cost = CostFunction.SM3\n",
" else:\n",
" raise ValueError('Selected cost function is not valid: {}.'.format(cost))\n",
" return cr_cost\n",
"\n",
"\n",
"def call_trajectory_planner(queue, function, scenario, planning_problem_set, vehicle_type_id):\n",
" queue.put(function(scenario, planning_problem_set, vehicle_type_id))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Read configuration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# open config file\n",
"with open('batch_processing_config.yaml', 'r') as stream:\n",
" try:\n",
" settings = yaml.load(stream)\n",
" except yaml.YAMLError as exc:\n",
" print(exc)\n",
"\n",
"# get planning wrapper function\n",
"sys.path.append(os.getcwd() + os.path.dirname(settings['trajectory_planner_path']))\n",
"module = __import__(settings['trajectory_planner_module_name'])\n",
"function = getattr(module, settings['trajectory_planner_function_name'])\n",
"time_timeout = settings['timeout']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Start Processing"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# iterate through scenarios\n",
"num_files = len(os.listdir(settings['input_path']))\n",
"\n",
"print(\"Total number of files to be processed: {}\".format(num_files))\n",
"print(\"Timeout setting: {} seconds\\n\".format(time_timeout))\n",
" \n",
"count_processed = 0\n",
"for filename in os.listdir(settings['input_path']):\n",
" count_processed += 1\n",
" print(\"File No. {} / {}\".format(count_processed, num_files))\n",
" \n",
" if not filename.endswith('.xml'):\n",
" continue\n",
" \n",
" fullname = os.path.join(settings['input_path'], filename)\n",
"\n",
" print(\"Started processing scenario {}\".format(filename))\n",
" scenario, planning_problem_set = CommonRoadFileReader(fullname).open()\n",
"\n",
" # get settings for each scenario\n",
" if scenario.benchmark_id in settings.keys():\n",
" # specific\n",
" vehicle_model = parse_vehicle_model(settings[scenario.benchmark_id]['vehicle_model'])\n",
" vehicle_type,vehicle_type_id = parse_vehicle_type(settings[scenario.benchmark_id]['vehicle_type'])\n",
" cost_function = parse_cost_function(settings[scenario.benchmark_id]['cost_function'])\n",
" else:\n",
" # default\n",
" vehicle_model = parse_vehicle_model(settings['default']['vehicle_model'])\n",
" vehicle_type, vehicle_type_id = parse_vehicle_type(settings['default']['vehicle_type'])\n",
" cost_function = parse_cost_function(settings['default']['cost_function'])\n",
" \n",
" queue = multiprocessing.Queue()\n",
" # create process, pass in required arguements\n",
" p = multiprocessing.Process(target=call_trajectory_planner, name=\"trajectory_planner\",\n",
" args=(queue, function, scenario, planning_problem_set, vehicle_type_id))\n",
" # start planning\n",
" p.start()\n",
" \n",
" # wait till process ends or skip if timed out\n",
" p.join(timeout=time_timeout)\n",
"\n",
" if p.is_alive():\n",
" print(\"===> Trajectory planner timeout.\")\n",
" p.terminate()\n",
" p.join()\n",
" solution_trajectories = {}\n",
" else:\n",
" print(\"Planning finished.\")\n",
" solution_trajectories = queue.get()\n",
"\n",
" # create path for solutions\n",
" pathlib.Path(settings['output_path']).mkdir(parents=True, exist_ok=True)\n",
"\n",
" error = False\n",
" cr_solution_writer = CommonRoadSolutionWriter(settings['output_path'], \n",
" scenario.benchmark_id, \n",
" scenario.dt,\n",
" vehicle_type, \n",
" vehicle_model, \n",
" cost_function)\n",
" \n",
" # inspect whether all planning problems are solved\n",
" for planning_problem_id, planning_problem in planning_problem_set.planning_problem_dict.items():\n",
" if planning_problem_id not in solution_trajectories.keys():\n",
" print('Solution for planning problem with ID={} is not provided for scenario {}. Solution skipped.'.format(\n",
" planning_problem_id, filename))\n",
" error = True\n",
" break\n",
" else:\n",
" cr_solution_writer.add_solution_trajectory(\n",
" solution_trajectories[planning_problem_id], planning_problem_id)\n",
" if not error:\n",
" cr_solution_writer.write_to_file(overwrite=settings['overwrite'])\n",
"\n",
" print(\"=========================================================\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (cr37)",
"language": "python",
"name": "cr37"
},
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
......@@ -15,7 +15,7 @@ motion_planner_module_name: batch_search
motion_planner_function_name: execute_search_batch
# benchmark evaluation parameters
# change 'defult' to scenario id to specify exclusive parameters for that scenario
# change 'default' to scenario id to specify exclusive parameters for that scenario
# e.g. change 'default' to 'USA_US101-6_2_T-1'
default:
# vehicle model, e.g., kinematic single-track model
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tutorial: Batch Processing"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This tutorial shows how to solve for solutions to different scenarios in a batch processing fashion. You can find all realted files in [this](https://gitlab.lrz.de/tum-cps/commonroad_io/tree/batch_processing) repository. The main components are:\n",
"* a configuration file (.yaml format),\n",
"* some helper functions,\n",
"* and the script below to call the planer function.\n",
"\n",
"Before proceeding, you should make sure the configuration file is set correctly. Here are the explanation for each of the parameters in the configuration file:\n",
"* **input_path**: input directory of CommonRoad scenarios that you indend to solve.\n",
"* **output_path**: output directory of the solution files.\n",
"* **overwrite**: flag to determine whether the existing solution files should be overwritten.\n",
"* **timeout**: timeout time for your motion planner, unit in seconds\n",
"* **motion_planner_path**: directory where the module containing the function to execute your motion planner is located\n",
"* **motion_planner_module_name**: name of the module that contains the function to execute your motion planner\n",
"* **motion_planner_function_name**: name of the function that executes your motion planner\n",
"* **default**: parameters specified under this section will be applied to all scenarios. If you wish to specify a different paramter for specific scenarios, simply copy the section and replace 'default' with the id of your scenario.\n",
"* **vehicle_model**: model of the vehicle, valid values: **PM, KS, ST and MB**. Please refer to [Vehicle Models](https://gitlab.lrz.de/tum-cps/commonroad-vehicle-models/blob/master/vehicleModels_commonRoad.pdf) for more information.\n",
"* **vehicle_type**: type of the vehicle, valid values: **FORD_ESCORT, BMW_320i and VW_VANAGON**.\n",
"* **cost_function**: identifier of cost function. Please refer to [Cost Functions](https://gitlab.lrz.de/tum-cps/commonroad-cost-functions/blob/master/costFunctions_commonRoad.pdf) for more information.\n",
"* **planner_id**: id of the planner that is used to solve for solutions. in this example, 1 = Greedy Best First Search, 2 = A*, else = Your own planner.\n",
"* **planning_problem_idx**: planner problem index. for cooperative scenarios: 0, 1, 2, ..., otherwise: 0\n",
"* **max_tree_depth**: maximum permissible depth of the search tree\n",
"\n",
"Note: the paths can be either **relative** to this script or **absolute**.\n",
"\n",
"Simply run the following script to start batch processing. The results here is just exemplary, you will see different output as your configuration varies."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# import helper functions\n",
"from helper_functions import *\n",
"\n",
"# specify path to configuration file\n",
"path_file_config = \"../configuration/batch_processing_config.yaml\"\n",
"\n",
"# load configuration file\n",
"configuration = load_configuration(path_file_config)\n",
"\n",
"# get target function\n",
"function_target = get_target_function(configuration)\n",
"\n",
"# get a list of scenario files\n",
"list_files_input = get_input_files(configuration)\n",
"\n",
"# get length of the list and time before timeout\n",
"num_files = len(list_files_input)\n",
"time_timeout = configuration['timeout']\n",
"\n",
"print(\"Total number of files to be processed: {}\".format(num_files))\n",
"print(\"Timeout setting: {} seconds\\n\".format(time_timeout))\n",
"count_processed = 0\n",
"\n",
"# iterate through scenarios\n",
"for file_scenario in list_files_input:\n",
" count_processed += 1\n",
" print(\"Processing file No. {} / {}. Scenario ID: {}\".format(count_processed, num_files, file_scenario[:-4]))\n",
" # parse the scenario file\n",
" result_parse = parse_scenario_file(configuration, file_scenario)\n",
" # execute target function\n",
" solution_trajectories = execute_target_function(function_target, result_parse, time_timeout)\n",
" # save solution file\n",
" save_solution(configuration, solution_trajectories, result_parse)\n",
" print(\"{:=^70s}\".format(''))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (cr37)",
"language": "python",
"name": "cr37"
},
"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.7.3"
}
},
"nbformat": 4,