Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
tum-cps
commonroad-search
Commits
e6b85311
Commit
e6b85311
authored
Nov 24, 2020
by
Edmond Irani Liu
🏂
Browse files
remove deprecated README
parent
bc9025c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
tutorials/1_search_algorithms/README_TREESEARCH.md
deleted
100644 → 0
View file @
bc9025c6
Tutorials on Tree Search Algorithms
============
This is a short guide on how to use the search algorithms in
`GSMP/motion_planner/search_algorithms`
for lectures and tutorials.
Set up
============
For using the code, you have to install the tools as described in the README in the root folder. For using the code in
Pycharm, open a new project in the repository's root directory
`graph-search-planner`
and set the
`commonroad-search/GSMP`
folder as
*Source Root*
, to avoid path issues.
# Documentation
For running the search algorithms, you can currently specify three different configurations which mainly influence the
visualization of the search and are defined in
`GSMP/motion_planner/PlotConfig.py`
:
### Default:
*
This configuration should only be used in the jupyter notebook tutorial
(
`step_1_tutorial_notebooks/step_1_1_cr_uninformed_search_tutorial.ipynb`
and
`step_1_tutorial_notebooks/step_1_2_cr_informed_search_tutorial.ipynb`
).
It first runs the algorithm and stores the state of each motion primitive,
i.e., explored/frontier/currently exploring etc., for each step.
Then it plots these steps using
*ipywidgets*
, so the student can step through the search in the jupyter notebook.
*
The color code for plotting is taken from the AIMA tutorial, but can be changed
in
`GSMP/motion_planner/PlotConfig.py`
.
*
By setting PLOT_LEGEND to True, a legend with all states of
motion primitives (see
`MotionPrimitiveStatus`
in
`GSMP/motion_planner/PlotHelper.py`
) is plotted.
*
To reduce the number of steps, you can turn off that motion primitives with collisions are plotted one
after the other by setting PLOT_COLLISION_STEPS to False.
### StudentScript:
This configuration uses the same parameters as the Default configuration, but it can be run in Pycharm,
e.g. when executing
`main.py`
. It plots the different steps while executing the search algorithm. It should help
students to easily go through the code.
# How to run
It is advised to add the directory
`1_basics-tree_search_algorithms`
to your python interpreter as
*Source Root*
.
It fixes the Unresolved References error messages in PyCharm.
It can be run in two different ways:
###Jupyter Notebook
Start a Jupyter Server, then navigate to the directory
`step_1_tutorial_notebooks`
, open up the notebooks and follow
instructions.
###Python script
Simply run the
`main.py`
from the directory
`1_basics-tree_search_algorithms`
. In PyCharm it can be achieved with a
right click on the file
`main.py`
and then
*Run*
.
\ No newline at end of file
tutorials/1_search_algorithms/example.py
View file @
e6b85311
...
...
@@ -18,51 +18,57 @@ from maneuver_automaton.maneuver_automaton import ManeuverAutomaton
from
motion_planner.motion_planner
import
MotionPlanner
from
motion_planner.plot_config
import
StudentScriptPlotConfig
# configurations
path_scenario
=
'../../scenarios/tutorial/ZAM_Tutorial_Urban-3_2.xml'
id_type_vehicle
=
2
file_motion_primitives
=
'V_9.0_9.0_Vstep_0_SA_-0.2_0.2_SAstep_0.4_T_0.5_Model_BMW320i.xml'
config_plot
=
StudentScriptPlotConfig
(
DO_PLOT
=
True
)
# load scenario and planning problem set
scenario
,
planning_problem_set
=
CommonRoadFileReader
(
path_scenario
).
open
()
# retrieve the first planning problem
planning_problem
=
list
(
planning_problem_set
.
planning_problem_dict
.
values
())[
0
]
# plot scenario
plt
.
figure
(
figsize
=
(
8
,
8
))
draw_object
(
scenario
)
draw_object
(
planning_problem_set
)
plt
.
gca
().
set_aspect
(
'equal'
)
plt
.
margins
(
0
,
0
)
plt
.
show
()
# close the figure to continue!
# create maneuver automaton and planning problem
automaton
=
ManeuverAutomaton
.
generate_automaton
(
file_motion_primitives
)
# comment out the planners which you don't want to execute
dict_motion_planners
=
{
0
:
(
MotionPlanner
.
BreadthFirstSearch
,
"Breadth First Search"
),
1
:
(
MotionPlanner
.
DepthFirstSearch
,
"Depth First Search"
),
2
:
(
MotionPlanner
.
DepthLimitedSearch
,
"Depth Limited Search"
),
3
:
(
MotionPlanner
.
UniformCostSearch
,
"Uniform Cost Search"
),
4
:
(
MotionPlanner
.
GreedyBestFirstSearch
,
"Greedy Best First Search"
),
5
:
(
MotionPlanner
.
AStarSearch
,
"A* Search"
)
# 6: (MotionPlanner.StudentMotionPlanner, "Student Planner"),
# 7: (MotionPlanner.StudentMotionPlannerExample, "Student Planner Example")
}
for
(
class_planner
,
name_planner
)
in
dict_motion_planners
.
values
():
planner
=
class_planner
(
scenario
=
scenario
,
planning_problem
=
planning_problem
,
automaton
=
automaton
,
plot_config
=
config_plot
)
# start search
print
(
name_planner
+
" started.."
)
planner
.
execute_search
()
plt
.
title
(
name_planner
)
# close the figure to continue
def
main
():
# configurations
path_scenario
=
'../../scenarios/tutorial/ZAM_Tutorial_Urban-3_2.xml'
id_type_vehicle
=
2
file_motion_primitives
=
'V_9.0_9.0_Vstep_0_SA_-0.2_0.2_SAstep_0.4_T_0.5_Model_BMW320i.xml'
config_plot
=
StudentScriptPlotConfig
(
DO_PLOT
=
True
)
# load scenario and planning problem set
scenario
,
planning_problem_set
=
CommonRoadFileReader
(
path_scenario
).
open
()
# retrieve the first planning problem
planning_problem
=
list
(
planning_problem_set
.
planning_problem_dict
.
values
())[
0
]
# plot scenario
plt
.
figure
(
figsize
=
(
8
,
8
))
draw_object
(
scenario
)
draw_object
(
planning_problem_set
)
plt
.
gca
().
set_aspect
(
'equal'
)
plt
.
margins
(
0
,
0
)
plt
.
show
()
# close the figure to continue!
# create maneuver automaton and planning problem
automaton
=
ManeuverAutomaton
.
generate_automaton
(
file_motion_primitives
)
# comment out the planners which you don't want to execute
dict_motion_planners
=
{
0
:
(
MotionPlanner
.
BreadthFirstSearch
,
"Breadth First Search"
),
# 1: (MotionPlanner.DepthFirstSearch, "Depth First Search"),
# 2: (MotionPlanner.DepthLimitedSearch, "Depth Limited Search"),
# 3: (MotionPlanner.UniformCostSearch, "Uniform Cost Search"),
# 4: (MotionPlanner.GreedyBestFirstSearch, "Greedy Best First Search"),
5
:
(
MotionPlanner
.
AStarSearch
,
"A* Search"
)
# 6: (MotionPlanner.StudentMotionPlanner, "Student Planner"),
# 7: (MotionPlanner.StudentMotionPlannerExample, "Student Planner Example")
}
for
(
class_planner
,
name_planner
)
in
dict_motion_planners
.
values
():
planner
=
class_planner
(
scenario
=
scenario
,
planning_problem
=
planning_problem
,
automaton
=
automaton
,
plot_config
=
config_plot
)
# start search
print
(
name_planner
+
" started.."
)
planner
.
execute_search
()
plt
.
title
(
name_planner
)
# close the figure to continue
plt
.
show
()
print
(
'Done'
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment