Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ros/ubuntu: add Docker workspace ros/ubuntu to build an image with ROS 1 + orocos_toolchain + rtt_ros_integration #4

Open
wants to merge 1 commit into
base: feature/preinstall-rtt-ros2-integration-and-common-interfaces
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions ros/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
## Provide Orocos Toolchain (RTT/OCL) and rtt_ros_integration overlay workspace on top of the
## official ROS 2 docker images.

ARG ROS_DISTRO
ARG UBUNTU_DISTRO

## *************************************************************************************************
## Stage base: prepare build environment
## *************************************************************************************************
FROM ros:${ROS_DISTRO}-ros-base-${UBUNTU_DISTRO} AS base

# add custom rosdep rule file and update rosdep database
COPY prereqs.yaml /etc/ros/rosdep/
RUN echo "yaml file:///etc/ros/rosdep/prereqs.yaml" > /etc/ros/rosdep/sources.list.d/10-custom.list
RUN rosdep update

# install python-vcstool used to clone repositories below
RUN apt-get update \
&& apt-get install -y python-vcstool \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Ubuntu focal, the package python-vcstool doesn't exist, since python3 is the default version (python3-vcstool). This impedes Ubuntu focal ROS noetic to be built. Also, git is missing in noetic OSRF (core, base).

Suggested change
&& apt-get install -y python-vcstool \
&& if [ $(lsb_release -cs) = "focal" ] ; then VCS_PKGS="python3-vcstool git" ; else VCS_PKGS="python-vcstool" ; fi \
&& apt-get install -y ${VCS_PKGS} \

&& rm -rf /var/lib/apt/lists/*

# setup new entrypoint and default command
COPY orocos_entrypoint.sh /orocos_entrypoint.sh
ENTRYPOINT [ "/orocos_entrypoint.sh" ]
CMD [ "bash" ]

## *************************************************************************************************
## Stage orocos_toolchain: clone, build and install Orocos Toolchain using CMake (with CORBA)
## *************************************************************************************************
FROM base AS orocos_toolchain

COPY orocos_toolchain.repos /build/src/
RUN vcs import --recursive /build/src < /build/src/orocos_toolchain.repos \
&& cd /build \
&& . /opt/ros/${ROS_DISTRO}/local_setup.sh \
#
# Install dependencies with rosdep
&& apt-get update \
&& apt-get install -y ruby \
&& rosdep install -y --from-path src --ignore-src \
&& rm -rf /var/lib/apt/lists/* \
#
# Build the workspace
&& catkin_make_isolated \
--install \
--install-space /opt/orocos/${ROS_DISTRO} \
--cmake-args \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_CORBA=ON \
-DCORBA_IMPLEMENTATION=OMNIORB \
-DOROCOS_INSTALL_INTO_PREFIX_ROOT=ON \
#
# Cleanup
&& rm -rf /build

## *************************************************************************************************
## Stage overlay: clone, build and install overlay workspaces to /opt/ros/${ROS_DISTRO}
## *************************************************************************************************
FROM orocos_toolchain AS overlay

COPY overlay.repos /build/src/
RUN vcs import --recursive /build/src < /build/src/overlay.repos \
&& cd /build \
&& . /opt/ros/${ROS_DISTRO}/local_setup.sh \
&& . /opt/orocos/${ROS_DISTRO}/local_setup.sh \
#
# Install dependencies with rosdep
&& apt-get update \
&& ROS_PACKAGE_PATH=/opt/orocos/${ROS_DISTRO}/share:/opt/ros/${ROS_DISTRO}/share \
rosdep install -y --from-path . --ignore-src \
&& rm -rf /var/lib/apt/lists/* \
#
# Build the workspace
&& catkin_make_isolated \
--install \
--install-space /opt/orocos/${ROS_DISTRO} \
--cmake-args \
-DCATKIN_ENABLE_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release \
#
# Cleanup
&& rm -rf /build
24 changes: 24 additions & 0 deletions ros/ubuntu/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# Build hook for Docker Hub.
# See https://docs.docker.com/docker-hub/builds/advanced/.

#DOCKER_TAG=eloquent-ros-base-bionic
ROS_DISTRO=${DOCKER_TAG%%-*}
UBUNTU_DISTRO=${DOCKER_TAG##*-}

# Build and push the stage orocos_toolchain first.
# Caching should make sure that the actual build step only rebuilds the final stage overlay.
docker build \
-t orocos/ros-ci:${DOCKER_TAG} \
--build-arg ROS_DISTRO=${ROS_DISTRO} \
--build-arg UBUNTU_DISTRO=${UBUNTU_DISTRO} \
--target orocos_toolchain \
.
docker push orocos/ros-ci:${DOCKER_TAG}

# Only then build the final stage. It will be pushed by Docker Hub.
docker build \
-t orocos/ros:${DOCKER_TAG} \
--build-arg ROS_DISTRO=${ROS_DISTRO} \
--build-arg UBUNTU_DISTRO=${UBUNTU_DISTRO} \
.
22 changes: 22 additions & 0 deletions ros/ubuntu/orocos_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -e

# Setup ROS and orocos environment
source "/opt/ros/$ROS_DISTRO/setup.sh"
[ -d "/opt/orocos/$ROS_DISTRO" ] && source "/opt/orocos/$ROS_DISTRO/local_setup.sh"

# Append commands to setup ROS and orocos environment to ~/.bashrc.
# This is only relevant if the command to be executed ("$@") is an interactive bash shell.
# Or for later `docker exec -it bash`.
# It is not sufficient to source bash-specific setup scripts here, because bash is executed as
# a new process. Aliases, command-line completion etc. configured here would have no effect.
if ! grep -q '# setup ROS and orocos environment' ~/.bashrc >/dev/null; then
cat >>~/.bashrc <<'EOF'

# setup ROS and orocos environment
source "/opt/ros/$ROS_DISTRO/setup.bash"
[ -d "/opt/orocos/$ROS_DISTRO" ] && source "/opt/orocos/$ROS_DISTRO/local_setup.bash"
EOF
fi

exec "$@"
5 changes: 5 additions & 0 deletions ros/ubuntu/orocos_toolchain.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repositories:
orocos_toolchain:
type: git
url: https://github.com/orocos-toolchain/orocos_toolchain.git
version: ros2
Copy link

@spd-intermodalics spd-intermodalics Aug 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the version for ros2, I guess:

Suggested change
version: ros2
version: toolchain-2.9

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the branch toolchain-2.9 contains a bug that prevents from building when using focal and noetic, referred to in this issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now it was intentional to use the ros2 branch. It is actually not specific to ROS 2, but has patches that have been applied while working on the ROS 2 integration and that still need to be submitted as individual pull requests to master. It also disables the build of other toolchain packages than RTT and OCL, for exactly the reasons you mentioned.

Once that is done and all required patches and also branch toolchain-2.9 itself has been merged back into master, we can switch back to the default branch HEAD here, too.

5 changes: 5 additions & 0 deletions ros/ubuntu/overlay.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repositories:
rtt_ros_integration:
type: git
url: https://github.com/orocos/rtt_ros_integration.git
version: HEAD
19 changes: 19 additions & 0 deletions ros/ubuntu/prereqs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Package ruby-facets does not exist anymore since Ubuntu Focal.
# Use gem instead.
facets:
ubuntu:
'*': ruby-facets
focal:
gem: facets

# Use metaruby and utilrb from rubygems.org.
metaruby:
debian:
gem: metaruby
ubuntu:
gem: metaruby
utilrb:
debian:
gem: utilrb
ubuntu:
gem: utilrb
8 changes: 4 additions & 4 deletions ros2/ubuntu/orocos_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
set -e

# Setup ros2 and orocos environment
# Setup ROS and orocos environment
source "/opt/ros/$ROS_DISTRO/setup.sh"
[ -d "/opt/orocos/$ROS_DISTRO" ] && source "/opt/orocos/$ROS_DISTRO/local_setup.sh"

# Append commands to setup ros2 and orocos environment to ~/.bashrc.
# Append commands to setup ROS and orocos environment to ~/.bashrc.
# This is only relevant if the command to be executed ("$@") is an interactive bash shell.
# Or for later `docker exec -it bash`.
# It is not sufficient to source bash-specific setup scripts here, because bash is executed as
# a new process. Aliases, command-line completion etc. configured here would have no effect.
if ! grep -q '# setup ros2 and orocos environment' ~/.bashrc >/dev/null; then
if ! grep -q '# setup ROS and orocos environment' ~/.bashrc >/dev/null; then
cat >>~/.bashrc <<'EOF'

# setup ros2 and orocos environment
# setup ROS and orocos environment
source "/opt/ros/$ROS_DISTRO/setup.bash"
[ -d "/opt/orocos/$ROS_DISTRO" ] && source "/opt/orocos/$ROS_DISTRO/local_setup.bash"
EOF
Expand Down