You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/docs/route_graph_generation.rst
+48-49Lines changed: 48 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
.. _route_graph_generation:
1
+
.. _route_graph_generation:
2
2
3
3
Route Graph Generation
4
4
**********************
@@ -19,16 +19,16 @@ Tutorial Steps
19
19
==============
20
20
21
21
22
-
1- Create New QGIS Project
22
+
1- Create New QGIS Project
23
23
--------------------------
24
24
25
-
Open QGIS and create a new project by selecting `Project->New`. Save your project by selecting, `Project -> Save As`.
26
-
Set the project coordinate reference system by selecting `Project->Properties->CRS`. Set the coordinate system to `WGS 84 / Pseudo-Mercator` and click `OK`.
25
+
Open QGIS and create a new project by selecting `Project->New`. Save your project by selecting, `Project -> Save As`.
26
+
Set the project coordinate reference system by selecting `Project->Properties->CRS`. Set the coordinate system to `WGS 84 / Pseudo-Mercator` and click `OK`.
27
27
28
28
29
-
.. note::
30
-
The `WGS 84/ Pseudo-Mercator` is one of few coordinate systems that could be used.
31
-
For more information about coordinate reference systems please review https://docs.qgis.org/3.22/en/docs/gentle_gis_introduction/coordinate_reference_systems.html.
29
+
.. note::
30
+
The `WGS 84/ Pseudo-Mercator` is one of few coordinate systems that could be used.
31
+
For more information about coordinate reference systems please review https://docs.qgis.org/3.22/en/docs/gentle_gis_introduction/coordinate_reference_systems.html.
32
32
33
33
|
34
34
@@ -39,22 +39,22 @@ Set the project coordinate reference system by selecting `Project->Properties->C
39
39
40
40
|
41
41
42
-
2- Setup Coordinate System
42
+
2- Setup Coordinate System
43
43
--------------------------
44
44
45
45
By default, the imported raster image origin will be at the top left corner, with x pointing to the right, and y pointing up.
46
-
To correctly set the orgin and the resolution we will georeference the raster image.
47
-
To georeference the image, three control points will choosen. Each control point maps a pixel location to the spatial reference.
46
+
To correctly set the origin and the resolution we will georeference the raster image.
47
+
To georeference the image, three control points will chosen. Each control point maps a pixel location to the spatial reference.
48
48
49
49
For example, let's say you have a 100 by 200 raster image with a resolution of 0.05 and a origin in the bottom left corner.
50
50
The first control point we could select is (0, -200)px -> (0, 0)m. (0, -200)px is the bottom left corner in the pixel frame and (0, 0)m is coordinates in the spatial frame.
51
51
This is the convention of our ROS maps, typically.
52
-
For the second control point we will select the top left corner of the image as the original (0, 0)px. The associated coordinates in the spatial frame can be calculated by using the resolution
53
-
to convert the pixels to meters. In this case, (0, 0)px -> (0, 10)m. Where 10 m is 200 px* 0.05 m/px. The last control will be the bottom right corner: (100, -200)px -> (5, 0)m.
52
+
For the second control point we will select the top left corner of the image as the original (0, 0)px. The associated coordinates in the spatial frame can be calculated by using the resolution
53
+
to convert the pixels to meters. In this case, (0, 0)px -> (0, 10)m. Where 10 m is 200 px* 0.05 m/px. The last control will be the bottom right corner: (100, -200)px -> (5, 0)m.
54
+
It is recommended to set the origin of your map to the lower left corner of the image (``[0.0, 0.0, 0.0]`` in your ``map.yaml``), to make this process easier.
54
55
55
-
56
-
To georeference image select `Raster -> Georefencer`. Set the `Trasformation Settings` to `Linear` for `Transformation
57
-
type`, `WGS 84/ Pseudo-Mercator` for `Target SRS` and set your desired path for the `Output Raster`.
56
+
To georeference image select `Raster -> Georefencer`. Set the `Transformation Settings` to `Linear` for `Transformation
57
+
type`, `WGS 84/ Pseudo-Mercator` for `Target SRS` and set your desired path for the `Output Raster`.
58
58
59
59
|
60
60
@@ -65,9 +65,9 @@ type`, `WGS 84/ Pseudo-Mercator` for `Target SRS` and set your desired path for
65
65
66
66
|
67
67
68
-
Select the raster image you wish to georeference and place control point by selecting `Add Point` and clicking on the raster image.
69
-
The control points can be modified by clicking on the control point table and typing in new values. Once you are satified with your control points, apply the transformation
70
-
by selecting `Start Transformation`.
68
+
Select the raster image you wish to georeference and place control point by selecting `Add Point` and clicking on the raster image.
69
+
The control points can be modified by clicking on the control point table and typing in new values. Once you are satisfied with your control points, apply the transformation
70
+
by selecting `Start Transformation`.
71
71
72
72
|
73
73
@@ -89,16 +89,16 @@ Close the window. Drag and drop the georeferenced raster file that was just crea
89
89
90
90
|
91
91
92
-
To verify the transformation worked, move the mouse around the raster image and look at the coordinates being displayed at the bottom of the window.
92
+
To verify the transformation worked, move the mouse around the raster image and look at the coordinates being displayed at the bottom of the window.
93
93
94
-
3- Add Nodes
94
+
3- Add Nodes
95
95
------------
96
96
97
97
Now that we have georeferenced the raster layer we can start placing nodes.
98
98
99
99
100
-
Select `Layer -> Create Layer -> New ShapeFile Layer`. Set the shapefile layer setting to be
101
-
`nodes` for the `File name`, `Point` for the `Geometry type` and `WGS 84/ Pseudo-Mercator` for the coordinate system. Press `OK`.
100
+
Select `Layer -> Create Layer -> New ShapeFile Layer`. Set the shapefile layer setting to be
101
+
`nodes` for the `File name`, `Point` for the `Geometry type` and `WGS 84/ Pseudo-Mercator` for the coordinate system. Press `OK`.
102
102
103
103
|
104
104
@@ -109,7 +109,7 @@ Select `Layer -> Create Layer -> New ShapeFile Layer`. Set the shapefile layer s
109
109
110
110
|
111
111
112
-
In order to have the `id` field auto increment, right click on the layer and select the `Properties -> Attribute Form`.
112
+
In order to have the `id` field auto increment, right click on the layer and select the `Properties -> Attribute Form`.
113
113
Expand the `Fields` drop down menu and select `id`. Select the `Expression Dialog` icon which is across from `Default value` field.
114
114
115
115
|
@@ -122,9 +122,9 @@ Expand the `Fields` drop down menu and select `id`. Select the `Expression Dialo
122
122
|
123
123
124
124
125
-
Within the `Expression Dialog` select `Import user expressions` and import `increment_node_id.json` which exists in the scripts file with the nav2 route module. Expand `User expressions` and double click on `increment_node_id`.
125
+
Within the `Expression Dialog` select `Import user expressions` and import `increment_node_id.json` which exists in the scripts file with the nav2 route module. Expand `User expressions` and double click on `increment_node_id`.
126
126
The expression should show up in the left window. Click `OK` to save the expression and exit the `Expression Dialog`. Then click `Apply` and `OK` and save and exit the `Attributes Form`.
127
-
This will increment the node `id` by one every time a new node is added. The first node `id` will be zero.
127
+
This will increment the node `id` by one every time a new node is added. The first node `id` will be zero.
128
128
129
129
|
130
130
@@ -136,7 +136,7 @@ This will increment the node `id` by one every time a new node is added. The fir
136
136
|
137
137
138
138
139
-
Click on the node layer and then select `Toggle Editing` icon represented as a pencil to start editing the layer.
139
+
Click on the node layer and then select `Toggle Editing` icon represented as a pencil to start editing the layer.
140
140
To add points, select the `Add Point Feature`. Start adding nodes by clicking in the main window.
141
141
Each time a node is added, a window will pop up with the auto incremented id. Press `OK` to continue placing points.
142
142
Once complete, unselect 'Toggle Editing' and save changes.
@@ -150,20 +150,20 @@ Once complete, unselect 'Toggle Editing' and save changes.
150
150
151
151
|
152
152
153
-
.. note::
153
+
.. note::
154
154
By default, if a is node deleted the id list will not be updated. It is up to the user to determine how they wish to update the ids if individual
155
-
or multiple nodes are deleted. Any node that is added will continue to increment based on the highest id, to ensure existing node are not automatically renumbered, breaking user implicit knowledge about the structure of the graph. This value can be overwriten by the user
156
-
though the pop window after node placement or though the `Attribute Table`. To delete features in a layer right click on the layer and select `Open Attribute Table`.
157
-
Click on `Target Multi Edit Mode`, select the features to delete, and click on the trash can icon.
155
+
or multiple nodes are deleted. Any node that is added will continue to increment based on the highest id, to ensure existing node are not automatically renumbered, breaking user implicit knowledge about the structure of the graph. This value can be overwritten by the user
156
+
though the pop window after node placement or though the `Attribute Table`. To delete features in a layer right click on the layer and select `Open Attribute Table`.
157
+
Click on `Target Multi Edit Mode`, select the features to delete, and click on the trash can icon.
158
158
159
159
160
-
4- Add Edges
160
+
4- Add Edges
161
161
------------
162
162
163
-
Now an edge layer can be created. Select `Layer -> Create Layer -> New ShapeFile Layer`. Set the shapefile layer setting to be
163
+
Now an edge layer can be created. Select `Layer -> Create Layer -> New ShapeFile Layer`. Set the shapefile layer setting to be
164
164
`edges` for the `File name`, `LineString` for the `Geometry type` and `WGS 84/ Pseudo-Mercator` for the coordinate system. Press `OK`.
165
-
To auto incrment the `id` field follow the same steps as above except replace `increment_node_id.json` with `increment_edge_id.json`.
166
-
This will increment the edge `id` by one every time a new edge is added. The first edge `id` will be `10000`.
165
+
To auto increment the `id` field follow the same steps as above except replace `increment_node_id.json` with `increment_edge_id.json`.
166
+
This will increment the edge `id` by one every time a new edge is added. The first edge `id` will be `10000`.
167
167
168
168
|
169
169
@@ -177,8 +177,8 @@ This will increment the edge `id` by one every time a new edge is added. The fir
177
177
To see the directionality of the edges, right click on the edge layer and select `Properties`. Click `Symbology -> Simple Line` and change the `Symbol layer type` to `Arrow`.
178
178
Click `Ok`. You should now be able to see arrows for each line string. Note that all edges in the route graph are directional, so if you want a bidirectional connection you should duplicate it in reverse.
179
179
180
-
Click on the edge layer and then on the `Toggle Editing` icon represented as a pencil to start editing the layer.
181
-
To add edges, click on the `Add Line Feature`. Start adding edges by clicking twice in the main window.
180
+
Click on the edge layer and then on the `Toggle Editing` icon represented as a pencil to start editing the layer.
181
+
To add edges, click on the `Add Line Feature`. Start adding edges by clicking twice in the main window.
182
182
(First point is start, second point is end). Press right click anywhere when you have finished adding the two points for the prompt to save to come up.
183
183
The edge locations must exactly match up to the node locations, so if Snapping is not already enabled by default, enable it via Views->Toolbars->Snapping Toolbar and depress the Magnet icon.
184
184
Once complete, unselect 'Toggle Editing' and save changes.
@@ -195,13 +195,13 @@ Once complete, unselect 'Toggle Editing' and save changes.
195
195
5- Associate Nodes With Edges
196
196
-----------------------------
197
197
198
-
Now that we have our node and edge layers, we can associate node IDs with edge IDs.
198
+
Now that we have our node and edge layers, we can associate node IDs with edge IDs.
199
199
Select `Database -> DB manager`. Expand `Virtual layers` and expand `Project layers`. Open up
200
-
the SQL window by clicking on the script icon in the top left corner. In the SQL window load in `generate_start_and_end_id.sql` by selecting `Load File`.
201
-
The script can found within the scripts directory in the nav2_route module.
202
-
Execute the script. Load the new layer by checking the `Load as new layer` box and clicking `Load`. The script associates the start and end of a line string by matching the node
203
-
point. Then export the layer as a ShapeFile by right clicking on the layer selecting `Export -> Save Feature As`. Change the format to type to `ESRI Shapefile`, name the file, and verify that the
204
-
coordinate reference system is `WGS 84 /Pseudo-Mercator`. Press `OK`.
200
+
the SQL window by clicking on the script icon in the top left corner. In the SQL window load in `generate_start_and_end_id.sql` by selecting `Load File`.
201
+
The script can found within the scripts directory in the nav2_route module.
202
+
Execute the script. Load the new layer by checking the `Load as new layer` box and clicking `Load`. The script associates the start and end of a line string by matching the node
203
+
point. Then export the layer as a ShapeFile by right clicking on the layer selecting `Export -> Save Feature As`. Change the format to type to `ESRI Shapefile`, name the file, and verify that the
204
+
coordinate reference system is `WGS 84 /Pseudo-Mercator`. Press `OK`.
205
205
206
206
|
207
207
@@ -212,18 +212,17 @@ coordinate reference system is `WGS 84 /Pseudo-Mercator`. Press `OK`.
212
212
213
213
|
214
214
215
-
6- Export To Geojson
215
+
6- Export To Geojson
216
216
--------------------
217
217
218
218
We are now ready to export the node and edge layer as geojson files. Execute `export_shapefiles.py <prefix_of_file> <path_to_edges_shapefile> <path_to_nodes_shapefile>`
219
-
within the scripts directory located in the nav2_route module. This script converts the nodes and edges shape file into a geojson file.
219
+
within the scripts directory located in the nav2_route module. This script converts the nodes and edges shape file into a geojson file.
220
220
221
-
7- Congratulations
221
+
7- Congratulations
222
222
------------------
223
-
Your graph is ready to be consumed by the nav2 route! If you wish to add nodes or edges to your graph,
224
-
edit the layers and repeat the proccess from step 5 to regenerate the graph. If you wish to adjust the graph, make sure `Editing` is toggled on for the
225
-
node and edge layer. Then select `Vertex Tool(all Layers)` and toggle on `Topological Editing`. Repeat the proccess from step 5 to regenerate the graph.
226
223
224
+
Your graph is ready to be consumed by the nav2 route! If you wish to add nodes or edges to your graph,
225
+
edit the layers and repeat the process from step 5 to regenerate the graph. If you wish to adjust the graph, make sure `Editing` is toggled on for the
226
+
node and edge layer. Then select `Vertex Tool(all Layers)` and toggle on `Topological Editing`. Repeat the process from step 5 to regenerate the graph.
0 commit comments