5.4.1 SLAM Mapping
Feature Introduction
SLAM stands for Simultaneous Localization and Mapping. This section uses ROS2's SLAM-Toolbox as the mapping algorithm, controls the robot in Gazebo to navigate and build a map, and visualizes the mapping effect via Rviz2. SLAM-Toolbox runs on the RDK, while Gazebo and Rviz2 run on a PC that is on the same network segment as the RDK.
Supported Platforms
| Platform | Execution Method |
|---|---|
| RDK X3, RDK X3 Module | Ubuntu 20.04 (Foxy), Ubuntu 22.04 (Humble) |
| RDK X5, RDK X5 Module | Ubuntu 22.04 (Humble) |
| RDK S100, RDK S100P | Ubuntu 22.04 (Humble) |
| RDK S600 | Ubuntu 24.04 (Jazzy) |
Preparation
RDK Platform
-
The RDK is flashed with the Ubuntu system image.
-
TogetheROS.Bot is successfully installed on the RDK.
-
After tros.b is successfully installed, install SLAM-Toolbox:
- Foxy
- Humble
- Jazzy
# Configure tros.b environment
source /opt/tros/setup.bash
# Configure tros.b environment
source /opt/tros/humble/setup.bash
# Configure tros.b environment
source /opt/tros/jazzy/setup.bash
- Humble
# Configure tros.b environment
source /opt/tros/humble/setup.bash
- Jazzy
# Configure tros.b environment
source /opt/tros/jazzy/setup.bash
sudo apt-get install ros-${ROS_DISTRO}-slam-toolbox
If the installation fails with the following error:
The following packages have unmet dependencies:
ros-foxy-slam-toolbox : Depends: ros-foxy-nav2-map-server but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Please run the following commands before installing:
apt update
sudo apt install libwebp6=0.6.1-2ubuntu0.20.04.3
If the sudo apt update command fails or returns an error, please refer to the Q10: How to handle apt update command failure or error? section in the FAQ for a solution.
If the sudo apt update command fails or returns an error, please refer to the Q10: How to handle apt update command failure or error? section in the FAQ for a solution.
If the sudo apt update command fails or returns an error, please refer to the FAQ section Q6: How to handle apt update command failure or error? for resolution.
If the sudo apt update command fails or returns an error, please refer to the Q6: How to handle apt update command failure or error? section in the FAQ for a solution.
:::
- A PC on the same network segment as the RDK, with Ubuntu installed along with ROS2 Desktop, the Gazebo simulation environment, and the Rviz2 data visualization tool.
- Foxy
- Humble
- Jazzy
source /opt/ros/foxy/setup.bash
Ubuntu 20.04 system and ROS2 Foxy Desktop
source /opt/ros/humble/setup.bash
Ubuntu 22.04 system and ROS2 Humble Desktop
source /opt/ros/jazzy/setup.bash
Ubuntu 24.04 system and ROS2 Jazzy Desktop
- Humble
source /opt/ros/humble/setup.bash
Ubuntu 22.04 system and ROS2 Humble Desktop
- Jazzy
source /opt/ros/jazzy/setup.bash
Ubuntu 24.04 system and ROS2 Jazzy Desktop
After successfully installing ROS2 on the PC, install Gazebo and the Turtlebot3-related packages using the following commands:
sudo apt-get install ros-${ROS_DISTRO}-gazebo-*
sudo apt install ros-${ROS_DISTRO}-turtlebot3
sudo apt install ros-${ROS_DISTRO}-turtlebot3-bringup
sudo apt install ros-${ROS_DISTRO}-turtlebot3-simulations
sudo apt install ros-${ROS_DISTRO}-teleop-twist-keyboard
Usage Guide
RDK Platform
This section describes how to run the SLAM algorithm on the RDK and observe the mapping results using a PC.
Start the simulation environment on the PC:
- Foxy
- Humble
- Jazzy
source /opt/ros/foxy/setup.bash
source /opt/ros/humble/setup.bash
source /opt/ros/jazzy/setup.bash
- Humble
source /opt/ros/humble/setup.bash
- Jazzy
source /opt/ros/jazzy/setup.bash
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
If the launch fails with the error [ERROR] [gzclient-2]: process has died, run the command source /usr/share/gazebo/setup.sh before launching again.
The simulation environment is shown below:

Open another terminal on the PC and launch Rviz2 to visualize the mapping effect:
- Foxy
- Humble
- Jazzy
source /opt/ros/foxy/setup.bash
source /opt/ros/humble/setup.bash
source /opt/ros/jazzy/setup.bash
- Humble
source /opt/ros/humble/setup.bash
- Jazzy
source /opt/ros/jazzy/setup.bash
ros2 launch turtlebot3_bringup rviz2.launch.py
After launching Rviz2, add the "map" visualization option to display the constructed map. Follow the steps shown below:

Run SLAM-Toolbox on the RDK board:
- Foxy
- Humble
- Jazzy
# Configure tros.b environment
source /opt/tros/setup.bash
# Configure tros.b environment
source /opt/tros/humble/setup.bash
# Configure tros.b environment
source /opt/tros/jazzy/setup.bash
- Humble
# Configure tros.b environment
source /opt/tros/humble/setup.bash
- Jazzy
# Configure tros.b environment
source /opt/tros/jazzy/setup.bash
# Launch SLAM launch file
ros2 launch slam_toolbox online_sync_launch.py
Open another terminal on the PC and launch the control tool to drive the robot using the keyboard. Refer to the console logs for control instructions (not detailed here):
- Foxy
- Humble
- Jazzy
source /opt/ros/foxy/setup.bash
ros2 run teleop_twist_keyboard teleop_twist_keyboard
source /opt/ros/humble/setup.bash
ros2 run teleop_twist_keyboard teleop_twist_keyboard
source /opt/ros/jazzy/setup.bash
ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -p stamped:=True
- Humble
source /opt/ros/humble/setup.bash
ros2 run teleop_twist_keyboard teleop_twist_keyboard
- Jazzy
source /opt/ros/jazzy/setup.bash
ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -p stamped:=True
As the robot moves, its radar detects more environmental information, and the SLAM algorithm builds an environmental map. The mapping effect can be observed in Rviz2.

Result Analysis
The terminal output on the RDK board is as follows:
[INFO] [launch]: All log files can be found below /root/.ros/log/2022-06-10-06-40-34-204213-ubuntu-5390
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [sync_slam_toolbox_node-1]: process started with pid [5392]
[sync_slam_toolbox_node-1] [INFO] [1654843239.403931058] [slam_toolbox]: Node using stack size 40000000
[sync_slam_toolbox_node-1] [INFO] [1654843240.092340814] [slam_toolbox]: Using solver plugin solver_plugins::CeresSolver
[sync_slam_toolbox_node-1] [INFO] [1654843240.096554433] [slam_toolbox]: CeresSolver: Using SCHUR_JACOBI preconditioner.
[sync_slam_toolbox_node-1] Info: clipped range threshold to be within minimum and maximum range!
[sync_slam_toolbox_node-1] [WARN] [1654843589.431524393] [slam_toolbox]: maximum laser range setting (20.0 m) exceeds the capabilities of the used Lidar (3.5 m)
[sync_slam_toolbox_node-1] Registering sensor: [Custom Described Lidar]