-
Notifications
You must be signed in to change notification settings - Fork 270
Graph generation #401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
SteveMacenski
merged 19 commits into
ros-navigation:master
from
jwallace42:graph_generation
Mar 28, 2025
Merged
Graph generation #401
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b553980
graph_generation
jwallace42 b5f040f
cleanup
jwallace42 c8a108f
code review
jwallace42 5126e0b
code review
jwallace42 1c7573f
review
jwallace42 5f250e5
updates
jwallace42 b4ce82c
Update tutorials/docs/route_graph_generation.rst
jwallace42 03d5a41
code review
jwallace42 da4f0eb
Update tutorials/docs/route_graph_generation.rst
SteveMacenski 829a304
Update tutorials/docs/route_graph_generation.rst
SteveMacenski a14507f
Update tutorials/docs/route_graph_generation.rst
SteveMacenski 6ac6a4a
code review
jwallace42 6f82be4
updates
jwallace42 18f6d16
Merge branch 'master' into graph_generation
SteveMacenski 232f850
Update tutorials/docs/route_graph_generation.rst
SteveMacenski 2723504
Update tutorials/docs/route_graph_generation.rst
SteveMacenski 73706ab
Update tutorials/docs/route_graph_generation.rst
SteveMacenski 7a20bc4
Update tutorials/docs/route_graph_generation.rst
SteveMacenski 2dc2da9
Update tutorials/docs/route_graph_generation.rst
SteveMacenski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,189 @@ | ||
| .. _graph_generation: | ||
|
|
||
| Graph Generation | ||
| **************** | ||
|
|
||
| - `Overview`_ | ||
| - `Requirements`_ | ||
| - `Tutorial Steps`_ | ||
|
|
||
| Overview | ||
| ======== | ||
| This tutorial walks a user through generating a graph for the nav2 router. | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
|
|
||
| Requirements | ||
| ============ | ||
| Follow https://www.qgis.org/en/site/forusers/download.html to install QGIS. | ||
|
|
||
| Tutorial Steps | ||
| ============== | ||
|
|
||
| 1- Open QGIS and create a new project. Set the project coordinate reference system to `WGS 84/ Pseudo-Mercator`. | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/coordinate_reference_system.png | ||
| :height: 400px | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
| :width: 600px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| 2- If you don't need to adjust your raster image to the map frame, click | ||
| `Layer -> Add Layer -> Add Raster Layer`. Select your raster image and click `Add`. | ||
|
|
||
| 3- If you need to adjust your raster image to the map frame, open the georeferencer tool | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
| by clicking `Raster -> Georefencer`. Set the trasformation settings to `Linear` for `Transformation | ||
| type`, `WGS 84/ Pseudo-Mercator` for `Traget SRS` and set your desired path for the `Output Raster`. | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/transformation_settings.png | ||
| :height: 500px | ||
| :width: 300px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| Select the raster image you wish to georeference and place at least three georeferencer control points. Apply the | ||
| transformation. | ||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/georeferencer.png | ||
| :height: 400px | ||
| :width: 600px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| Drag and drop the raster file output into the layers window. | ||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/raster_layer.png | ||
| :height: 400px | ||
| :width: 600px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| 4- Now that we have the raster layer in the correct coordinate system we can start placing nodes. | ||
|
|
||
|
|
||
| Select `Layer -> Create Layer -> New ShapeFile Layer`. Set the shapefile layer setting to be | ||
| `nodes` for the `File name`, `points` for the `Geometry type` and `WGS 84/ Pseudo-Mercator` for the coordinate system. Press `OK`. | ||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/node_layer.png | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
| :height: 600px | ||
| :width: 400px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| Click on the node layer and use the tool bar to start adding nodes. The IDs field can be left null. | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/nodes.png | ||
| :height: 600px | ||
| :width: 400px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
|
|
||
| 5- Now an edge layer can be created. Select `Layer -> Create Layer -> New ShapeFile Layer`. Set the shapefile layer setting to be | ||
| `edges` for the `File name`, `LineString` for the `Geometry type` and `WGS 84/ Pseudo-Mercator` for the coordinate system. Press `OK`. | ||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/edge_layer.png | ||
| :height: 400px | ||
| :width: 600px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| Click on the edge layer and use the tool bar to start adding edges. Use the magnet tool to snap | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
| the start and end points of the edge to nodes. | ||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/edges.png | ||
| :height: 600px | ||
| :width: 400px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| 6- Now we will add ids for all nodes and edges. | ||
| Select the node layer and then click on the `Field calculator` tool. Check the `Update existing | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
| field` box and select `id` in the dropdown menu. Add `@row_number` to the `expression field`` and click `Ok`. | ||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/field_calculator.png | ||
| :height: 400px | ||
| :width: 600px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| This will generate ids for each node. To verify that the ids have been generated, right click on | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
| the node layer and select `Open attribute table`. This will display the current attributes associated with the node layer. | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
|
|
||
| Follow the same process for the edges but swap the `@row_number` for `@row_number + <number_of_nodes>`. | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| 7- Now that we have our node and edge layers with IDs, we can associate node IDs with edge IDs. | ||
|
|
||
| Select `Database -> DB manager`. Expand `Virtual layers` and expand `Project layers`. Open up | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
| the SQL window. In the SQL window load in the association script by selecting `Load File`. | ||
| Execute the script. Load the new layer by checking the `Load as new layer` box and clicking `Load`. | ||
| This layer will be refered to as connected edges. | ||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/sql_script.png | ||
| :height: 400px | ||
| :width: 600px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| 8- We are now ready to export the node and edge layer as geojson files. Right click on the nodes layer and select | ||
| `Export -> Save Feature As`. Set the format to geojson and verify the coordinate reference system is set to `WGS 84/ Pseudo-Mercator`. | ||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/export_to_geojson.png | ||
| :height: 300px | ||
| :width: 400px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| Follow the same process for the connected edges layer. | ||
|
|
||
| 9- Create a new geojson file called graph. Copy the nodes geojson file into the graph file. Insert the features | ||
| from the connected edges geojson file into the features tag in the graph file. | ||
|
SteveMacenski marked this conversation as resolved.
Outdated
|
||
|
|
||
| | | ||
|
|
||
| .. image:: images/graph_generation/geojson_graph.png | ||
| :height: 600px | ||
| :width: 400px | ||
| :align: center | ||
|
|
||
| | | ||
|
|
||
| 10- Congratulations! Your graph is ready to be consumed by the nav2 route! If you wish to add nodes or edges to your graph, | ||
| edit the layers and repeat the proccess from step 6. If you wish to adjust the graph, make sure `Editing` is toggled on for the | ||
| node and edge layer. Then select `Vertex Tool(all Layers)` and toggle on `Topological Editing`. Repeat the proccess from step 7. | ||
|
|
||
|
|
||
| Happy Routing! | ||
|
|
||
Binary file added
BIN
+264 KB
tutorials/docs/images/graph_generation/coordinate_reference_system.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.