diff --git a/ros/humble/ubuntu/focal/README.md b/ros/humble/ubuntu/focal/README.md new file mode 100644 index 000000000..00a3dfb82 --- /dev/null +++ b/ros/humble/ubuntu/focal/README.md @@ -0,0 +1,21 @@ +# Instructions + +```bash +# Build ROS 2 humble from source in a focal container +cd ros-core +docker build . -t ros:humble-ros-core-focal + +# Install ROS 1 binaries and then build the ros1_bridge with colcon. +cd ../ros1-bridge +docker build . -t ros:humble-ros1-bridge-focal +dit ros:humble-ros1-bridge-focal +echo $CMAKE_PREFIX_PATH +echo $ROS1_INSTALL_PATH +echo $ROS2_INSTALL_PATH + +source ${ROS1_INSTALL_PATH}/setup.bash +# Now, source your local workspace with your messages +source install/setup.bash # Assume this sources /opt/ros/humble underlay +# You should see standard ROS message packages and your custom ones below. +ros2 pkg list | grep msgs +``` \ No newline at end of file diff --git a/ros/humble/ubuntu/focal/ros-core/Dockerfile b/ros/humble/ubuntu/focal/ros-core/Dockerfile new file mode 100644 index 000000000..9c394597b --- /dev/null +++ b/ros/humble/ubuntu/focal/ros-core/Dockerfile @@ -0,0 +1,83 @@ +# Adapted from ros/foxy/ubuntu/focal/ros-core/Dockerfile +# Usage: +# docker build . -t ros:humble-ros-core-focal +# +# Documentation for ros1_bridge setup: https://github.com/ros2/ros1_bridge?tab=readme-ov-file#building-the-bridge-from-source + +# We use focal becaue ROS 1 can be installed with binaries, +# and ROS 2 humble supports compilation as a Tier 3 platform per REP-2000. +# There is another repository that uses a Jammy base image, but requires +# more changes. +# https://github.com/TommyChangUMD/ros-humble-ros1-bridge-builder/issues/21 + +FROM ubuntu:focal + +# setup timezone +RUN echo 'Etc/UTC' > /etc/timezone && \ + ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \ + apt-get update && \ + apt-get install -q -y --no-install-recommends tzdata && \ + rm -rf /var/lib/apt/lists/* + +# install packages +RUN apt-get update && apt-get install -q -y --no-install-recommends \ + dirmngr \ + gnupg2 \ + && rm -rf /var/lib/apt/lists/* + +# setup keys +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B63CF8FDE49746E98FA01DDAD19BAB3CBF125EA + +# setup sources.list +RUN echo "deb http://snapshots.ros.org/foxy/final/ubuntu focal main" > /etc/apt/sources.list.d/ros2-snapshots.list + +# setup environment +ENV LANG C.UTF-8 +ENV LC_ALL C.UTF-8 + +ENV ROS_DISTRO humble + +# install ros2 packages +# Note - There don't seem to be separate VCS files for core, base, and everything. +# For now, just use upstream's big list. + +# https://docs.ros.org/en/humble/Installation/Alternatives/Ubuntu-Development-Setup.html#install-development-tools-and-ros-tools +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3-flake8-docstrings \ + python3-pip \ + python3-pytest-cov \ + ros-dev-tools \ + && rm -rf /var/lib/apt/lists/* + +RUN python3 -m pip install -U \ + flake8-blind-except \ + flake8-builtins \ + flake8-class-newline \ + flake8-comprehensions \ + flake8-deprecated \ + flake8-import-order \ + flake8-quotes \ + "pytest>=5.3" \ + pytest-repeat \ + pytest-rerunfailures + +WORKDIR /ws + +RUN mkdir src +RUN vcs import --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos src +RUN apt-get update && \ + rosdep init && \ + rosdep update && \ + rosdep install --from-paths src --ignore-src -y --skip-keys \ + "fastcdr rti-connext-dds-6.0.1 urdfdom_headers" + +# Disable testing to make the build faster. +RUN colcon build --install-base /opt/ros/humble --cmake-args -DBUILD_TESTING=OFF + +ENV ROS2_INSTALL_PATH=/opt/ros/humble + +# setup entrypoint +COPY ./ros_entrypoint.sh / + +ENTRYPOINT ["/ros_entrypoint.sh"] +CMD ["bash"] \ No newline at end of file diff --git a/ros/humble/ubuntu/focal/ros-core/ros_entrypoint.sh b/ros/humble/ubuntu/focal/ros-core/ros_entrypoint.sh new file mode 100755 index 000000000..c9298da7a --- /dev/null +++ b/ros/humble/ubuntu/focal/ros-core/ros_entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +# setup ros2 environment +# source "/opt/ros/$ROS_DISTRO/setup.bash" -- +exec "$@" diff --git a/ros/humble/ubuntu/focal/ros1-bridge/Dockerfile b/ros/humble/ubuntu/focal/ros1-bridge/Dockerfile new file mode 100644 index 000000000..456498886 --- /dev/null +++ b/ros/humble/ubuntu/focal/ros1-bridge/Dockerfile @@ -0,0 +1,66 @@ +# Adapted from ros/foxy/ubuntu/focal/ros1-bridge/Dockerfile + +# Usage: +# docker build . -t ros:humble-ros1-bridge-focal + +FROM ros:humble-ros-core-focal as base + +# install ros1 packages +RUN set -eux; \ + key='C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654'; \ + export GNUPGHOME="$(mktemp -d)"; \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key"; \ + mkdir -p /usr/share/keyrings; \ + gpg --batch --export "$key" > /usr/share/keyrings/ros1-latest-archive-keyring.gpg; \ + gpgconf --kill all; \ + rm -rf "$GNUPGHOME" + +# setup sources.list +RUN echo "deb [ signed-by=/usr/share/keyrings/ros1-latest-archive-keyring.gpg ] http://packages.ros.org/ros/ubuntu focal main" > /etc/apt/sources.list.d/ros1-latest.list + +# Install ROS 1 binaries, plus the message dependencies. +# If they don't have ROS 1 message binaries, you will need to set up a catkin workspace to build. +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-noetic-ros-core=1.5.0-1* \ + ros-noetic-mavros-msgs \ + && rm -rf /var/lib/apt/lists/* + +ENV ROS1_INSTALL_PATH=/opt/ros/noetic + +FROM base as final + +# The path or URL to the VCS repos. +ARG VCS_MSG_FILE="custom_msgs.repos" +# Which packages to build +ARG CUSTOM_MSG_PKGS="mavros_msgs" + + +WORKDIR /ws +RUN rm -rf src/* build install log +# This COPY is only necessary if you have a local file. +# If it's in a repo, comment this out and supply it as a build arg. +COPY $VCS_MSG_FILE . +RUN vcs import --input $VCS_MSG_FILE src +# Custom messages may have dependencies. +# Ignore any errors to keep it simple. +RUN apt-get update && \ + rosdep update && \ + rosdep install --from-paths src --ignore-src -y -r --skip-keys \ + "fastcdr rti-connext-dds-6.0.1 urdfdom_headers" +# Build all custom messge packages here in the right order. +RUN . /opt/ros/humble/setup.sh && colcon build --packages-up-to ${CUSTOM_MSG_PKGS} + +# Source the local workspace then build just the ros1_bridge. +# This links to all the other message packages at build time. +# Order of sourcing is VERY picky and NOT clear in the ros1_bridge README. +# https://github.com/ros2/ros1_bridge?tab=readme-ov-file#building-the-bridge-from-source +# This shows the source order with custom workspaces +# https://github.com/jayprajapati009/ros1_bridge_tutorial?tab=readme-ov-file#ros1_bridge-setup +RUN . /opt/ros/noetic/setup.sh && . /opt/ros/humble/setup.sh && . install/setup.sh && colcon build --packages-select ros1_bridge + +# setup entrypoint +COPY ./ros_entrypoint.sh / + +ENTRYPOINT ["/ros_entrypoint.sh"] +CMD ["bash"] + diff --git a/ros/humble/ubuntu/focal/ros1-bridge/custom_msgs.repos b/ros/humble/ubuntu/focal/ros1-bridge/custom_msgs.repos new file mode 100644 index 000000000..3f581b874 --- /dev/null +++ b/ros/humble/ubuntu/focal/ros1-bridge/custom_msgs.repos @@ -0,0 +1,17 @@ +repositories: + ros2/ros1_bridge: + type: git + url: https://github.com/ros2/ros1_bridge.git + version: master + + # MAVROS depends on geographic_msgs, but it's not available on focal. + # Therefore, we add it here. + # mavros_msgs: No definition of [geographic_msgs] for OS version [focal] + ros-geographic-info/geographic_info: + type: git + url: https://github.com/ros-geographic-info/geographic_info.git + version: ros2 + mavlink/mavros: + type: git + url: https://github.com/mavlink/mavros.git + version: ros2 diff --git a/ros/humble/ubuntu/focal/ros1-bridge/ros_entrypoint.sh b/ros/humble/ubuntu/focal/ros1-bridge/ros_entrypoint.sh new file mode 100755 index 000000000..c9298da7a --- /dev/null +++ b/ros/humble/ubuntu/focal/ros1-bridge/ros_entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + +# setup ros2 environment +# source "/opt/ros/$ROS_DISTRO/setup.bash" -- +exec "$@"