Skip to content

Commit c70add3

Browse files
authored
add visibility road map path doc (AtsushiSakai#592)
* add visibility road map path doc * add visibility road map path doc * add visibility road map path doc * add visibility road map path doc * add visibility road map path doc * add visibility road map path doc * add visibility road map path doc
1 parent 4d60c3c commit c70add3

File tree

9 files changed

+87
-11
lines changed

9 files changed

+87
-11
lines changed

PathPlanning/VisibilityRoadMap/geometry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class Geometry:
2+
23
class Point:
34
def __init__(self, x, y):
45
self.x = x
@@ -40,4 +41,4 @@ def orientation(p, q, r):
4041
if (o4 == 0) and on_segment(p2, q1, q2):
4142
return True
4243

43-
return False
44+
return False

PathPlanning/VisibilityRoadMap/visibility_road_map.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323

2424
class VisibilityRoadMap:
2525

26-
def __init__(self, robot_radius, do_plot=False):
27-
self.robot_radius = robot_radius
26+
def __init__(self, expand_distance, do_plot=False):
27+
self.expand_distance = expand_distance
2828
self.do_plot = do_plot
2929

3030
def planning(self, start_x, start_y, goal_x, goal_y, obstacles):
3131

32-
nodes = self.generate_graph_node(start_x, start_y, goal_x, goal_y,
33-
obstacles)
32+
nodes = self.generate_visibility_nodes(start_x, start_y,
33+
goal_x, goal_y, obstacles)
3434

3535
road_map_info = self.generate_road_map_info(nodes, obstacles)
3636

@@ -48,7 +48,8 @@ def planning(self, start_x, start_y, goal_x, goal_y, obstacles):
4848

4949
return rx, ry
5050

51-
def generate_graph_node(self, start_x, start_y, goal_x, goal_y, obstacles):
51+
def generate_visibility_nodes(self, start_x, start_y, goal_x, goal_y,
52+
obstacles):
5253

5354
# add start and goal as nodes
5455
nodes = [DijkstraSearch.Node(start_x, start_y),
@@ -129,8 +130,8 @@ def calc_offset_xy(self, px, py, x, y, nx, ny):
129130
offset_vec = math.atan2(math.sin(p_vec) + math.sin(n_vec),
130131
math.cos(p_vec) + math.cos(
131132
n_vec)) + math.pi / 2.0
132-
offset_x = x + self.robot_radius * math.cos(offset_vec)
133-
offset_y = y + self.robot_radius * math.sin(offset_vec)
133+
offset_x = x + self.expand_distance * math.cos(offset_vec)
134+
offset_y = y + self.expand_distance * math.sin(offset_vec)
134135
return offset_x, offset_y
135136

136137
@staticmethod
@@ -184,7 +185,7 @@ def main():
184185
sx, sy = 10.0, 10.0 # [m]
185186
gx, gy = 50.0, 50.0 # [m]
186187

187-
robot_radius = 5.0 # [m]
188+
expand_distance = 5.0 # [m]
188189

189190
obstacles = [
190191
ObstaclePolygon(
@@ -209,8 +210,8 @@ def main():
209210
plt.axis("equal")
210211
plt.pause(1.0)
211212

212-
rx, ry = VisibilityRoadMap(robot_radius, do_plot=show_animation).planning(
213-
sx, sy, gx, gy, obstacles)
213+
rx, ry = VisibilityRoadMap(expand_distance, do_plot=show_animation)\
214+
.planning(sx, sy, gx, gy, obstacles)
214215

215216
if show_animation: # pragma: no cover
216217
plt.plot(rx, ry, "-r")

docs/modules/path_planning/grid_base_search/grid_base_search.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This is a 2D grid based path planning with Depth first search algorithm.
1919

2020
In the animation, cyan points are searched nodes.
2121

22+
.. _dijkstra:
23+
2224
Dijkstra algorithm
2325
~~~~~~~~~~~~~~~~~~
2426

docs/modules/path_planning/path_planning_main.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Path Planning
99
.. include:: model_predictive_trajectory_generator/model_predictive_trajectory_generator.rst
1010
.. include:: state_lattice_planner/state_lattice_planner.rst
1111
.. include:: prm_planner/prm_planner.rst
12+
.. include:: visibility_road_map_planner/visibility_road_map_planner.rst
1213
.. include:: vrm_planner/vrm_planner.rst
1314
.. include:: rrt/rrt.rst
1415
.. include:: cubic_spline/cubic_spline.rst
Loading
Loading
Loading
Loading
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Visibility Road-Map planner
2+
---------------------------
3+
4+
.. image:: https://github.com/AtsushiSakai/PythonRoboticsGifs/raw/master/PathPlanning/VisibilityRoadMap/animation.gif
5+
6+
`[Code] <https://github.com/AtsushiSakai/PythonRobotics/blob/master/PathPlanning/VisibilityRoadMap/visibility_road_map.py>`_
7+
8+
This visibility road-map planner uses Dijkstra method for graph search.
9+
10+
In the animation, the black lines are polygon obstacles,
11+
12+
red crosses are visibility nodes, and blue lines area collision free visibility graphs.
13+
14+
The red line is the final path searched by dijkstra algorithm frm the visibility graphs.
15+
16+
Algorithms
17+
~~~~~~~~~~
18+
19+
In this chapter, how does the visibility road map planner search a path.
20+
21+
We assume this planner can be provided these information in the below figure.
22+
23+
- 1. Start point (Red point)
24+
- 2. Goal point (Blue point)
25+
- 3. Obstacle polygons (Black lines)
26+
27+
.. image:: visibility_road_map_planner/step0.png
28+
:width: 400px
29+
30+
31+
Step1: Generate visibility nodes based on polygon obstacles
32+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33+
34+
The nodes are generated by expanded these polygons vertexes like the below figure:
35+
36+
.. image:: visibility_road_map_planner/step1.png
37+
:width: 400px
38+
39+
Each polygon vertex is expanded outward from the vector of adjacent vertices.
40+
41+
The start and goal point are included as nodes as well.
42+
43+
Step2: Generate visibility graphs connecting the nodes.
44+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45+
46+
When connecting the nodes, the arc between two nodes is checked to collided or not to each obstacles.
47+
48+
If the arc is collided, the graph is removed.
49+
50+
The blue lines are generated visibility graphs in the figure:
51+
52+
.. image:: visibility_road_map_planner/step2.png
53+
:width: 400px
54+
55+
56+
Step3: Search the shortest path in the graphs using Dijkstra algorithm
57+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
59+
The red line is searched path in the figure:
60+
61+
.. image:: visibility_road_map_planner/step3.png
62+
:width: 400px
63+
64+
You can find the details of Dijkstra algorithm in :ref:`dijkstra`.
65+
66+
References
67+
^^^^^^^^^^
68+
69+
- `Visibility graph - Wikipedia <https://en.wikipedia.org/wiki/Visibility_graph>`_
70+
71+

0 commit comments

Comments
 (0)