A project template that allows building a multi-robot ROS2-enabled simulation. The template contains a level with a large warehouse scene called Warehouse.prefab
.
Due to ROS2 dependency, this project was prepared and tested on Linux operating system. It is recomended to use Ubuntu 22.04, however any distribution meeting following requirements may be used.
Refer to the O3DE System Requirements documentation to make sure that the system/hardware requirements are met. This project has the following dependencies:
Please make sure that clang
was installed and configured. For details refer to this section of O3DE documentation.
The following steps will assume the following:
${HOME}/O3DE
./home/${USER}/O3DE/Engines/Development
.In this tutorial, CLI tools will be used. It is also possible to use O3DE GUI to set up a project from template. See the O3DE Project manager documentation for more details. In such cases it is required to source your ROS2 distribution before launching O3DE manager:
source /opt/ros/humble/setup.bash
./build/linux/bin/profile/o3de
sudo apt install ros-${ROS_DISTRO}-ackermann-msgs ros-${ROS_DISTRO}-gazebo-msgs ros-${ROS_DISTRO}-control-toolbox
For convenienience, we'll define a shell variables with O3DE folders:
export O3DE_HOME=${HOME}/O3DE
Clone the o3de-extras
repository containing the template and asset gems
mkdir -p ${O3DE_HOME}/Projects
cd ${O3DE_HOME}/Projects
git clone https://github.com/o3de/o3de-extras.git
cd o3de-extras
git lfs install && git lfs pull
Register gems and project template.
${O3DE_HOME}/scripts/o3de.sh register --gem-path ${O3DE_HOME}/Projects/o3de-extras/Gems/ROS2
${O3DE_HOME}/scripts/o3de.sh register --gem-path ${O3DE_HOME}/Projects/o3de-extras/Gems/WarehouseAssets
${O3DE_HOME}/scripts/o3de.sh register --gem-path ${O3DE_HOME}/Projects/o3de-extras/Gems/ProteusRobot
${O3DE_HOME}/scripts/o3de.sh register --template-path ${O3DE_HOME}/Projects/o3de-extras/Templates/Ros2FleetRobotTemplate
Assign a name for the new project. In this example, it is assumed that it will be: Ros2FleetRobotTest
, and it will be located in ${O3DE_HOME}/Projects/Ros2FleetRobotTest
folder.
export PROJECT_NAME=Ros2FleetRobotTest
export PROJECT_PATH=${O3DE_HOME}/Projects/${PROJECT_NAME}
${O3DE_HOME}/scripts/o3de.sh create-project --project-path $PROJECT_PATH --template-name Ros2FleetRobotTemplate
Next, let us build the project with necessary elements of the O3DE engine and ROS2 Gem.
cd $PROJECT_PATH
source /opt/ros/humble/setup.bash
cmake -B build/linux -G "Ninja Multi-Config" -DLY_STRIP_DEBUG_SYMBOLS=TRUE -DLY_DISABLE_TEST_MODULES=ON
cmake --build build/linux --config profile --target $PROJECT_NAME.GameLauncher Editor
Finally, the O3DE with preloaded gems can be run:
$PROJECT_PATH/build/linux/bin/profile/Editor
The level contains spawn points configured to spawn Proteus robots. To spawn all spawn points call the following services in ROS2:
source /opt/ros/humble/setup.bash
ros2 service call /spawn_entity gazebo_msgs/srv/SpawnEntity '{name: 'proteus', xml: 'spawnPoint1'}'& \
ros2 service call /spawn_entity gazebo_msgs/srv/SpawnEntity '{name: 'proteus', xml: 'spawnPoint2'}'& \
ros2 service call /spawn_entity gazebo_msgs/srv/SpawnEntity '{name: 'proteus', xml: 'spawnPoint3'}'& \
ros2 service call /spawn_entity gazebo_msgs/srv/SpawnEntity '{name: 'proteus', xml: 'spawnPoint4'}'
Every spawned robot has its namespace. The first spawned robot publishes and subscribes to topics:
/proteus_1/cmd_vel
- the requested velocity/proteus_1/pc
- the LiDAR pointcloudThe first spawned robot also provides the following transformations:
/proteus_1/odom
/proteus_1/base_link
/proteus_1/lidar
To drive the second spawned robot use the following tool with topic name /proteus_2/cmd_vel
:
source /opt/ros/humble/setup.bash
ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args --remap /cmd_vel:=/proteus_2/cmd_vel