From 3016ade72eafa3eb8375a721a74498f8f6697be8 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Wed, 17 Jan 2024 11:19:02 +0100 Subject: [PATCH] add option to choose desired ROS 2 middleware --- .gitlab-ci/docker-ros.yml | 1 + README.md | 4 ++++ action.yml | 7 +++++++ docker/Dockerfile | 11 +++++++++++ scripts/build.sh | 1 + scripts/ci.sh | 1 + templates/docker-compose.template.yml | 1 + 7 files changed, 26 insertions(+) diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index e7888ac..3f22462 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -24,6 +24,7 @@ variables: ENABLE_INDUSTRIAL_CI: 'false' # Enable industrial_ci ENABLE_SINGLEARCH_PUSH: 'false' # Enable push of single arch images with [-amd64|-arm64] postfix ENABLE_PUSH_AS_LATEST: 'false' # Push images with tag `latest`/`latest-dev` in addition to the configured image names + RMW_IMPLEMENTATION: 'rmw_cyclonedds_cpp' # RMW implementation to use (only for ROS 2) ROS_DISTRO: '' # ROS Distro (required if ROS is not installed in `base-image`) GIT_HTTPS_SERVER: ${CI_SERVER_HOST} # Server URL (without protocol) for cloning private Git repositories via HTTPS GIT_HTTPS_USER: gitlab-ci-token # Username for cloning private Git repositories via HTTPS diff --git a/README.md b/README.md index 7d0f1b7..8c9aefd 100644 --- a/README.md +++ b/README.md @@ -432,6 +432,10 @@ Create a folder `additional-files` in your `docker` folder (or configure a diffe - **`registry-user` | `REGISTRY_USER`** Docker registry username *default:* `${{ github.actor }}` | `$CI_REGISTRY_USER` +- **`rmw-implementation` | `RMW_IMPLEMENTATION`** + ROS 2 middleware implementation + *default:* `rmw_cyclonedds_cpp` + *supported values:* `rmw_fastrtps_cpp`, `rmw_cyclonedds_cpp`, `rmw_gurumdds_cpp`, ... - **`ros-distro` | `ROS_DISTRO`** ROS Distro *required if ROS is not installed in `base-image`* diff --git a/action.yml b/action.yml index 99d3720..dffe720 100644 --- a/action.yml +++ b/action.yml @@ -47,6 +47,10 @@ inputs: description: "Docker registry password" default: ${{ github.token }} + rmw-implementation: + description: "RMW implementation to use (only for ROS 2)" + default: rmw_cyclonedds_cpp + ros-distro: description: "ROS Distro (required if ROS is not installed in `base-image`)" @@ -178,6 +182,7 @@ runs: IMAGE_TAG: ${{ inputs.image-tag }} DEV_IMAGE_NAME: ${{ inputs.dev-image-name }} DEV_IMAGE_TAG: ${{ inputs.dev-image-tag }} + RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }} ROS_DISTRO: ${{ inputs.ros-distro }} GIT_HTTPS_SERVER: ${{ inputs.git-https-server }} GIT_HTTPS_USER: ${{ inputs.git-https-user }} @@ -235,6 +240,7 @@ runs: DEV_IMAGE_NAME: ${{ inputs.dev-image-name }} DEV_IMAGE_TAG: ${{ inputs.dev-image-tag }} ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }} + RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }} ROS_DISTRO: ${{ inputs.ros-distro }} GIT_HTTPS_SERVER: ${{ inputs.git-https-server }} GIT_HTTPS_USER: ${{ inputs.git-https-user }} @@ -270,6 +276,7 @@ runs: DEV_IMAGE_NAME: ${{ inputs.dev-image-name }} DEV_IMAGE_TAG: latest-dev ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }} + RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }} ROS_DISTRO: ${{ inputs.ros-distro }} GIT_HTTPS_SERVER: ${{ inputs.git-https-server }} GIT_HTTPS_USER: ${{ inputs.git-https-user }} diff --git a/docker/Dockerfile b/docker/Dockerfile index c7921c1..799e056 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -205,6 +205,17 @@ RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ fi \ && rm -rf /var/lib/apt/lists/* +# install desired ROS 2 middleware +ARG RMW_IMPLEMENTATION +ENV RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION} +RUN apt-get update && \ + if [[ "$ROS_VERSION" == "2" ]]; then \ + apt-get update && \ + RMW_PACKAGE=ros-$ROS_DISTRO-$(echo $RMW_IMPLEMENTATION | tr '_' '-') && \ + apt-get install -y $RMW_PACKAGE && \ + rm -rf /var/lib/apt/lists/* ; \ + fi + # source ROS RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc diff --git a/scripts/build.sh b/scripts/build.sh index 5f3a5bd..83b59a6 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -17,6 +17,7 @@ build_image() { $(if [[ "${_ENABLE_IMAGE_PUSH}" == "true" ]]; then echo "--push"; else echo "--load"; fi) \ --build-arg BASE_IMAGE="${BASE_IMAGE}" \ --build-arg COMMAND="${COMMAND}" \ + $(if [[ -n "${RMW_IMPLEMENTATION}" ]]; then echo "--build-arg RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION}"; fi) \ $(if [[ -n "${ROS_DISTRO}" ]]; then echo "--build-arg ROS_DISTRO=${ROS_DISTRO}"; fi) \ $(if [[ -n "${GIT_HTTPS_SERVER}" ]]; then echo "--build-arg GIT_HTTPS_SERVER=${GIT_HTTPS_SERVER}"; fi) \ $(if [[ -n "${GIT_HTTPS_USER}" ]]; then echo "--build-arg GIT_HTTPS_USER=${GIT_HTTPS_USER}"; fi) \ diff --git a/scripts/ci.sh b/scripts/ci.sh index e6e6590..8f76fd4 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -20,6 +20,7 @@ DEV_IMAGE_TAG="${DEV_IMAGE_TAG:-${IMAGE_TAG}-dev}" IMAGE="${IMAGE_NAME}:${IMAGE_TAG}" DEV_IMAGE="${DEV_IMAGE_NAME}:${DEV_IMAGE_TAG}" ENABLE_SINGLEARCH_PUSH="${ENABLE_SINGLEARCH_PUSH:-false}" +RMW_IMPLEMENTATION="${RMW_IMPLEMENTATION:-}" ROS_DISTRO="${ROS_DISTRO:-}" GIT_HTTPS_SERVER="${GIT_HTTPS_SERVER:-}" GIT_HTTPS_USER="${GIT_HTTPS_USER:-}" diff --git a/templates/docker-compose.template.yml b/templates/docker-compose.template.yml index 5018b47..54280bf 100644 --- a/templates/docker-compose.template.yml +++ b/templates/docker-compose.template.yml @@ -27,6 +27,7 @@ x-build: &build GIT_HTTPS_USER: $GIT_HTTPS_USER GIT_SSH_KNOWN_HOST_KEYS: $GIT_SSH_KNOWN_HOST_KEYS GIT_SSH_PRIVATE_KEY: $GIT_SSH_PRIVATE_KEY + RMW_IMPLEMENTATION: $RMW_IMPLEMENTATION ROS_DISTRO: $ROS_DISTRO services: