Lecture 02 Discrete Motion Planning
Lecture 02 Discrete Motion Planning
If you are experienced in python, there will probably be no news for you.
4
Start
Edges
1891
Edges could have
weights/costs/lengths
Goal
10
5 8 2
1 3
7 4 6
5 8 2
1 4 3
7 6 2
5 8
11
X = {1, . . . , 25}
4 9 14 19 24
U (x) ⊆ {Up, Down, Left, Right} G
xI = 1, xG = 14
3 8 13 18 23
<latexit sha1_base64="SbJcnYSNz01U35KGQVDSSUm+bZQ=">AAACa3icbVFda9RAFJ2kftRV62ofFPVhcGmpUJZk3dL2QSgqqOBDFdMubJYwmb3ZHTqZpDM3dZeQF3+ib/4DX/wPTrJh8evAwLnnfnImzqUw6HnfHXfj2vUbNzdvdW7fubt1r3v/wZnJCs0h4JnM9ChmBqRQEKBACaNcA0tjCefxxes6f34F2ohMfcZlDpOUzZRIBGdopaj7NUwZzjmT5aiiuy9pWPr7NJxmaPbp4CCswrAT7C2e093QFLEBhEtbEiIssAzyypY29E32Ra2DD5DgOvgkZnOsmjmL6H29oZ5/WbApXURvqQ2HUbfn9b0G9F/it6RHWpxG3W/2QF6koJBLZszY93KclEyj4BKqTlgYyBm/YDMYW6pYCmZSNl5VdMcqU5pk2j6FtFF/7yhZaswyjW1l7Yz5O1eL/8uNC0yOJqVQeYGg+GpRUkiKGa2Np1OhgaNcWsK4FvZWyudMM472ezqNCccN6IocDlty7K9NOBv0/Rf9wcdh7+RVa8cmeUKekT3ik0NyQt6RUxIQTn44W85D55Hz0912H7tPV6Wu0/Zskz/g7vwCNl23jg==</latexit>
0
x = f (x, u) ∈ X
<latexit sha1_base64="gf2DqGDZaF+P8gvFl/WoAI84rhw=">AAACBHicbZDLSsNAFIYn9VbrLeqym8EiVpCS1ELtQii6cVnBXqAJZTKdtEMnkzAzkZbQhRtfxY0LRdz6EO58G5M0iLcfBj7+cw7nzO8EjEplGB9abml5ZXUtv17Y2Nza3tF39zrSDwUmbewzX/QcJAmjnLQVVYz0AkGQ5zDSdSaXSb17S4SkPr9Rs4DYHhpx6lKMVGwN9OL0CJ5Dtzw9geExtCi3PKTGGLGoNx/oJaNipIJ/wcygBDK1Bvq7NfRx6BGuMENS9k0jUHaEhKKYkXnBCiUJEJ6gEenHyJFHpB2ln5jDw9gZQtcX8eMKpu73iQh5Us48J+5MTpS/a4n5X60fKvfMjigPQkU4XixyQwaVD5NE4JAKghWbxYCwoPGtEI+RQFjFuRXSEBqp4ALqtQwa5lcInWrFPK1Ur2ul5kUWRx4UwQEoAxPUQRNcgRZoAwzuwAN4As/avfaovWivi9acls3sgx/S3j4Bi1GXMg==</latexit>
2 7 12 17 22
U (8) = {Left, Down}
<latexit sha1_base64="Qvg02Rg2u6y6qrXJFHFZa52nm6g=">AAACDHicbVDLSgMxFM34rPVVdekmWAQFKTMq6EYQdeHCRQWrhU4pmfRODWYyQ3JHLcN8gBt/xY0LRdz6Ae78G9PHQq0HAifnnEtyT5BIYdB1v5yx8YnJqenCTHF2bn5hsbS0fGniVHOo8VjGuh4wA1IoqKFACfVEA4sCCVfBzXHPv7oFbUSsLrCbQDNiHSVCwRlaqVUq1zb2N+kB9TMf4R6zMwgx36KDy0l8p3I/tym34vZBR4k3JGUyRLVV+vTbMU8jUMglM6bhuQk2M6ZRcAl50U8NJIzfsA40LFUsAtPM+svkdN0qbRrG2h6FtK/+nMhYZEw3CmwyYnht/no98T+vkWK438yESlIExQcPhamkGNNeM7QtNHCUXUsY18L+lfJrphlH21/RluD9XXmUXG5XvJ3K9vlu+fBoWEeBrJI1skE8skcOySmpkhrh5IE8kRfy6jw6z86b8z6IjjnDmRXyC87HN46Nmrk=</latexit>
18
u = Up 1 6 11 16 21
f (17, u) = 22 u = Right S
16 u = Down
<latexit sha1_base64="XXLiyZOZlwP/lytqTZPm2RlvEk4=">AAACUHicbZHPb9MwFMdfOn5s4ccKO3KxqIaGhKqkTHQ7TJoGB44D0W1SU1WO+5Jac5zIfgGqqH/iLrvt7+DCYWhz04Ao7CtZ/urznp+tr+NCSUtBcOW11u7df/BwfcN/9PjJ0832s+cnNi+NwIHIVW7OYm5RSY0DkqTwrDDIs1jhaXz+flE//YrGylx/oVmBo4ynWiZScHJo3E6TnbD/hpWv2QHzoxhTqSvh5tm5H+6xV6x0PCL8TtWgmEeR3+utwM8yndKCh+9W+If8m577EepJM23c7gTdoBb734SN6UCj43H7MprkosxQk1Dc2mEYFDSquCEpFLrZpcWCi3Oe4tBZzTO0o6oOZM62HZmwJDduaWI1/ftExTNrZ1nsOjNOU/tvbQHvqg1LSvZGldRFSajF8qKkVIxytkiXTaRBQWrmDBdGurcyMeWGC3J/4Nch7NdiS9Pfbcx++CeEk143fNvtfdrtHB41cazDC3gJOxBCHw7hIxzDAARcwA+4hl/epffTu2l5y9bfO2zBilr+Lap9sCo=</latexit>
13
5 8 2
search
Up Right
¥ Build search tree and explore
Left
until solution is found Down
5 8 2 5 8 2 5 2 5 8 2
¥ depth first
Left Right Up Down Left Right Up Down
¥ breadth first
¥ É 4 3 1 3 4 3 1 4 3 1 4 3 1 4 3 1 4 1 4 3
1 7 6 7 4 6 1 7 6 5 7 6 7 8 6 7 8 6 7 6 3 7 6 2
5 8 2 5 8 2 5 8 2 8 2 5 2 5 2 5 8 2 5 8
14
Queues
¥ A queue is a data structure where you can
¥ Push (or insert) elements on the queue
¥ Pop (or remove) elements from the queue
¥ Very useful for describing and implementing search algorithms
¥ Three different queues will be used
¥ FIFO - First In First Out
¥ LIFO - Last In First Out
¥ Priority Queue - assign priority to each element
≈ efficiently keep the queue always sorted (not exactly true but É)
Will return to this queue later.
15
4 9 14 19 24
G
3 8 13 18 23
2 7 12 17 22
1 6 11 16 21
S
18
x′ = previous(x)
1 function B a c k t r a c k ( v i s i t e d , s o u r c e , g o a l ) :
2 i f found
defines the path. 3 p = ;
4 u = goal
¥ Node x is the predecessor 5 while p r e v i o u s [ u ] 6= s t a r t
6 i n s e r t u at the beginning of p
of node x′ 7 u = previous [ u ]
8 i n s e r t u at the beginning of p
¥ Backtracking from goal to
start then gives the path
20
G G
¥ Clearly neither depth-first nor breadth-first finds the shortest path in the
graph
¥ Not surprising since there is no notion of distance/stage-cost in the search
¥ Next step is to find shortest paths É
Dijkstra’s algorithm - finding shortest path
22
Dijkstra’s algorithm
¥ Well known algorithm, first published in the 1950Õs
¥ Computes, not only the shortest path between two nodes
¥ Not only that, it can compute the shortest path between a source node
and all other nodes; shortest path tree
(hint: useful in extra assignment for HI1)
¥ Idea:
¥ keep track of cost-to-come for each visited node, and
¥ explore the tree search prioritized by cost-to-come
¥ Use Priority Queues instead of FIFO/LIFO
23
Priority Queue
¥ You can insert and pop (element, priority) pairs
¥ Here priority is typically path cost (length/time)
¥ Operations (for min-priority queue)
¥ insert(element, priority) - insert pair into the queue
¥ pop() - returns element and priority corresponding to the lowest priority
¥ decrease_key(element, priority) - change priority for an element
¥ In general, you can decrease an elements priority by pushing it again
¥ This is not strictly needed, I will come back to this; lazy delete
¥ Insert and pop are no longer constant time operations, typically 𝒪(log n)
for implementations based on a data-structure called heap
24
Dijkstra’s algorithm
1 function D i j k s t r a :
¥ d(x, x′) cost (∼ length) to go from 2 C(xI ) = 0
3 Q. i n s e r t ( xI , C(xI ) )
node x to x′ 4
A B
C C? Here path to C
is rewired
G
26
Dijkstra’s algorithm
Start: 1 Pop 5: 17 21
5 10 15 20 25 Prio 0 Prio 4 4
Pop 1: 2 6 Pop 17: 21 18 22
Prio 1 1 Prio 4 5 5
Pop 2: 6 3 7 Pop 21: 18 22
4 9 14 19 24 Prio 1 2 2 Prio 5 5
Pop 6: 3 7 11 Pop 18: 22 19 23
G Prio 2 2 2 Prio 5 6 6
Pop 3: 7 11 4 8 Pop 22: 19 23
3 8 13 18 23 Prio 2 2 3 3 Prio 6 6
Pop 7: 11 4 8 Pop 19: 23 14 20 24
Prio 2 3 3 Prio 6 7 7 7
Pop 11: 4 8 16 Pop 23: 14 20 24
2 7 12 17 22 Prio 3 3 3 Prio 7 7 7
Pop 4: 8 16 5 Pop 14: Goal
Prio 3 3 4
Pop 8: 16 5
1 6 11 16 21 Prio 3 4
S Pop 16:
Prio
5 17 21
4 4 4
Node Previous Cost 27
node 10
11 6 2
12
¥ Cost(x) - current cost to come 13
14 19 7
¥ Using Previous(x), backtracking gives 15
16 11 3
the resulting path 17 16 4
18 17 5
¥ 14 - 19 - 18 - 17 - 16 - 11 - 6 - 1 19 18 6
20 19 7
¥ Note that you get minimum length 21 16 4
A*
5.38 km path
6594 nodes visited
Depth First
26 km path
7570 nodes visited
Dijkstra
5.38 km path
11626 nodes visited
A* - efficiently finding an optimal path
32
<
Strategy:
1. Prioritize nodes according to estimated final length
2. Explore nodes in the search that have high chance to be in optimal path.
33
C(x) + h(x)
C(x) + h(x)
Note that no node is excluded from the search, it is just put way back in the
queue if the expected cost to go through that node is high!
37
h=7 5 h=0
38
<
Explore nodes in the search that have high chance to be in optimal path; here
means explore nodes that, with underestimated cost-to-go, is cheaper than others
40
Resulting path 1
2
1
1
0
1
¥ During A* search, two functions are 3 2 2
4 3 3
updated 5 4 4
6 1 1
¥ Previous(x) - keep track of parent 7 2 2
node 8
9
3 3
10
¥ Cost(x) - current cost to come 11 6 2
12
¥ Using Previous(x), backtracking gives 13
the resulting path 14
15
19 7
¥ 14 - 19 - 18 - 17 - 16 - 11 - 6 - 1 16
17
11
16
3
5
18 17 5
19 18 6
20 19 7
21 16 5
22 17 5
23 18 6
24 19 7
25
A closer look at heuristics —
consistent and admissible heuristics
43
Figure from: “Optimisation based path planning for car parking in narrow
environments”, P. Zips et.al., Robotics and Autonomous Systems, 2016
45
h(x) = | x − xg |
(x, y, θ)
h(x) = ?
54
hc(x) = c h(x)
7L
55
Reading instructions
¥ ÒPlanning AlgorithmsÓ, Chapter 2 (mainly sections 2.1-2.3), S. LaValle.
¥ Want to dig a little deeper? HereÕs some extra reading for the interested É
¥ ÒARA*: Anytime A* with provable bounds on sub-optimality.Ó,
Likhachev et al. Advances in neural information processing systems,
2004.
¥ ÒPriority queues and Dijkstra's algorithmÓ, Chen, Mo, et al.. Computer
Science Department, University of Texas at Austin, 2007.
¥ Connections to dynamic optimization, optimal control, and
reinforcement learning
Bertsekas, D. (2019). ÒReinforcement learning and optimal controlÓ.
Athena Scientific.
https://www.mit.edu/~dimitrib/RLbook.html
59
(x, y, θ) = (0,0,0)