ROS 2 Project Configuration


  • Ubuntu 22.04. Other Ubuntu versions and Linux distributions can also work as long as they support ROS 2 Humble or ROS 2 Iron.
    The ROS 2 Gem is not available for Windows.
  • O3DE built from source on Linux.
  • The latest released version of ROS 2. This instruction assumes that the desktop version is installed. Otherwise, some packages might be missing.

Setting up

ROS 2 ecosystem

Source your ROS 2 workspace

To build or run projects using ROS 2 Gem, you must source your ROS 2 workspace in your console. The best way to ensure that ROS 2 is sourced at all times is by adding the following line to the ~/.profile file:

source /opt/ros/<distro>/setup.bash

Replace <distro> with the ROS 2 distribution name (such as humble). Then, you must log out and log in from Ubuntu for the change to take effect.

Custom packages

The Gem fully supports workspace overlaying . Source your workspace on top of the ROS 2 installation to include custom packages.

The Gem comes with a number of ROS 2 packages already included and linked, but you might want to include additional packages in your project. To do so, use the target_depends_on_ros2 function in your project’s Gem/CMakeLists.txt:

target_depends_on_ros2_packages(<your_target> <ros_package1> <ros_package2>)

Working with multiple ROS versions

If you have multiple ROS 2 versions installed, make sure you source the one you would like to use. You can check which version is sourced in your console by checking the value of ROS_DISTRO environment variable (echo $ROS_DISTRO).

You currently need to rebuild your project if it was previously built with another ROS version.

Additional ROS 2 packages required

  • gazebo_msgs: ros-${ROS_DISTRO}-gazebo-msgs
    • gazebo_msgs are used for robot spawning (no dependency on Gazebo).
  • Ackermann messages: ros-${ROS_DISTRO}-ackermann-msgs
  • Control toolbox ros-${ROS_DISTRO}-control-toolbox
  • XACRO ros-${ROS_DISTRO}-xacro

If a desktop installation of ROS 2 distro was selected, everything else should be there.

Use this helpful command to install:

sudo apt install ros-${ROS_DISTRO}-ackermann-msgs ros-${ROS_DISTRO}-control-toolbox ros-${ROS_DISTRO}-nav-msgs ros-${ROS_DISTRO}-gazebo-msgs ros-${ROS_DISTRO}-xacro

Clone the Gem repository

The ROS 2 Gem lives in the o3de/o3de-extras repository. Clone the GitHub repository to your machine:

git clone

Registering the Gem

To use the ROS 2 Gem in any O3DE project, you need to register it with O3DE.

For convenience, set a couple of environment variables: O3DE_HOME to where your O3DE is located and O3DE_EXTRAS_HOME to the path of your cloned o3de-extras repository, for example:

export O3DE_HOME=${HOME}/o3de
export O3DE_EXTRAS_HOME=${HOME}/o3de-extras

Run the following command to register the ROS 2 Gem:

${O3DE_HOME}/scripts/ register --gem-path ${O3DE_EXTRAS_HOME}/Gems/ROS2

Registering robotic project templates

Robotics project templates can help you quickly start your simulation project. We recommend that you register the robotics project template Gems and their Asset Gems, which you downloaded with the o3de-extras repository.

To register robotic templates and assets:

  1. Enable Git Large File Storage (LFS), if you haven’t already. Asset Gems use LFS to store large files.
    cd ${O3DE_EXTRAS_HOME}
    git lfs install && git lfs pull
  2. Register the following robotic templates and assets.
    ${O3DE_HOME}/scripts/ register --gem-path ${O3DE_EXTRAS_HOME}/Gems/ProteusRobot
    ${O3DE_HOME}/scripts/ register --gem-path ${O3DE_EXTRAS_HOME}/Gems/RosRobotSample
    ${O3DE_HOME}/scripts/ register --gem-path ${O3DE_EXTRAS_HOME}/Gems/WarehouseAssets
    ${O3DE_HOME}/scripts/ register --gem-path ${O3DE_EXTRAS_HOME}/Gems/WarehouseSample
    ${O3DE_HOME}/scripts/ register --template-path ${O3DE_EXTRAS_HOME}/Templates/Ros2FleetRobotTemplate
    ${O3DE_HOME}/scripts/ register --template-path ${O3DE_EXTRAS_HOME}/Templates/Ros2RoboticManipulationTemplate
    ${O3DE_HOME}/scripts/ register --template-path ${O3DE_EXTRAS_HOME}/Templates/Ros2ProjectTemplate

For more information, refer to Adding and Removing Gems and Registering Gems.

Creating a new robotic simulation project

Robotic Project Templates

Project templates are useful tools to shape your initial project. When created with a template, a new project can start with a specific configuration. include certain enabled Gems and starting levels.

Robotic project templates are designed to help you to quickly start simulating robots in O3DE with ROS 2.

ROS 2 Project Templates

There are three templates for robotics:

:bulb: The template repositories also include examples that you can try out by following their README files.

Create a new project with a template

To create a project with a template, you may use GUI or command line. The quickest way is to run the following commands (adjust PROJECT_NAME, PROJECT_PATH and the template as you wish):

export PROJECT_NAME=MySimulationProject
export PROJECT_PATH=${HOME}/projects/${PROJECT_NAME}
${O3DE_HOME}/scripts/ create-project --project-path $PROJECT_PATH --template-path ${O3DE_EXTRAS_HOME}/Templates/Ros2ProjectTemplate 

For more information, refer to Project Creation


The ROS 2 Gem is built when you build an O3DE project with the ROS 2 Gem enabled.

Make sure to source your ROS 2 workspace before building.

For convenience, here is an example of parametrized CMake calls:

cmake --build build/linux --config profile --target ${PROJECT_NAME} Editor ${PROJECT_NAME}.Assets 

These commands build O3DE with PhysX 5 (as opposed to default PhysX 4), which is better suited for robotic simulation. For a deeper understanding on how O3DE projects are built, please refer to Configure and Build.

Launching your project in O3DE Editor

Once your project is built, run the following command to start the Editor: