Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

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,6 +265,7 @@ def start_search(scenario, planning_problem, automata, motion_planner, initial_m
draw_it(collision_object, draw_params={'collision': {'facecolor': 'magenta'}})
# visualize current trajectory
if flag_plot_intermediate_results is True:
fig.canvas.draw()
# wait till process_search terminates
......
......@@ -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
......
%% Cell type:markdown id: tags:
# Batch Processing
%% Cell type:markdown id: tags:
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:
* input_path: the input directory of CommonRoad scenarios that you indend to solve.
* output_path: the output directory of the solution files.
* overwrite: the falg to determine whether to overwrite existing solution files.
* timeout: timeout time for your motion planner, unit in seconds
* trajectory_planner_path: input directory where the module containing the function to execute your motion planner is located
* trajectory_planner_module_name: name of the module taht contains the function to execute your motion planner
* trajectory_planner_function_name: name of the function that executes your motion planner
* 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.
* vehicle_model: model of the vehicle, its value could be PM, KS, ST and MB.
* vehicle_type type of the vehicle, its value could be FORD_ESCORT, BMW_320i and VW_VANAGON.
* 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 id: tags:
### Helper functions
%% Cell type:code id: tags:
``` python
import os
import pathlib
import multiprocessing
import yaml
import sys
import warnings
from commonroad.common.file_reader import CommonRoadFileReader
from commonroad.common.solution_writer import CommonRoadSolutionWriter, VehicleModel, VehicleType, CostFunction
def parse_vehicle_model(model):
if model == 'PM':
cr_model = VehicleModel.PM
elif model == 'ST':
cr_model = VehicleModel.ST
elif model == 'KS':
cr_model = VehicleModel.KS
elif model == 'MB':
cr_model = VehicleModel.MB
else:
raise ValueError('Selected vehicle model is not valid: {}.'.format(model))
return cr_model
def parse_vehicle_type(type):
if type == 'FORD_ESCORT':
cr_type = VehicleType.FORD_ESCORT
cr_type_id = 1
elif type == 'BMW_320i':
cr_type = VehicleType.BMW_320i
cr_type_id = 2
elif type == 'VW_VANAGON':
cr_type = VehicleType.VW_VANAGON
cr_type_id = 3
else:
raise ValueError('Selected vehicle type is not valid: {}.'.format(type))
return cr_type, cr_type_id
def parse_cost_function(cost):
if cost == 'JB1':
cr_cost = CostFunction.JB1
elif cost == 'SA1':
cr_cost = CostFunction.SA1
elif cost == 'WX1':
cr_cost = CostFunction.WX1
elif cost == 'SM1':
cr_cost = CostFunction.SM1
elif cost == 'SM2':
cr_cost = CostFunction.SM2
elif cost == 'SM3':
cr_cost = CostFunction.SM3
else:
raise ValueError('Selected cost function is not valid: {}.'.format(cost))
return cr_cost
def call_trajectory_planner(queue, function, scenario, planning_problem_set, vehicle_type_id):
queue.put(function(scenario, planning_problem_set, vehicle_type_id))
```
%% Cell type:markdown id: tags:
### Read configuration
%% Cell type:code id: tags:
``` python
# open config file
with open('batch_processing_config.yaml', 'r') as stream:
try:
settings = yaml.load(stream)
except yaml.YAMLError as exc:
print(exc)
# get planning wrapper function
sys.path.append(os.getcwd() + os.path.dirname(settings['trajectory_planner_path']))
module = __import__(settings['trajectory_planner_module_name'])
function = getattr(module, settings['trajectory_planner_function_name'])
time_timeout = settings['timeout']
```
%% Cell type:markdown id: tags:
### Start Processing
%% Cell type:code id: tags:
``` python
# iterate through scenarios
num_files = len(os.listdir(settings['input_path']))
print("Total number of files to be processed: {}".format(num_files))
print("Timeout setting: {} seconds\n".format(time_timeout))
count_processed = 0
for filename in os.listdir(settings['input_path']):
count_processed += 1
print("File No. {} / {}".format(count_processed, num_files))
if not filename.endswith('.xml'):
continue
fullname = os.path.join(settings['input_path'], filename)
print("Started processing scenario {}".format(filename))
scenario, planning_problem_set = CommonRoadFileReader(fullname).open()
# get settings for each scenario
if scenario.benchmark_id in settings.keys():
# specific
vehicle_model = parse_vehicle_model(settings[scenario.benchmark_id]['vehicle_model'])
vehicle_type,vehicle_type_id = parse_vehicle_type(settings[scenario.benchmark_id]['vehicle_type'])
cost_function = parse_cost_function(settings[scenario.benchmark_id]['cost_function'])
else:
# default
vehicle_model = parse_vehicle_model(settings['default']['vehicle_model'])
vehicle_type, vehicle_type_id = parse_vehicle_type(settings['default']['vehicle_type'])
cost_function = parse_cost_function(settings['default']['cost_function'])
queue = multiprocessing.Queue()
# create process, pass in required arguements
p = multiprocessing.Process(target=call_trajectory_planner, name="trajectory_planner",
args=(queue, function, scenario, planning_problem_set, vehicle_type_id))
# start planning
p.start()
# wait till process ends or skip if timed out
p.join(timeout=time_timeout)
if p.is_alive():
print("===> Trajectory planner timeout.")
p.terminate()
p.join()
solution_trajectories = {}
else:
print("Planning finished.")
solution_trajectories = queue.get()
# create path for solutions
pathlib.Path(settings['output_path']).mkdir(parents=True, exist_ok=True)
error = False
cr_solution_writer = CommonRoadSolutionWriter(settings['output_path'],
scenario.benchmark_id,
scenario.dt,
vehicle_type,
vehicle_model,
cost_function)
# inspect whether all planning problems are solved
for planning_problem_id, planning_problem in planning_problem_set.planning_problem_dict.items():
if planning_problem_id not in solution_trajectories.keys():
print('Solution for planning problem with ID={} is not provided for scenario {}. Solution skipped.'.format(
planning_problem_id, filename))
error = True
break
else:
cr_solution_writer.add_solution_trajectory(
solution_trajectories[planning_problem_id], planning_problem_id)
if not error:
cr_solution_writer.write_to_file(overwrite=settings['overwrite'])
print("=========================================================")
```
......@@ -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
......
%% Cell type:markdown id: tags:
# Tutorial: Batch Processing
%% Cell type:markdown id: tags:
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:
* a configuration file (.yaml format),
* some helper functions,
* and the script below to call the planer function.
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:
* **input_path**: input directory of CommonRoad scenarios that you indend to solve.
* **output_path**: output directory of the solution files.
* **overwrite**: flag to determine whether the existing solution files should be overwritten.
* **timeout**: timeout time for your motion planner, unit in seconds
* **motion_planner_path**: directory where the module containing the function to execute your motion planner is located
* **motion_planner_module_name**: name of the module that contains the function to execute your motion planner
* **motion_planner_function_name**: name of the function that executes your motion planner
* **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.
* **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.
* **vehicle_type**: type of the vehicle, valid values: **FORD_ESCORT, BMW_320i and VW_VANAGON**.
* **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.
* **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.
* **planning_problem_idx**: planner problem index. for cooperative scenarios: 0, 1, 2, ..., otherwise: 0
* **max_tree_depth**: maximum permissible depth of the search tree
Note: the paths can be either **relative** to this script or **absolute**.
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 id: tags:
``` python
# import helper functions
from helper_functions import *
# specify path to configuration file
path_file_config = "../configuration/batch_processing_config.yaml"
# load configuration file
configuration = load_configuration(path_file_config)
# get target function
function_target = get_target_function(configuration)
# get a list of scenario files
list_files_input = get_input_files(configuration)
# get length of the list and time before timeout
num_files = len(list_files_input)
time_timeout = configuration['timeout']
print("Total number of files to be processed: {}".format(num_files))
print("Timeout setting: {} seconds\n".format(time_timeout))
count_processed = 0
# iterate through scenarios
for file_scenario in list_files_input:
count_processed += 1
print("Processing file No. {} / {}. Scenario ID: {}".format(count_processed, num_files, file_scenario[:-4]))
# parse the scenario file
result_parse = parse_scenario_file(configuration, file_scenario)
# execute target function
solution_trajectories = execute_target_function(function_target, result_parse, time_timeout)
# save solution file
save_solution(configuration, solution_trajectories, result_parse)
print("{:=^70s}".format(''))
```
......@@ -65,5 +65,107 @@
solution_trajectories = execute_target_function(function_target, result_parse, time_timeout)
# save solution file
save_solution(configuration, solution_trajectories, result_parse)
print("{:=^70s}".format(''))
```
%%%% Output: error
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-1-c4fa63224ee7> in <module>
27 print("Processing file No. {} / {}. Scenario ID: {}".format(count_processed, num_files, file_scenario[:-4]))
28 # parse the scenario file
---> 29 result_parse = parse_scenario_file(configuration, file_scenario)
30 # execute target function
31 solution_trajectories = execute_target_function(function_target, result_parse, time_timeout)
/media/sebastian/TUM/05_teaching/gems_of_informatic/commonroad-search-cps/notebooks/batch_processing/script/helper_functions.py in parse_scenario_file(configuration, file_scenario)
120 '''
121 path_file_full = os.path.join(configuration['input_path'], file_scenario)
--> 122 scenario, planning_problem_set = CommonRoadFileReader(path_file_full).open()
123
124 # get configuration for each scenario
/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py in open(self)
81 """
82 self._read_header()
---> 83 scenario = self._open_scenario()
84 planning_problem_set = self._open_planning_problem_set(scenario.lanelet_network)
85 return scenario, planning_problem_set
/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py in _open_scenario(self)
101 """
102 scenario = ScenarioFactory.create_from_xml_node(self._tree, self._dt, self._benchmark_id,
--> 103 self._commonroad_version, self._meta_data)
104 return scenario
105
/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py in create_from_xml_node(cls, xml_node, dt, benchmark_id, commonroad_version, meta_data)
203 scenario.add_objects(LaneletNetworkFactory.create_from_xml_node(xml_node))
204 if commonroad_version == '2018b':
--> 205 scenario.add_objects(cls._obstacles_2018b(xml_node, scenario.lanelet_network))
206 for key, value in LaneletFactory._speed_limits.items():
207 for lanelet in value:
/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py in _obstacles_2018b(cls, xml_node, lanelet_network)
240 obstacles.append(StaticObstacleFactory.create_from_xml_node(o, lanelet_network))
241 elif o.find('role').text == 'dynamic':
--> 242 obstacles.append(DynamicObstacleFactory.create_from_xml_node(o, lanelet_network))
243 else:
244 raise ValueError('Role of obstacle is unknown. Got role: {}'.format(xml_node.find('role').text))
/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py in create_from_xml_node(cls, xml_node, lanelet_network)
1047 lanelet_network, obstacle_id, shape)
1048 center_lanelet_assignment = cls.find_obstacle_center_lanelets(initial_state, trajectory.state_list,
-> 1049 lanelet_network)
1050 prediction = TrajectoryPrediction(trajectory, shape, center_lanelet_assignment, shape_lanelet_assignment)
1051 elif xml_node.find('occupancySet') is not None:
/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py in find_obstacle_center_lanelets(initial_state, state_list, lanelet_network)
1020
1021 for state in compl_state_list:
-> 1022 lanelet_ids = lanelet_network.find_lanelet_by_position([state.position])[0]
1023 lanelet_ids_per_state[state.time_step] = set(lanelet_ids)
1024
/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/scenario/lanelet.py in find_lanelet_by_position(self, point_list)
1206 mapped = list()
1207 for lanelet_id, poly in polygons:
-> 1208 if poly.contains_point(point):
1209 mapped.append(lanelet_id)
1210 res.append(mapped)
/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/geometry/shape.py in contains_point(self, point)
375 'not a vector of real numbers of length 2. point = {}'\
376 .format(point)
--> 377 return self._shapely_polygon.intersects(shapely.geometry.Point(point))
378