Skip to content

Commit 147b6e7

Browse files
committed
Merge branch 'o3de_curiosity_docker'
PR to solve space-ros#181 by Azmyin Md. Kamal. Part of submission to the NASA Space ROS Sim Summer Sprint Challenge 2024. Freelancer id: azmyin12 Description: Integrates Open 3D Engine natively with Space ROS via the ROS 2 Gem and showcases photorealistic, physics-defined simulation of Curiosity rover in a new test environment inpsired by the NASA JPL's Mars Yard testing ground
2 parents 0c482ba + c177363 commit 147b6e7

9 files changed

+488
-0
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"cmake.configureOnOpen": true
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
FROM ros:humble-ros-core-jammy
2+
3+
ENV O3DE_HASH=5b344a0be6
4+
ENV O3DE_EXTRAS_HASH=ros2_project_template
5+
ENV PROJECT_NAME=WarehouseTest
6+
7+
ENV WORKDIR=/data/workspace
8+
WORKDIR $WORKDIR
9+
10+
ARG DEBIAN_FRONTEND=noninteractive
11+
12+
# Setup time zone and locale data (necessary for SSL and HTTPS packages)
13+
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get -y \
14+
install \
15+
tzdata \
16+
locales \
17+
keyboard-configuration \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
21+
&& dpkg-reconfigure --frontend=noninteractive locales \
22+
&& update-locale LANG=en_US.UTF-8
23+
24+
ENV LANG=en_US.UTF-8
25+
26+
# Install common tools
27+
# deps in https://github.com/o3de/o3de/blob/development/scripts/build/build_node/Platform/Linux/package-list.ubuntu-jammy.txt
28+
RUN apt-get update && apt-get install -y \
29+
bc \
30+
bind9-utils \
31+
binutils \
32+
ca-certificates \
33+
clang \
34+
cmake \
35+
file \
36+
firewalld \
37+
git \
38+
git-lfs \
39+
jq \
40+
kbd \
41+
kmod \
42+
less \
43+
lsb-release \
44+
libglu1-mesa-dev \
45+
libxcb-xinerama0 \
46+
libfontconfig1-dev \
47+
libcurl4-openssl-dev \
48+
libnvidia-gl-470 \
49+
libssl-dev \
50+
libxcb-xkb-dev \
51+
libxkbcommon-x11-dev \
52+
libxkbcommon-dev \
53+
libxcb-xfixes0-dev \
54+
libxcb-xinput-dev \
55+
libxcb-xinput0 \
56+
libpcre2-16-0 \
57+
lsof \
58+
net-tools \
59+
ninja-build \
60+
pciutils \
61+
python3-pip \
62+
software-properties-common \
63+
sudo \
64+
tar \
65+
unzip \
66+
vim \
67+
wget \
68+
xz-utils \
69+
&& rm -rf /var/lib/apt/lists/*
70+
71+
# Gem + ROS pacakges
72+
RUN apt-get update && apt-get install -y \
73+
ros-humble-ackermann-msgs \
74+
ros-humble-control-toolbox \
75+
ros-humble-gazebo-msgs \
76+
ros-humble-joy \
77+
ros-humble-navigation2 \
78+
ros-humble-rviz2 \
79+
ros-humble-tf2-ros \
80+
ros-humble-urdfdom \
81+
ros-humble-vision-msgs \
82+
&& rm -rf /var/lib/apt/lists/*
83+
84+
## Symlink clang version to non-versioned clang and set cc to clang
85+
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 \
86+
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
87+
88+
# Install o3de
89+
RUN git clone https://github.com/o3de/o3de.git \
90+
&& cd o3de \
91+
&& git checkout ${O3DE_HASH} \
92+
&& git lfs install \
93+
&& git lfs pull \
94+
&& python/get_python.sh
95+
96+
# Install o3de-extras
97+
RUN git clone https://github.com/RobotecAI/o3de-extras.git \
98+
&& cd o3de-extras \
99+
&& git checkout ${O3DE_EXTRAS_HASH} \
100+
&& git lfs install \
101+
&& git lfs pull
102+
103+
# regiester engine and Gems from o3de-extras
104+
RUN ./o3de/scripts/o3de.sh register --this-engine \
105+
&& ./o3de/scripts/o3de.sh register --gem-path ./o3de-extras/Gems/ROS2 \
106+
&& ./o3de/scripts/o3de.sh register --gem-path ./o3de-extras/Gems/RosRobotSample \
107+
&& ./o3de/scripts/o3de.sh register --gem-path ./o3de-extras/Gems/WarehouseSample
108+
109+
# create in project from template in o3de-extras
110+
RUN ./o3de/scripts/o3de.sh create-project \
111+
--project-path ${WORKDIR}/${PROJECT_NAME} \
112+
--template-path ./o3de-extras/Templates/Ros2ProjectTemplate/ -f
113+
114+
WORKDIR ${WORKDIR}/${PROJECT_NAME}
115+
116+
RUN . /opt/ros/humble/setup.sh \
117+
&& cmake -B build/linux -S . -G "Ninja Multi-Config" -DLY_STRIP_DEBUG_SYMBOLS=ON
118+
119+
RUN . /opt/ros/humble/setup.sh \
120+
&& cmake --build build/linux --config profile --target ${PROJECT_NAME} Editor AssetProcessor
121+
122+
# This final step takes long since they Assets will be downloading
123+
RUN . /opt/ros/humble/setup.sh \
124+
&& echo "This final step can take more than 1 hour. Good time for going for a coffee :)" \
125+
&& cmake --build build/linux --config profile --target ${PROJECT_NAME}.Assets
126+
127+
# Installing some ros2 for navigation
128+
RUN apt-get update && apt-get install -y \
129+
python3-colcon-common-extensions \
130+
ros-humble-cyclonedds \
131+
ros-humble-rmw-cyclonedds-cpp \
132+
ros-humble-slam-toolbox \
133+
ros-humble-navigation2 \
134+
ros-humble-nav2-bringup \
135+
ros-humble-pointcloud-to-laserscan \
136+
ros-humble-teleop-twist-keyboard \
137+
ros-humble-ackermann-msgs \
138+
ros-humble-topic-tools \
139+
&& rm -rf /var/lib/apt/lists/*
140+
141+
RUN pip install python-statemachine
142+
143+
WORKDIR $WORKDIR
144+
145+
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

o3de_curiosity_demo/Dockerfile

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Copyright 2024 Azmyin Md. Kamal
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# A Docker configuration script to build the o3de_curiosit_docker image that showcases Open 3D Engine
16+
# in simulating a Curiositry rover traversing through a test ground inspired by the NASA JPL Mars Yard
17+
#
18+
# The script provides the following build arguments:
19+
#
20+
# VCS_REF - The git revision of the Space ROS source code (no default value).
21+
# VERSION - The version of Space ROS (default: "preview")
22+
23+
FROM openrobotics/moveit2:latest
24+
25+
# Define arguments used in the metadata definition
26+
ARG VCS_REF
27+
ARG VERSION="preview"
28+
29+
# Specify the docker image metadata
30+
LABEL org.label-schema.schema-version="1.0"
31+
LABEL org.label-schema.name="Curiosity Rover"
32+
LABEL org.label-schema.description="Curiosity rover demo on a new test enviornment on the Space ROS platform and Open 3D Engine"
33+
LABEL org.label-schema.vendor="Nasa Space ROS Sim Summer Spring Challenge 2024"
34+
LABEL org.label-schema.version=${VERSION}
35+
LABEL org.label-schema.url="https://github.com/space-ros"
36+
LABEL org.label-schema.vcs-url="https://github.com/Mechazo11/space-ros-docker"
37+
LABEL org.label-schema.vcs-ref=${VCS_REF}
38+
39+
# Define a few key variables
40+
ENV DEMO_DIR=${HOME_DIR}/demos_ws
41+
ENV IGNITION_VERSION fortress
42+
ENV GZ_VERSION fortress
43+
44+
# Disable prompting during package installation
45+
ARG DEBIAN_FRONTEND=noninteractive
46+
47+
# Get rosinstall_generator
48+
# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that
49+
# the cache won't make it into the built image but will be maintained between steps.
50+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
51+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
52+
sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator
53+
54+
# TODO(anyone): remove demo-pkgs.txt, no packages left after exclusions
55+
# Generate repos file for demo dependencies, excluding packages from Space ROS core.
56+
# COPY --chown=${USERNAME}:${USERNAME} demo-pkgs.txt /tmp/
57+
# COPY --chown=${USERNAME}:${USERNAME} excluded-pkgs.txt /tmp/
58+
# RUN rosinstall_generator \
59+
# --rosdistro ${ROSDISTRO} \
60+
# --deps \
61+
# --exclude-path ${SPACEROS_DIR}/src \
62+
# --exclude-path ${MOVEIT2_DIR}/src \
63+
# --exclude $(cat /tmp/excluded-pkgs.txt) -- \
64+
# -- $(cat /tmp/demo-pkgs.txt) \
65+
# > /tmp/demo_generated_pkgs.repos
66+
67+
RUN mkdir -p ${DEMO_DIR}/src
68+
WORKDIR ${DEMO_DIR}
69+
70+
71+
# Install libmongoc for development
72+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
73+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
74+
sudo apt-get install libmongoc-dev -y
75+
76+
# Compile mongo cxx driver https://mongocxx.org/mongocxx-v3/installation/linux/
77+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
78+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
79+
sudo apt-get install libssl-dev build-essential devscripts debian-keyring fakeroot debhelper cmake libboost-dev libsasl2-dev libicu-dev libzstd-dev doxygen -y
80+
RUN wget https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.7/mongo-cxx-driver-r3.6.7.tar.gz
81+
RUN tar -xzf mongo-cxx-driver-r3.6.7.tar.gz
82+
RUN cd mongo-cxx-driver-r3.6.7/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local && sudo cmake --build . --target EP_mnmlstc_core && cmake --build . && sudo cmake --build . --target install
83+
84+
# Get the source for the dependencies
85+
# RUN vcs import src < /tmp/demo_generated_pkgs.repos
86+
COPY --chown=${USERNAME}:${USERNAME} demo_manual_pkgs.repos /tmp/
87+
RUN vcs import src < /tmp/demo_manual_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"'
88+
89+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
90+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
91+
sudo apt-get update -y \
92+
&& /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \
93+
&& /bin/bash -c 'source "${MOVEIT2_DIR}/install/setup.bash"' \
94+
&& rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROSDISTRO}
95+
96+
# Build the demo
97+
RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash && source ${MOVEIT2_DIR}/install/setup.bash \
98+
&& colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release'
99+
100+
# Add the user to the render group so that the user can access /dev/dri/renderD128
101+
RUN sudo usermod -aG render $USERNAME
102+
103+
# Setup the entrypoint
104+
COPY ./entrypoint.sh /
105+
ENTRYPOINT ["/entrypoint.sh"]
106+
CMD ["bash"]

o3de_curiosity_demo/README.md

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Integrating Open 3D Engine with Space ROS for an Accurate Physics Simulation of the Curiosity Rover: A Case Study
2+
3+
This docker image is part of a submission to the NASA Space ROS Sim Summer Spring Challenge 2024.
4+
Related Issue: [#181](https://github.com/space-ros/docker/issues/181)
5+
6+
Author: Azmyin Md. Kamal,
7+
Ph.D. student, iCORE Lab, MIE
8+
Louisiana State University,
9+
Baton Rounge, LA-70803
10+
11+
Date: 09/08/2024
12+
13+
14+
**TODO** a preview image once Bulding 336 asset is complete.
15+
16+
## Description
17+
18+
This README.md contains the build and usage instructions for **o3de_curiosity_demo**, a docker image that demonstrates the Curiosity rover traversing through a new test enviornment modelled after NASA JPL's Mars Yard testing ground. It is meant to showcase the integration of the Open 3D Engine with Space ROS via the [ROS 2 Gem](). All textures used are CC0, all models built are either from CC0 sources or made by me which, I hereby declare as also CC0. Open 3D Engine, ROS 2 Gem are all Apache 2.0 licensed. Space ROS and all other releated dependecies are also Apache 2.0 licensed. Please look into the attached url for seeing the demo in action.
19+
20+
**TODO** link to the 5 min video that will be submitted as part of the competition.
21+
22+
23+
The Dockerfile installs all of the prerequisite system dependencies for building the ros2 workspace, installs the Open 3D Engine, registers the engine and then downloads, and registers in order, the ```RobotSim``` O3DE project, the ```NasaCuriosityRover``` Gem and the ```MarsYard``` Gem. Finally, the docker file will build the entire project (takes 5 - 10 mins).
24+
25+
## Prerequisits
26+
27+
* Ensure Docker and then Earthly are installed correctly.
28+
29+
* Git clone this fork of ```space-ros/docker``` and change directory
30+
31+
```bash
32+
cd ~
33+
git clone --branch o3de_curiosity_docker --single-branch https://github.com/Mechazo11/space-ros-docker.git
34+
cd space-ros-docker
35+
```
36+
37+
* This docker image reqiures **space-ros** base image ```osrf/spaceros:latest```. Pull the latest build from docker hub
38+
39+
```bash
40+
docker pull osrf/space-ros
41+
```
42+
43+
* Buld moveit2 docker image
44+
45+
```bash
46+
cd moveit2
47+
./build.sh
48+
```
49+
50+
## Build the o3de_docker image
51+
52+
```bash
53+
cd ..
54+
cd o3de_curiosity_demo
55+
./build.sh
56+
```
57+
58+
* Checklist
59+
* Install
60+
61+
62+
* Install rosintall-generator: ```sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator```
63+
64+
* Install the lark library: ```pip3 install lark```
65+
66+
* Clone repositories into ```src``` folder: ```vcs import src < space-ros.repos```
67+
68+
* Clone simulation related packages: ```vcs import src < space-robot-sim.repos```
69+
70+
* Install all dependencies ```rosdep update && rosdep install --from-paths src --ignore-src -r -y --rosdistro humble --skip-keys urdfom_headers ikos```
71+
72+

o3de_curiosity_demo/build.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
ORG=openrobotics
4+
IMAGE=o3de_curiosity_docker
5+
TAG=latest
6+
7+
VCS_REF=""
8+
VERSION=preview
9+
10+
# Exit script with failure if build fails
11+
set -eo pipefail
12+
13+
echo ""
14+
echo "##### Building O3DE + Space ROS Demo Docker Image #####"
15+
echo ""
16+
17+
docker build -t $ORG/$IMAGE:$TAG \
18+
--build-arg VCS_REF="$VCS_REF" \
19+
--build-arg VERSION="$VERSION" .
20+
21+
echo ""
22+
echo "##### Done! #####"
23+

o3de_curiosity_demo/entrypoint.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Setup the Demo environment
5+
source "${DEMO_DIR}/install/setup.bash"
6+
exec "$@"

o3de_curiosity_demo/excluded-pkgs.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fastrtps
2+
fastcdr
3+
generate_parameter_library
4+
rmw_fastrtps_cpp
5+
rmw_fastrtps_dynamic_cpp
6+
rmw_fastrtps_shared_cpp
7+
rmw_connextdds
8+
rosidl_typesupport_fastrtps_c
9+
rosidl_typesupport_fastrtps_cpp
10+
fastrtps_cmake_module

0 commit comments

Comments
 (0)