This workspace provides a complete solution for:
- SLAM-based mapping - Create maps of unknown environments using the TurtleBot3's LiDAR sensor
- Localization - Use AMCL (Adaptive Monte Carlo Localization) to localize the robot on a known map
- Autonomous Navigation - Navigate to goal poses using Nav2's global and local planning algorithms
The implementation supports:
- TurtleBot3 models: Burger, Waffle, Waffle Pi
- Standard environments: TurtleBot3 House World, TurtleBot3 World
- Custom environments: RoboCup@work arena simulation
rcup_simulations/
├── README.md
└── src/
├── slam_pkg/ # Main SLAM and Nav2 package
│ ├── launch/ # Launch files for SLAM, localization, and navigation
│ ├── config/ # Configuration files (YAML, RViz)
│ ├── maps/ # Saved maps
│ ├── src/ # Source files (C++)
│ ├── CMakeLists.txt
│ └── package.xml
└── custom_world/ # Custom Gazebo world package
├── launch/ # Launch files for custom world
├── config/ # Configuration files for custom world
├── maps/ # Maps for custom world
├── setup.py
└── package.xml
The primary package containing all necessary launch files for SLAM and autonomous navigation in the standard TurtleBot3 environments.
Features:
- SLAM mapping using
slam_toolbox - AMCL-based localization
- Nav2 autonomous navigation
- Pre-configured RViz configurations
Launch Files:
slam.launch. py- Start SLAM mappinglocalisation_amcl.launch.py- Start localization with saved mapnav2.launch.py- Full autonomous navigation stack
A specialized package for running SLAM and Nav2 in a custom Gazebo world resembling the RoboCup@work arena.
Features:
- Custom world loader
- Adapted SLAM parameters
- Custom map support
Launch Files:
slam. launch.py- SLAM in custom worldnav2.launch.py- Navigation in custom worldturtlebot3_customworld.launch.py- Load custom Gazebo world
- Asynchronous SLAM: Processes scans in a separate thread for better performance
- Loop Closure: Detects when the robot revisits known areas to correct drift
- Pose Graph Optimization: Uses graph-based optimization (Ceres solver) for map consistency
- Particle Filter: Represents robot pose uncertainty with particles
- Sensor Model: Compares expected laser scans with actual scans
- Motion Model: Predicts particle movement based on odometry
- Global Planner: Computes optimal path from start to goal
- Local Planner: Generates velocity commands to follow the path
- Recovery Behaviors: Handles stuck situations (rotate, back up, clear costmap)
- Behavior Trees: Coordinates navigation tasks and recovery
┌─────────────┐ ┌──────────────┐ ┌────────────┐
│ Gazebo │─────▶│ TurtleBot3 │─────▶│ LiDAR Scan │
│ World │ │ /scan topic │ │ /scan │
└─────────────┘ └──────────────┘ └─────┬──────┘
│
▼
┌──────────────────────────────────┐
│ slam_toolbox │
│ (async_slam_toolbox_node) │
│ - Scan matching │
│ - Loop closure │
│ - Map building │
└─────────────┬────────────────────┘
│
▼
┌────────────────┐
│ /map topic │
│ Occupancy Grid│
└────────────────┘
┌──────────────┐ ┌─────────────┐ ┌──────────────┐
│ Map Server │─────▶│ AMCL │─────▶│ Localized │
│ (saved map) │ │ (particles) │ │ Robot Pose │
└──────────────┘ └─────────────┘ └──────┬───────┘
│
▼
┌──────────────┐ ┌────────────────┐
│ Goal Pose │────────────────────────▶ │ Nav2 Stack │
│ (from RViz) │ │ - Planner │
└──────────────┘ │ - Controller │
│ - Recovery │
└────────┬───────┘
│
▼
┌────────────────┐
│ cmd_vel │
│ (velocity │
│ commands) │
└────────────────┘
- OS: Ubuntu 22.04 (Jammy)
- ROS2 Distribution: Humble Hawksbill (recommended)
# ROS2 Humble
sudo apt update
sudo apt install ros-humble-desktop
# TurtleBot3 packages
sudo apt install ros-humble-turtlebot3*
sudo apt install ros-humble-turtlebot3-gazebo
# SLAM Toolbox
sudo apt install ros-humble-slam-toolbox
# Nav2 Stack
sudo apt install ros-humble-navigation2
sudo apt install ros-humble-nav2-bringup
# Additional dependencies
sudo apt install ros-humble-gazebo-ros-pkgs
sudo apt install ros-humble-rviz2mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
git clone https://github.com/SanjayS66/rcup_simulations.gitAdd to your ~/.bashrc:
export TURTLEBOT3_MODEL=burger # or 'waffle', 'waffle_pi'Then source:
source ~/.bashrccd ~/ros2_ws
colcon build --symlink-install
source install/setup.bash# Terminal 1: Launch SLAM
ros2 launch slam_pkg slam.launch.pyThis will:
- Start Gazebo with TurtleBot3 House world
- Launch
async_slam_toolbox_nodefor mapping - Open RViz2 with SLAM visualization
Control the robot using keyboard teleop:
# Terminal 2: Teleoperation
ros2 run turtlebot3_teleop teleop_keyboardSave the map:
# Terminal 3: Save map
ros2 run nav2_map_server map_saver_cli -f ~/maps/my_mapros2 launch custom_world slam.launch.pyLaunch localization with a previously saved map:
ros2 launch slam_pkg localisation_amcl.launch.pySet initial pose in RViz:
- Click "2D Pose Estimate" in RViz toolbar
- Click and drag on the map to set robot's initial position and orientation
ros2 launch slam_pkg nav2.launch.pyros2 launch custom_world nav2.launch.pySend navigation goals:
- Set the Initial Pose
- In RViz, click "Nav2 Goal" or "2D Goal Pose"
- Click on the map where you want the robot to navigate
- The robot will plan and execute a path to the goal
slam_turtlebot.1.mp4
nav2_turtlebot.1.mp4
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is maintained as part of RoboCup training tasks. Please contact the maintainer for licensing information.
Sanjay
- Email: sanjay702594@gmail.com
- GitHub: @SanjayS66
- ROBOTIS TurtleBot3
- slam_toolbox
- Nav2 Stack
- Slam Tutorial by Articulated robotics
- Nav2 Tutorials by Articulated robotics
- TurtleBot3 Simulation Guide
- slam_toolbox Documentation
- Nav2 Documentation
- RoboCup@work community