Demo repository showcasing ROS2 navigation with semantic segmentation-based costmap layers.
This demo shows autonomous navigation using semantic segmentation to identify traversable surfaces. A TurtleBot 4 robot navigates through a simulated environment (Baylands world) using Nav2, with a custom costmap layer that assigns navigation costs based on terrain classification (sidewalk, grass, background).
- Semantic Segmentation Layer: Custom Nav2 costmap plugin that integrates semantic segmentation into path planning
- Semantic Segmentation Node: ROS2 node for real-time ONNX-based inference. A simple model that works on gazebo sidewalks is also provided.
- Semantic Segmentation Sim: Gazebo simulation environment with TurtleBot 4 on the baylands outdoors world.
For training custom models, you can use the Simple Segmentation Toolkit to easily prototype segmentation models with SAM-based auto-labeling (no manual annotation required).
- Docker with GPU support (NVIDIA)
- VSCode with Dev Containers extension
-
Open in Dev Container:
# Clone the repository git clone <repository-url> cd <repository-name> # Open in VSCode code . # VSCode will prompt to reopen in container - accept it
-
Build the workspace (first time only):
cd rover/ros2 colcon build --symlink-install source install/setup.bash
-
Launch the complete simulation:
ros2 launch semantic_segmentation_sim segmentation_simulation_launch.py
This will start:
- Gazebo simulation with TurtleBot 4 in Baylands world
- Nav2 navigation stack with semantic segmentation costmap
- Semantic segmentation inference node
- RViz for visualization
You can customize the launch with arguments:
# Launch without Gazebo GUI (headless)
ros2 launch semantic_segmentation_sim segmentation_simulation_launch.py use_sim_gui:=false
# Launch without RViz
ros2 launch semantic_segmentation_sim segmentation_simulation_launch.py use_rviz:=false
# Launch fully headless (no GUI at all)
ros2 launch semantic_segmentation_sim segmentation_simulation_launch.py use_sim_gui:=false use_rviz:=falseOnce the simulation is running, you can send navigation goals via RViz:
- Click the "2D Goal Pose" button in RViz
- Click and drag on the map to set a goal position and orientation
- The robot will plan a path that prefers sidewalks and avoids grass
Refer to each package's README for detailed documentation and configuration options.
The system classifies terrain into three categories:
- Sidewalk (traversable): Cost = 0 (preferred)
- Background (intermediate): Cost = 127 (acceptable fallback)
- Grass (danger): Cost = 254 (avoided)
The robot's path planner will try to stay on sidewalks, but can traverse background areas if necessary to reach the goal.
See individual package licenses for details.
- Nav2 - ROS2 navigation framework
- Kiwi Campus - Semantic segmentation layer plugin
- Super Gradients - Model training framework
