Skip to main content

O3DE: ROSbot XL + SLAM Toolbox

About

Choosing the right simulation engine is crucial for testing your robotics use case and ensuring the successful development of a project, as it directly impacts the accuracy and effectiveness of the simulation process. While engines like Gazebo or Webots, designed specifically for robotics simulation, offer advantages such as accurate sensor data simulation and a variety of pre-built robot models, they may lack the level of realism provided by game engines. That's why in certain cases, using a highly realistic game engine such as O3DE can be beneficial, as it helps bridge the gap between simulation and reality, enhancing the overall simulation experience.

The tutorial below demonstrates how you can use O3DE to run the ROSbot XL simulation.

O3DE is an open-source, real-time 3D simulation engine governed by the Linux Foundation. With the ROS 2 Gem extension developed by Robotec.ai and AWS Game Tech, you can utilize O3DE to develop robotic simulations using ROS 2 tools and components.

Additionally, the tutorial demonstrates the use of SLAM Toolbox for mapping an unknown environment. In the video below you can see the final result of this guide.


Quick Start

Prerequisites

Before we begin, there are a few things you'll need to have set up on your computer. First, you'll need to install Docker Engine and Docker Compose by following the official installation guide. This project has been tested on the following setup:

$ docker compose version
Docker Compose version v2.16.0
$
$ docker --version
Docker version 23.0.1, build a5ee5b1

Additionally, this project uses NVIDIA Container Runtime. So, please make sure that you have an NVIDIA GPU and the NVIDIA Container Toolkit installed on your system before moving forward.

Clone the repository:

git clone https://github.com/husarion/o3de-docker.git
cd o3de-docker/demo

Pull the Docker images:

docker compose pull

Start the containers in a new terminal:

xhost +local:docker && \
docker compose up

Now you will need to open DemoLevel and start the simulation. After O3DE finishes loading you should see the welcome screen.

Click on the Open button:

o3de-welcome

Then select DemoLevel from Levels and open it:

o3de-open-level

Finally click the [Play Controls] button in the top-right corner to start the simulation:

o3de-sim-stopped

Now you should see the following screen:

o3de-sim-started

For manual ROSbot XL control just use arrow keys on your keyboard in the O3DE simulation environment. You should be all set and mapping should work now.

Source code

You can access the full source code for this project on GitHub at the following link: https://github.com/husarion/o3de-docker.

Let's look at the main docker compose file:

compose.yaml
# Usage:
# xhost +local:docker && docker compose -f compose.sim.o3de.yaml up

x-net-config:
&net-config
network_mode: host
ipc: host
env_file: net.env

x-gpu-config:
&gpu-config
runtime: nvidia
environment:
- DISPLAY=${DISPLAY:?err}
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=all

services:
rviz:
image: husarion/rviz2:galactic-8.5.2-20230204-stable
<<: [ *net-config, *gpu-config ]
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- ./config/rosbot_xl.rviz:/root/.rviz2/default.rviz
- ./config/rosbot_xl.urdf:/robot_models/rosbot_xl.urdf

rosbot-xl:
image: husarion/o3de:1.2.0
<<: [ *net-config, *gpu-config ]
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
command: /data/workspace/ROSbotXLDemo/build/linux/bin/profile/Editor

mapping:
image: husarion/slam-toolbox:humble-2.6.4-20230204-stable
<<: *net-config
volumes:
- ./config/slam_toolbox_params.yaml:/slam_params.yaml
command: >
ros2 launch slam_toolbox online_sync_launch.py
slam_params_file:=/slam_params.yaml
use_sim_time:=True

map-saver:
image: husarion/nav2-map-server:humble-1.1.5-20230204-stable
<<: *net-config
volumes:
- ./maps:/maps
command: bash -c "while true; do ros2 run nav2_map_server map_saver_cli --free 0.15 --fmt png -f /maps/map; sleep 5; done"

There are 4 Docker services:

  • The rviz service launches the RViz2 ROS 2 Visualization tool. You can find the source code for building this Docker image here
  • The rosbot-xl service starts the ROSbot XL O3DE simulation. The source code for building this Docker image can be found here.
  • The mapping service is a Dockerized version of the SLAM Toolbox package.
  • The map-saver service periodically saves the current map to the maps directory.

In addition, configuration files are also included in the project repository and are bind-mounted to the rviz and mapping services.

Summary

That's all there is to it! If you're interested in running your own ROS 2 code with O3DE, all you need to do is create a minimal Docker image that runs your ROS 2 node. You can easily reuse the husarion/o3de Docker image. This makes it easy to run your own ROS 2 code with O3DE and provides a great way to test and debug your code in a simulated environment.

In this project, we used a combination of SLAM Toolbox, O3DE, and Docker to create a map of the unknown world using ROSbot XL in simulation:

  • O3DE is an open-source, real-time 3D simulation engine. Thanks to the ROS 2 Gem extension developed by Robotec.ai and AWS Game Tech, you can use O3DE to develop robotic simulations through ROS 2 tools and components. O3DE lets you use AAA game tier 3D engine to simulate your robotic application. Realistic graphics can be really beneficial when closing the gap between simulation and reality.
  • SLAM Toolbox was great for creating the map because it is a powerful tool that allows for easy implementation of simultaneous localization and mapping (SLAM) algorithms.
  • Finally, Docker was a great choice for this project because it allows for easy deployment and management of the different components of the simulation, such as the RViz2 visualization tool, the ROSbot XL O3DE simulation, and the SLAM Toolbox package. By using Docker, we were able to easily set up and run the simulation with minimal setup and configuration.