Skip to content

Instantly share code, notes, and snippets.

@michalpelka
Created January 27, 2023 08:06
Show Gist options
  • Select an option

  • Save michalpelka/a571f914bf5c9822935f2654e45811ec to your computer and use it in GitHub Desktop.

Select an option

Save michalpelka/a571f914bf5c9822935f2654e45811ec to your computer and use it in GitHub Desktop.
Dockerfile
FROM ros:humble-ros-core-jammy
ENV O3DE_HASH=5b344a0be6
ENV O3DE_EXTRAS_HASH=ros2_project_template
ENV PROJECT_NAME=WarehouseTest
ENV WORKDIR=/data/workspace
WORKDIR $WORKDIR
ARG DEBIAN_FRONTEND=noninteractive
# Setup time zone and locale data (necessary for SSL and HTTPS packages)
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get -y \
install \
tzdata \
locales \
keyboard-configuration \
&& rm -rf /var/lib/apt/lists/*
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales \
&& update-locale LANG=en_US.UTF-8
ENV LANG=en_US.UTF-8
# Install common tools
# deps in https://github.com/o3de/o3de/blob/development/scripts/build/build_node/Platform/Linux/package-list.ubuntu-jammy.txt
RUN apt-get update && apt-get install -y \
bc \
bind9-utils \
binutils \
ca-certificates \
clang \
cmake \
file \
firewalld \
git \
git-lfs \
jq \
kbd \
kmod \
less \
lsb-release \
libglu1-mesa-dev \
libxcb-xinerama0 \
libfontconfig1-dev \
libcurl4-openssl-dev \
libnvidia-gl-470 \
libssl-dev \
libxcb-xkb-dev \
libxkbcommon-x11-dev \
libxkbcommon-dev \
libxcb-xfixes0-dev \
libxcb-xinput-dev \
libxcb-xinput0 \
libpcre2-16-0 \
lsof \
net-tools \
ninja-build \
pciutils \
python3-pip \
software-properties-common \
sudo \
tar \
unzip \
vim \
wget \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
# Gem + ROS pacakges
RUN apt-get update && apt-get install -y \
ros-humble-ackermann-msgs \
ros-humble-control-toolbox \
ros-humble-gazebo-msgs \
ros-humble-joy \
ros-humble-navigation2 \
ros-humble-rviz2 \
ros-humble-tf2-ros \
ros-humble-urdfdom \
ros-humble-vision-msgs \
&& rm -rf /var/lib/apt/lists/*
## Symlink clang version to non-versioned clang and set cc to clang
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
# Install o3de
RUN git clone https://github.com/o3de/o3de.git \
&& cd o3de \
&& git checkout ${O3DE_HASH} \
&& git lfs install \
&& git lfs pull \
&& python/get_python.sh
# Install o3de-extras
RUN git clone https://github.com/RobotecAI/o3de-extras.git \
&& cd o3de-extras \
&& git checkout ${O3DE_EXTRAS_HASH} \
&& git lfs install \
&& git lfs pull
# regiester engine and Gems from o3de-extras
RUN ./o3de/scripts/o3de.sh register --this-engine \
&& ./o3de/scripts/o3de.sh register --gem-path ./o3de-extras/Gems/ROS2 \
&& ./o3de/scripts/o3de.sh register --gem-path ./o3de-extras/Gems/RosRobotSample \
&& ./o3de/scripts/o3de.sh register --gem-path ./o3de-extras/Gems/WarehouseSample
# create in project from template in o3de-extras
RUN ./o3de/scripts/o3de.sh create-project \
--project-path ${WORKDIR}/${PROJECT_NAME} \
--template-path ./o3de-extras/Templates/Ros2ProjectTemplate/ -f
WORKDIR ${WORKDIR}/${PROJECT_NAME}
RUN . /opt/ros/humble/setup.sh \
&& cmake -B build/linux -S . -G "Ninja Multi-Config" -DLY_STRIP_DEBUG_SYMBOLS=ON
RUN . /opt/ros/humble/setup.sh \
&& cmake --build build/linux --config profile --target ${PROJECT_NAME} Editor AssetProcessor
# This final step takes long since they Assets will be downloading
RUN . /opt/ros/humble/setup.sh \
&& echo "This final step can take more than 1 hour. Good time for going for a coffee :)" \
&& cmake --build build/linux --config profile --target ${PROJECT_NAME}.Assets
# Installing some ros2 for navigation
RUN apt-get update && apt-get install -y \
python3-colcon-common-extensions \
ros-humble-cyclonedds \
ros-humble-rmw-cyclonedds-cpp \
ros-humble-slam-toolbox \
ros-humble-navigation2 \
ros-humble-nav2-bringup \
ros-humble-pointcloud-to-laserscan \
ros-humble-teleop-twist-keyboard \
ros-humble-ackermann-msgs \
ros-humble-topic-tools \
&& rm -rf /var/lib/apt/lists/*
RUN pip install python-statemachine
WORKDIR $WORKDIR
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

Dockerfile for running the WarehouseTest

The Dockerfile is going to create an Ubuntu Jammy + ROS Humble platform that prepares the O3DE simulator together with the o3de-ros2-gem to run the demo in this repository.

Requisites

Building the Docker Image

To build the Dockerfile the only required step :

docker build -t warehousetest -f Dockerfile .

Note: the build process is going to download all the necessary assets for running the demo so it can take several hours depending on the Internet connection.

Running the Docker Image

GPU acceleration is required for running O3DE correctly. For running docker with support for GPU please follow the documentation for docker run.

Another option is to install and use rocker.

rocker --x11 --nvidia warehousetest --name warehousetestcontainer

The Dockerfile leaves ready the compilation of all the O3DE artifacts to be able to execute the Editor.

/data/workspace/WarehouseTest/build/linux/bin/profile/Editor

Runing nav2 stack

Attach to container :

docker exec -it warehousetestcontainer /bin/bash

and launch:

source /opt/ros/humble/setup.sh 
ros2 launch /data/workspace/WarehouseTest/Examples/slam_navigation/launch/navigation.launch.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment