Multiple robots

By default, each TurtleBot 4 will use the same topic, action, and service names for communication. If we connect two default TurtleBot 4's to the same network, the topics from both robots will communicate with each other and cause unwanted behaviours.

This tutorial will cover the two main methods for running multiple TurtleBot 4's on a single network.


The ROS_DOMAIN_ID is an environment variable used in ROS 2 to change the ports that ROS 2 processes use for communication. This effectively allows us to separate different ROS 2 processes from communicating with each other on the same network. For a detailed explanation, click here.

We can leverage this by assigning a unique ROS_DOMAIN_ID to each of our robots. This will ensure that communication between robots does not occur. The ROS_DOMAIN_ID can be set to any value between 0 and 101, inclusively.

Setting the environment variable

There are four locations in which the ROS_DOMAIN_ID environment variable must be set:

  • Create® 3
  • RPi4 Terminal
  • RPi4 Robot Upstart Job
  • User PC
  • For RPi4 images v0.1.3 or higher, a script has been installed which will conveniently set the ROS_DOMAIN_ID in the first 3 locations. If you are using an earlier version, you can copy the script to /usr/local/bin/ on your RPi4. You will also need to update your script by downloading it from here and replacing the existing script in /usr/local/bin.

    Simply call on your RPi4 and follow the instructions. Note that this script can also be used to switch between fastrtps and cyclonedds middlewares.

    ROS Config
    Using the script

    Once the settings are confirmed, the script will apply the changes to the Create® 3 and restart the Create® application. This may take about a minute or so. The script will also uninstall the TurtleBot 4 Robot Upstart job, and reinstall it with the new settings. Finally, it will add the ROS_DOMAIN_ID to the ~/.bashrc file of the RPi4. To apply the change to your current RPi4 terminal you will need to call source ~/.bashrc.

    Create® 3

    To manually set the ROS_DOMAIN_ID of the Create® 3, go to the webserver. Navigate to Application->Configuration. Set the Domain ID and click ‘Save'. Then restart the application.

    RPi4 Terminal

    To manually set the ROS_DOMAIN_ID on the RPi4 terminal, simply call export ROS_DOMAIN_ID=#, replacing # with your ID number. Note that this will only be applied in your current terminal. To apply this environment variable to all new terminals, add this line to your ~/.bashrc file.

    RPi4 Robot Upstart Job

    To change the ROS_DOMAIN_ID of the TurtleBot 4 Robot Upstart job, you will need to reinstall the job.

    First, stop the turtlebot4 service:

    sudo systemctl stop turtlebot4.service

    Then, uninstall it:

    Now you can install it again:

    v0.1.3 or higher <model> --domain #

    v0.1.2 <model> #

    Replace <model> with your TurtleBot 4 model (standard or lite) and # with your ROS_DOMAIN_ID

    User PC

    The ROS_DOMAIN_ID can be set on the User PC in the same way as the RPi4 Terminal (described above).

  • SSH into your TurtleBot 4 and run the turtlebot4 setup tool:


    Navigate to ‘Bash Setup' in the ‘ROS Setup' menu, then change your ROS_DOMAIN_ID. Save the settings, then apply settings in the main menu.

    Setting the ROS_DOMAIN_ID

    This will apply the new ROS_DOMAIN_ID to the Create® 3, RPi4 Terminal, and RPi4 Robot Upstart job.

    On the user PC, set the ROS_DOMAIN_ID in your setup.bash file and source it. See Installing ROS 2 for more details.

Once the Create® 3 application has restarted, try calling ros2 topic list on both your PC and the RPi4 to ensure that all topics are visible.


Namespacing is a method of adding a prefix to topic names to group certain topics, or to make them unique. By namespacing all topics on a TurtleBot 4, we can have a full set of unique topics for that robot. This allows us to run multiple robots on the same ROS_DOMAIN_ID.

It is common to use the name of the robot as the namespace. For example, if we have a robot named robot1, the namespaced topics would look like:

ubuntu@ubuntu:~$ ros2 topic list
  • Namespacing is not supported in Galactic.

  • To set the robot namespace, SSH into your TurtleBot 4 and run the turtlebot4 setup tool:


    Navigate to ‘Bash Setup' in the ‘ROS Setup' menu, then change the ROBOT_NAMESPACE setting. Save the settings, then apply settings in the main menu.

    Setting the robot namespace

    This will apply the new namespace to the Create® 3, RPi4 Terminal, and RPi4 Robot Upstart job.

    Viewing the Robot in RViz

    On the user PC, turtlebot4_desktop launch files can use a namespace argument to view a specific robot:

    ros2 launch turtlebot4_viz namespace:=/robot1

    Launching Robots in Simulation

    The first robot can be launched normally, with the addition of a namespace. All other parameters are still available as shown below:

    ros2 launch turtlebot4_ignition_bringup namespace:=/robot1 nav2:=true slam:=false localization:=true rviz:=true

    Any additional robots must be launched using the turtlebot4_spawn launch file, a unique namespace and a unique spawn location:

    ros2 launch turtlebot4_ignition_bringup namespace:=/robot2 x:=0.0 y:=1.0 nav2:=true slam:=false localization:=true rviz:=true

    Launching Navigation

    The SLAM, Localization and Nav2 launch files all support namespacing and can be launched as follows:

    ros2 launch turtlebot4_navigation namespace:=/robot1
    ros2 launch turtlebot4_navigation map:=office.yaml namespace:=/robot1
    ros2 launch turtlebot4_navigation namespace:=/robot1

    Replace robot1 with the desired robot namespace.