Skip to content

Add semantic segmentation tutorial#876

Open
pepisg wants to merge 4 commits intoros-navigation:masterfrom
pepisg:semantic-segmentation
Open

Add semantic segmentation tutorial#876
pepisg wants to merge 4 commits intoros-navigation:masterfrom
pepisg:semantic-segmentation

Conversation

@pepisg
Copy link
Contributor

@pepisg pepisg commented Feb 18, 2026

Signed-off-by: pepisg <pedro.gonzalez@eia.edu.co>
Signed-off-by: pepisg <pedro.gonzalez@eia.edu.co>
Signed-off-by: pepisg <pedro.gonzalez@eia.edu.co>
Signed-off-by: pepisg <pedro.gonzalez@eia.edu.co>
Copy link
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really love this, thank you! ❤️

.. _navigation2_with_semantic_segmentation:

Navigating with Semantic Segmentation
**************************************
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**************************************
*************************************

========

This tutorial demonstrates how to use semantic segmentation in costmaps with nav2, using a custom `semantic_segmentation_layer plugin <https://github.com/ros-navigation/navigation2_tutorials/tree/master/nav2_semantic_segmentation_layer>`_ and a pre-trained segmentation model that works on gazebo's Baylands world. It was written by Pedro Gonzalez at `robot.com <https://robot.com/>`_.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Immediately right here put on of your impressive gifs :-)

:alt: Example of semantic segmentation showing original image and segmented mask

Once trained, the output of a semantic segmentation model is typically an image with the same size as the input, where each pixel holds the probability of that pixel belonging to each class.
For instance, the model provided in this tutorial has 3 classes: sidewalk, grass, and background; hence its raw output is a 3-channel image, where each channel corresponds to the probability of the pixel belonging to that class.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this was a general purpose segementation algorithm with many classes?

Might it be better to have the node have the probability handling so that the output image was 1 channel where it corresponded to the thresholded value (or unknown)?

:alt: Gazebo Baylands world

1- Setup Semantic Segmentation Inference Node
-----------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-----------------------------------------------
---------------------------------------------

segmentation_topic: "/segmentation/mask"
confidence_topic: "/segmentation/confidence"
labels_topic: "/segmentation/label_info"
pointcloud_topic: "/rgbd_camera/depth/points"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for me + the tutorial to clarify: Does this pointcloud topic need to be from the same frame as the image is from, or can it be from another source?

The tutorial provides a pre-configured `nav2_params.yaml <https://github.com/ros-navigation/navigation2_tutorials/blob/master/nav2_semantic_segmentation_demo/semantic_segmentation_sim/config/nav2_params.yaml>`_ file in the semantic_segmentation_sim package. You can use it to configure the Nav2 costmaps for your own application.

3- Run everything together
----------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
----------------------------
--------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments