Generating a Map

This guide explains how to generate a map using the TurtleBot4.

Prerequisites

Make sure your PC and TurtleBot are connected to the same network.

Step 1: Check ROS_DOMAIN_ID

Before starting, ensure that the ROS_DOMAIN_ID is the same on both the TurtleBot and your PC.

On the TurtleBot

Open a terminal and connect via SSH:

ssh ubuntu@<ip_address>

Enter the password:

turtlebot4

Check the ROS_DOMAIN_ID:

echo $ROS_DOMAIN_ID

On your PC

Open another terminal and check your configuration:

nano ~/.bashrc

Scroll to the bottom and look for:

export ROS_DOMAIN_ID=<value>

Make sure this value matches the one on the TurtleBot.

You can also check it quickly:

echo $ROS_DOMAIN_ID

If the values are different, update them so they match.

Step 2: Launch SLAM (Mapping)

Start the mapping process using SLAM.

Terminal 1 – Start SLAM

ros2 launch turtlebot4_navigation slam.launch.py namespace:=raphael
Note:

The namespace may be different depending on your TurtleBot name.

Terminal 2 – Start Visualization

ros2 launch turtlebot4_viz view_navigation.launch.py namespace:=raphael

Result

A visualization window will appear where the robot builds a map of the environment in real-time.