README.md 4.63 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Graph Search-Based Motion Planner with Motion Primitives

This is a programming exercise for the lecture **Introduction to Artificial Intelligence** (WS19) delivered at the  Department of Informatics, TUM. Please clone this repository or download it using the button at the upper-right corner. The repository has the following folder structure:
``` code-block:: text
commonroad-search/
	├GSMP/
		├motion_automata/
			├automata/
			├motion_primitives/
			└vehicle_model/
		└tools/
			├commonroad-collision-checker/
			└commonroad-road-boundary/
	├notebooks/	
		├batch_processing/
		├motion_primitives_generator/
		└tutorials/
	├scenarios/
		├../
		└../
	└solutions/ 
```
The codes are written in Python 3.7 and tested on Ubuntu 18.04. Please follow the installation guide below and further proceed with `notebooks/tutorials/0_Guide_for_Exercise.pdf`. 
Moritz Klischat's avatar
Moritz Klischat committed
24
25
26

## Before you start

27
28
29
30
31
We recommend using [Anaconda](https://www.anaconda.com/) to manage your environment so that even if you mess up something, you can always have a safe and clean restart. A guide for managing the environments can be found [here](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html). Also, the usage of [PyCharm](https://www.jetbrains.com/pycharm/) is highly recommended (free version available for students).

After installing Anaconda, create a new environment by command:
``` sh
 $ conda create -n commonroad-py37 python=3.7
Moritz Klischat's avatar
Moritz Klischat committed
32
```
33
34
35
36
37

Here the name of the environment is called **commonroad-py37**. You may also change this name as you wish. In such case, don't forget to change it in the following commands as well.

`Always activate` this environment before you do anything related:

Moritz Klischat's avatar
Moritz Klischat committed
38
```sh
39
40
  $ conda activate commonroad-py37
  or
Moritz Klischat's avatar
Moritz Klischat committed
41
42
  $ source activate commonroad-py37
```
43
Install `Jupyter Notebook` and supplementary modules:
Moritz Klischat's avatar
Moritz Klischat committed
44
```sh
45
  $ conda install jupyter
Moritz Klischat's avatar
Moritz Klischat committed
46
  $ conda install ipykernel
47
  $ pip install ipython-autotime
Moritz Klischat's avatar
Moritz Klischat committed
48
49
  $ conda install ipywidgets
  $ conda install sphinx
50
51
  $ jupyter nbextension install --py widgetsnbextension --user
  $ jupyter nbextension enable widgetsnbextension --user --py
Moritz Klischat's avatar
Moritz Klischat committed
52
53
```

54
## Installation guide
Moritz Klischat's avatar
Moritz Klischat committed
55

56
Please follow this installation guide if you are using your own machine. Alternatively, you can use the virtual machine image provide by us, in which all the necessary modules are installed for you already.
Moritz Klischat's avatar
Moritz Klischat committed
57

58
This exercise has three main dependencies that need to be installed.
Moritz Klischat's avatar
Moritz Klischat committed
59

60
### 1. CommonRoad-io
Moritz Klischat's avatar
Moritz Klischat committed
61

62
As documented in CommonRoad-io [Documentation](https://commonroad.in.tum.de/static/docs/commonroad-io/index.html), type in the following command to install the package:
Moritz Klischat's avatar
Moritz Klischat committed
63
64

```sh
65
  $ pip install commonroad-io
Moritz Klischat's avatar
Moritz Klischat committed
66
67
68
69
```


### 2. CommonRoad-Collision-Checker
70
Go to folder `GSMP/tools/commonroad-collision-checker/` and follow the instruction in README.rst. (You may navigate to it from this page by  for a better rendering of the .rst file)
Moritz Klischat's avatar
Moritz Klischat committed
71

72
A tutorial of CommonRoad Collision Checker can be found [here](https://commonroad.in.tum.de/tutorials/).
Moritz Klischat's avatar
Moritz Klischat committed
73

74
75
### 3. CommonRoad-Road-Boundary
Go to folder `GSMP/tools/commonroad-road-boundary/` and follow the instruction in README.md. (You may navigate to it from this page by  for a better rendering of the .md file) In case you face an error, refer to troubleshooting section. 
Moritz Klischat's avatar
Moritz Klischat committed
76

77
78
79
80
## Tutorials

Navigate your terminal to `commonroad-search/` folder, and start Jupyter Notebook with:
```shell
Moritz Klischat's avatar
Moritz Klischat committed
81
82
83
  $ jupyter notebook
```

84
In the prompt up page, navigate to `notebooks/tutorials/` and follow the tutorials `tutorial_commonroad-io.ipynb` and `tutorial_commonroad-search.ipynb`.  Remember to refer to `tutorials/0_Guide_for_Exercise.pdf` for additional explanation. The executed Jupyter notebooks for tutorials can also be found [here](https://commonroad.in.tum.de/tutorials/).
Moritz Klischat's avatar
Moritz Klischat committed
85
86
87

## Implement your own search algorithm

88
Open `GSMP/motion_automata/automata/MotionPlanner.py`. Write your own heuristic functions and/or search algorithm in the following functions:
Moritz Klischat's avatar
Moritz Klischat committed
89
90

```python
91
92
	def calc_heuristic_cost()
	def search_alg()
Moritz Klischat's avatar
Moritz Klischat committed
93
94
```

95
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.
Moritz Klischat's avatar
Moritz Klischat committed
96

97
## Troubleshooting
Moritz Klischat's avatar
Moritz Klischat committed
98

99
### 1. Boundary library not working properly
Moritz Klischat's avatar
Moritz Klischat committed
100

101
102
If there are errors stating not finding the boundary library (e. g. module `construction` not found) while going through the second tutorial, try manually copying all the contents under folder `GSMP/tools/commonroad-road-boundary/`  into `/path/to/your/anaconda3/envs/lib/python3.7/site-packages/commonroad-road-boundary/`. 
`Make sure to copy all files within the folder manually, not just copying the folder it self. Also, remember to add this path to your IDE's (e. g. PyCharm) interpretor path.`