-
Notifications
You must be signed in to change notification settings - Fork 170
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
Graph generation #401
Open
jwallace42
wants to merge
13
commits into
ros-navigation:master
Choose a base branch
from
jwallace42:graph_generation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Graph generation #401
Changes from 5 commits
Commits
Show all changes
13 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 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+264 KB
tutorials/docs/images/route_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.
Binary file added
BIN
+72.5 KB
tutorials/docs/images/route_graph_generation/transformation_settings.png
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 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,207 @@ | ||
.. _route_graph_generation: | ||
|
||
Route Graph Generation | ||
********************** | ||
|
||
- `Overview`_ | ||
- `Requirements`_ | ||
- `Tutorial Steps`_ | ||
|
||
Overview | ||
======== | ||
This tutorial walks a user through generating a graph for the nav2 route server. | ||
|
||
Requirements | ||
============ | ||
Follow https://www.qgis.org/en/site/forusers/download.html to install QGIS. | ||
|
||
Tutorial Steps | ||
============== | ||
|
||
1- Open QGIS and create a new project by selecting `Project->New`. Save your project by selecting, `Project -> Save As`. | ||
Set the project coordinate reference system by selecting `Project->Properties->CRS`. Set the coordinate system to `WGS 84/ Pseudo-Mercator` and click `OK`. | ||
|
||
|
||
.. note:: | ||
The `WGS 84/ Pseudo-Mercator` is one of few coordinate systems that could be used. | ||
For more information about coordinate reference systems please review https://docs.qgis.org/3.22/en/docs/gentle_gis_introduction/coordinate_reference_systems.html. | ||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/coordinate_reference_system.png | ||
:height: 1097px | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:width: 1064px | ||
:align: center | ||
|
||
| | ||
|
||
2- By default, the imported raster image origin will be at the top left corner, with x pointing to the right, and y pointing up. | ||
The size of the image in meters is equal to the equal to the size in pixels. | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
To correctly set the orgin and the resolution we will georeference the raster image. | ||
To georeference the image, three control points will choosen. Each control point maps a pixel location to the spatial reference. | ||
|
||
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. | ||
The first control point we could select is (0, -200) -> (0,0). (0, -200) is the bottom left corner in the pixel frame and (0, 0) is coordinates in the spatial frame. | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
For the second control point we will select the top left corner of the image (0,0). The associated coordinates in the spatial frame can be calculated by using the resolution | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
to convert the pixels to meters. In this case, (0, 0) -> (0, 10). Where 10 m is 200 * 0.05. The last control will be the bottom right corner. (200,-200) -> (5, 0). | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. note:: | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Georeferencing is type of coordinate transformation that relates a digital raster image to a spatial reference. | ||
|
||
To georeference image select `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`. | ||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/transformation_settings.png | ||
:height: 757px | ||
:width: 458px | ||
:align: center | ||
|
||
| | ||
|
||
Select the raster image you wish to georeference and place control point by selecting the icon next to the `Transformation Settings` and clicking on the raster image. | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
by selecting `Start Transformation`. | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/georeferencer.png | ||
:height: 807px | ||
:width: 1460px | ||
:align: center | ||
|
||
| | ||
|
||
Drag and drop the georeferenced raster file into the layers window. | ||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/raster_layer.png | ||
:height: 702px | ||
:width: 1051px | ||
:align: center | ||
|
||
| | ||
|
||
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. | ||
|
||
3- Now that we have georeferenced the raster layer we can start placing nodes. | ||
|
||
|
||
Select `Layer -> Create Layer -> New ShapeFile Layer`. Set the shapefile layer setting to be | ||
`nodes` for the `File name`, `Point` for the `Geometry type` and `WGS 84/ Pseudo-Mercator` for the coordinate system. Press `OK`. | ||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/node_layer.png | ||
:height: 1041px | ||
:width: 887px | ||
:align: center | ||
|
||
| | ||
|
||
In order to have the `id` field auto increment, right click on the layer and select the `Properties -> Attribute Form`. | ||
Expand the `Fields` drop down menu and select `id`. Select the `Expression Dialog` icon which is next to the `Default value` field. | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/attribute_form.png | ||
:height: 788px | ||
:width: 1107px | ||
:align: center | ||
|
||
| | ||
|
||
|
||
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`. | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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`. | ||
This will increment the node `id` by one every time a new node is added. The first node `id` will be zero. | ||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/expression_dialog.png | ||
:height: 776px | ||
:width: 950px | ||
:align: center | ||
|
||
| | ||
|
||
|
||
Click on the node layer and then on the pencil icon to start editing the layer. To add points, click on `Add points feature`. Start adding nodes by clicking in the main window. | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Each time a node is added, a window will pop up with the auto incremented id. Press `OK` to continue placing points. | ||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/nodes.png | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this one a bit larger, I can't see the buttons you have highlighted in the render |
||
:height: 1922px | ||
:width: 1082px | ||
:align: center | ||
|
||
| | ||
|
||
.. note:: | ||
By default, if a 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 | ||
or multiple nodes are deleted. Any node that is added will contiune to increment based on the highest id. This value can be overwriten by the user | ||
jwallace42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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`. | ||
Click on `Target Multi Edit Mode`, select the features to delete, and click on the trash can icon. | ||
|
||
|
||
4- 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`. | ||
To auto incrment the `id` field follow the same steps as above except replace `increment_node_id.json` with `increment_edge_id.json`. | ||
This will increment the edge `id` by one every time a new edge is added. The first edge `id` will be `10000`. | ||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/edge_layer.png | ||
:height: 1041px | ||
:width: 887px | ||
:align: center | ||
|
||
| | ||
|
||
Click on the edge layer and then on the pencil icon to start editing the layer. To add edges, click on `Add Line feature`. Start adding edges by clicking twice in the main window. | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(First point is start, second point is end). Press `Esc` when you have finished adding the two points. | ||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/edges.png | ||
:height: 1922px | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:width: 1082px | ||
:align: center | ||
|
||
| | ||
|
||
.. note:: | ||
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`. | ||
SteveMacenski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Click `Ok`. You should now be able to see arrows for each line string. | ||
|
||
|
||
5- Now that we have our node and edge layers, we can associate node IDs with edge IDs. | ||
Select `Database -> DB manager`. Expand `Virtual layers` and expand `Project layers`. Open up | ||
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`. | ||
The script can found within the scripts directory in the nav2_route module. | ||
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 | ||
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 | ||
coordinate reference system is `WGS 84 /Pseudo-Mercator`. Press `OK`. | ||
|
||
| | ||
|
||
.. image:: images/route_graph_generation/db_manager.png | ||
:height: 700px | ||
:width: 1060px | ||
:align: center | ||
|
||
| | ||
|
||
6- 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>` | ||
within the scripts directory located in the nav2_route module. This script converts the nodes and edges shape file into a geojson file. | ||
|
||
7- 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 5 to regenerate the graph. 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 5 to regenerate the graph. | ||
|
||
|
||
Happy Routing! | ||
|
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mention this before since its a final cleanup thing but we're at this point now: For all the numbered steps, make them subsections. If you use the
-----
header type, then it'll fall under the Tutorial Steps section but be more easily pronounced.So like
or