-
Notifications
You must be signed in to change notification settings - Fork 266
Add docs for Denoise Layer plugin (costmap_2d) #209
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
AlexeyMerzlyakov
merged 25 commits into
ros-navigation:master
from
ryzhikovas:feature-costmap2d-denoise
May 12, 2023
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
92c2da5
Add docs for Denoise Layer plugin (costmap_2d)
ryzhikovas 68dd94c
Move config example to plugin params page
ryzhikovas fcd0bd6
Remove unnecessary extra spaces
ryzhikovas d8a8a0b
Minor improvements
ryzhikovas f69d529
Add a short description to the migration guide
ryzhikovas 11c35a6
Improves the tutorial
ryzhikovas 3b27923
Fix markup
ryzhikovas 52bad2c
Improve content and fix errors
ryzhikovas 8ef62f0
Move to general tutorials list
ryzhikovas f2df439
Default config only includes the local_costmap
ryzhikovas a5b3dc0
Fix headline in migration notes
ryzhikovas dcf6118
Add a warning about the global costmap
ryzhikovas f6ae123
Move to actual migration guide
ryzhikovas ff3291e
Fix launch command
ryzhikovas c3ca185
Fix typo
ryzhikovas f8850e5
Fix interpretation of cells
ryzhikovas e863523
Restore clarification
ryzhikovas 9e70835
Update tutorials/docs/filtering_of_noise-induced_obstacles.rst
SteveMacenski dadb4d2
Update tutorials/docs/filtering_of_noise-induced_obstacles.rst
SteveMacenski 157fe58
Update tutorials/docs/filtering_of_noise-induced_obstacles.rst
SteveMacenski 32681d7
Update tutorials/docs/filtering_of_noise-induced_obstacles.rst
SteveMacenski f330416
Update tutorials/docs/filtering_of_noise-induced_obstacles.rst
SteveMacenski 3a8056c
Update tutorials/docs/filtering_of_noise-induced_obstacles.rst
SteveMacenski 3cd2571
Remove some technical details
ryzhikovas 451a6cf
Merge branch 'master' into feature-costmap2d-denoise
AlexeyMerzlyakov 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
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,63 @@ | ||
| .. _denoise: | ||
|
|
||
| Denoise Layer Parameters | ||
| ======================== | ||
|
|
||
| ``<denoise layer>`` is the corresponding plugin name selected for this type. | ||
|
|
||
| :``<denoise layer>``.enabled: | ||
|
|
||
| ==== ======= | ||
| Type Default | ||
| ---- ------- | ||
| bool True | ||
| ==== ======= | ||
|
|
||
| Description | ||
| Whether it is enabled. | ||
|
|
||
| :``<denoise layer>``.minimal_group_size: | ||
|
|
||
| ==== ======= | ||
| Type Default | ||
| ---- ------- | ||
| int 2 | ||
| ==== ======= | ||
|
|
||
| Description | ||
| The minimum number of adjacent obstacles that should not be discarded as noise. | ||
|
|
||
| | If 1 or less, all obstacles will be kept. | ||
| | If 2, standalone obstacles (without neighbors in adjacent cells) will be removed. | ||
| | If N, obstacles groups smaller than N will be removed. | ||
|
|
||
| :``<denoise layer>``.group_connectivity_type: | ||
|
|
||
| ====== ======= | ||
| Type Default | ||
| ------ ------- | ||
| int 8 | ||
| ====== ======= | ||
|
|
||
| Description | ||
| Obstacles connectivity type (is the way in which obstacles relate to their neighbors). | ||
| Must be 4 or 8. | ||
|
|
||
| | 4 - adjacent obstacles are connected horizontally and vertically. | ||
| | 8 - adjacent obstacles are connected horizontally, vertically and diagonally. | ||
|
|
||
| Example | ||
| ******* | ||
| .. code-block:: yaml | ||
|
|
||
| local_costmap: | ||
| local_costmap: | ||
| ros__parameters: | ||
| ... | ||
| plugins: ["voxel_layer", "denoise_layer", "inflation_layer"] | ||
| ... | ||
| denoise_layer: | ||
| plugin: "nav2_costmap_2d::DenoiseLayer" | ||
| enabled: true | ||
| minimal_group_size: 2 | ||
| group_connectivity_type: 8 | ||
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
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
132 changes: 132 additions & 0 deletions
132
tutorials/docs/filtering_of_noise-induced_obstacles.rst
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,132 @@ | ||
| .. _filtering_of_noise-induced_obstacles: | ||
|
|
||
| Filtering of Noise-Induced Obstacles | ||
| ************************************ | ||
|
|
||
| - `Overview`_ | ||
| - `Requirements`_ | ||
| - `Tutorial Steps`_ | ||
| - `How it works`_ | ||
|
|
||
| .. image:: images/Filtering_of_noise-induced_obstacles/title.png | ||
| :width: 1000px | ||
|
|
||
| Overview | ||
| ======== | ||
|
|
||
| Noisy sensor measurements can cause to errors in ``Voxel Layer`` or ``Obstacle Layer``. As a result, salt and pepper noise may appear on the costmap. This noise creates false obstacles that prevent the robot from finding the best path on the map. While the images above show both salt and pepper noise as well as error due to mislocalization, this layer will only remove sensor noise, not mislocalized artifacts misaligned with the static map. | ||
| This tutorial shows how to configure filtering of false obstacles caused by noise. This functionality is provided by the ``DenoiseLayer`` costmap layer plugin which will be enabled and used in this document. | ||
|
|
||
| Requirements | ||
| ============ | ||
|
|
||
| It is assumed that ROS 2, Gazebo and TurtleBot3 packages are installed or built locally. Please make sure that Nav2 project is also built locally as it was made in :ref:`build-instructions`. | ||
|
|
||
| Tutorial Steps | ||
| ============== | ||
|
|
||
| 1. Enable Denoise Layer | ||
| ----------------------- | ||
|
|
||
| Denoise Layer is Costmap2D plugin. You can enable the ``DenoiseLayer`` plugin in Costmap2D by adding ``denoise_layer`` to the ``plugins`` parameter in ``nav2_params.yaml``. You can place it in the ``global_costmap`` and (or) ``local_costmap`` to filter noise on a global or local map. The DenoiseLayer plugin should have the following parameter defined: | ||
|
|
||
| - ``plugin``: type of plugin. In our case ``nav2_costmap_2d::DenoiseLayer``. | ||
|
|
||
| Full list of parameters supported by ``DenoiseLayer`` are listed at :ref:`denoise` page. | ||
|
|
||
| It is important to note that ``DenoiseLayer`` typically should be placed before the inflation layer. | ||
| This is required to prevent inflation from noise-induced obstacles. | ||
| Moreover, ``DenoiseLayer`` processes only obstacle information in the costmap. | ||
| Values ``INSCRIBED_INFLATED_OBSTACLE``, ``LETHAL_OBSTACLE`` and optionally ``NO_INFORMATION`` | ||
| will be interpreted as obstacle cell. Cells with any other values will be interpreted as ``FREE_SPACE`` when processed (won't be distorted in the cost map). | ||
| If a cell with an obstacle is recognized as noise, it will be replaced by ``FREE_SPACE`` after processing. | ||
|
|
||
| To enable ``DenoiseLayer`` for both global and local costmaps, use the following configuration: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| global_costmap: | ||
| global_costmap: | ||
| ros__parameters: | ||
| ... | ||
| plugins: ["static_layer", "obstacle_layer", "denoise_layer", "inflation_layer"] | ||
| ... | ||
| denoise_layer: | ||
| plugin: "nav2_costmap_2d::DenoiseLayer" | ||
| enabled: True | ||
| ... | ||
| local_costmap: | ||
| local_costmap: | ||
| ros__parameters: | ||
| ... | ||
| plugins: ["voxel_layer", "denoise_layer", inflation_layer"] | ||
| ... | ||
| keepout_filter: | ||
| plugin: "nav2_costmap_2d::DenoiseLayer" | ||
| enabled: True | ||
|
|
||
| .. note:: | ||
|
|
||
| The key to success in filtering noise is to understand its type and choose the right ``DenoiseLayer`` parameters. | ||
| The default parameters are focused on fast removal of standalone obstacles. | ||
| More formally, an obstacle is discarded if there are no obstacles among the adjacent eight cells. | ||
| This should be sufficient in typical cases. | ||
|
|
||
| If some sensor generates intercorrelated noise-induced obstacles and small obstacles in the world are unlikely, small groups of obstacles can be removed. | ||
| To configure the ``DenoiseLayer`` to such cases and understand how it works, refer to the section `How it works`_. | ||
| .. warning:: | ||
|
|
||
| Use this plugin to filter the global costmap with caution. It introduces potential performance issues. | ||
| For example in case of typically-high-range lidars (20+ meters) update window can be massive making processing time unacceptably long. | ||
| It is worth taking this into account as an application designer. | ||
|
|
||
| 2. Run Nav2 stack | ||
| ----------------- | ||
|
|
||
| After Denoise Layer was enabled for global/local costmaps, run Nav2 stack as written in :ref:`getting_started`: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| ros2 launch nav2_bringup tb3_simulation_launch.py headless:=False | ||
|
|
||
| And check that filter is working properly: with the default parameters, | ||
| no standalone obstacles should remain on the cost map. This can be checked, for example, in RViz main window displaying local and global costmaps after removing unnecessary particles (illustrated at the top of this tutorial). | ||
|
|
||
|
|
||
| How it works | ||
| ============ | ||
|
|
||
| The plugin is based on two algorithms. | ||
|
|
||
| When parameter ``minimal_group_size`` = 2, the first algorithm turns on. | ||
| It apply `erosion <https://docs.opencv.org/3.4/db/df6/tutorial_erosion_dilatation.html>`_ function with kernel from image below (left if ``group_connectivity_type`` = 4 or right if ``group_connectivity_type`` = 8) to the costmap. | ||
| White color of the kernel pixel means to use the value, black means to ignore it. | ||
|
|
||
| .. image:: images/Filtering_of_noise-induced_obstacles/3x3_kernels.png | ||
| :width: 222px | ||
|
|
||
| As a result of erosion function the neighbors image is created. Each possible position of the kernel on the costmap corresponds to one pixel of the neighbors image. The pixel value of this image is equal to the maximum of 4/8 costmap pixels corresponding to the white pixels of the mask. | ||
| In other words, the pixel of the neighbors image is equal to the obstacle code if there is an obstacle nearby, the free space code in other case. | ||
| After that, obstacles corresponding to free space code on neighbors image are removed. | ||
|
|
||
| This process is illustrated below. On the left side of the image is a costmap, on the right is a neighbors image. White pixels are free space, black pixels are obstacles, ``group_connectivity_type`` = 4. | ||
| Obstacles marked at the end of the animation will be removed. | ||
|
|
||
| .. image:: images/Filtering_of_noise-induced_obstacles/dilate.gif | ||
| :width: 600px | ||
|
|
||
| When parameter ``minimal_group_size`` > 2, the second algorithm is executed. | ||
| This is a generalized solution that allows you to remove groups of adjacent obstacles if their total number is less than ``minimal_group_size``. | ||
| To select groups of adjacent obstacles, the algorithm performs their segmentation. | ||
| The type of cell connectivity in one segment is determined by the parameter ``group_connectivity_type``. | ||
| Next, the size of each segment is calculated. | ||
| Obstacles segments with size less than the ``minimal_group_size`` are replaced with empty cells. | ||
| This algorithm is about 10 times slower than first, so use it with caution and only when necessary. | ||
| Its execution time depends on the size of the processed map fragment (and not depend on the value of ``minimal_group_size``). | ||
|
|
||
| This algorithm is illustrated in the animation below (``group_connectivity_type`` = 8). | ||
| Obstacles marked at the end of the animation will be removed (groups that size less 3). | ||
|
|
||
| .. image:: images/Filtering_of_noise-induced_obstacles/connected_components.gif | ||
| :width: 600px | ||
|
|
Binary file added
BIN
+197 Bytes
tutorials/docs/images/Filtering_of_noise-induced_obstacles/3x3_kernels.png
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
+37.1 KB
...rials/docs/images/Filtering_of_noise-induced_obstacles/connected_components.gif
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.