From d492233e6fbac73f0b0c6e6523558ac74824e672 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Tue, 22 Oct 2024 22:30:53 +0200 Subject: [PATCH 1/8] support usage of rmw_zenoh --- docker/Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ac68022..e2e8cb7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -214,7 +214,14 @@ RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ ARG RMW_IMPLEMENTATION="rmw_cyclonedds_cpp" ENV RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION} RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ - if [[ "$ROS_VERSION" == "2" ]]; then \ + if [[ "$RMW_IMPLEMENTATION" == "rmw_zenoh" ]]; then \ + git clone https://github.com/ros2/rmw_zenoh.git $WORKSPACE/src/upstream/rmw_zenoh && \ + rosdep init || true && \ + rosdep update --rosdistro $ROS_DISTRO && \ + apt-get update && \ + rosdep install -y --from-paths $WORKSPACE/src/upstream/rmw_zenoh --ignore-src --rosdistro $ROS_DISTRO && \ + rm -rf /var/lib/apt/lists/* ; \ + elif [[ "$ROS_VERSION" == "2" ]]; then \ apt-get update && \ RMW_PACKAGE=ros-$ROS_DISTRO-$(echo $RMW_IMPLEMENTATION | tr '_' '-') && \ apt-get install -y $RMW_PACKAGE && \ From 92c94f64f177440771225a25ff456c28ba61d39b Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Tue, 22 Oct 2024 22:31:59 +0200 Subject: [PATCH 2/8] fix some warnings --- docker/Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index e2e8cb7..a7c56e3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,7 @@ ARG BASE_IMAGE ############ dependencies ###################################################### -FROM ${BASE_IMAGE} as dependencies +FROM ${BASE_IMAGE} AS dependencies USER root SHELL ["/bin/bash", "-c"] @@ -232,14 +232,14 @@ RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc # set entrypoint -ENV TINI_VERSION v0.19.0 +ENV TINI_VERSION=v0.19.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TARGETARCH} /tini RUN chmod +x /tini COPY docker/docker-ros/docker/entrypoint.sh / ENTRYPOINT ["/tini", "--", "/entrypoint.sh"] ############ dev ############################################################### -FROM dependencies-install as dev +FROM dependencies-install AS dev # copy contents of repository from dependencies stage COPY --from=dependencies $WORKSPACE/src $WORKSPACE/src @@ -247,7 +247,7 @@ COPY --from=dependencies $WORKSPACE/src $WORKSPACE/src CMD ["bash"] ############ build ############################################################# -FROM dev as build +FROM dev AS build # build ROS workspace RUN if [[ -x "$(command -v colcon)" ]]; then \ @@ -259,7 +259,7 @@ RUN if [[ -x "$(command -v colcon)" ]]; then \ fi ############ run ############################################################### -FROM dependencies-install as run +FROM dependencies-install AS run # copy ROS install space from build stage COPY --from=build $WORKSPACE/install install From 30b1a3dc016cda8138ddaaa3e6b2c346c992776a Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Wed, 23 Oct 2024 11:19:27 +0200 Subject: [PATCH 3/8] update readme --- README.md | 2 +- docker/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 41dcfb1..ab3047f 100644 --- a/README.md +++ b/README.md @@ -453,7 +453,7 @@ The password of the custom user is set to its username (`dockeruser:dockeruser` - **`rmw-implementation` | `RMW_IMPLEMENTATION`** ROS 2 middleware implementation *default:* `rmw_cyclonedds_cpp` - *supported values:* `rmw_fastrtps_cpp`, `rmw_cyclonedds_cpp`, `rmw_gurumdds_cpp`, ... + *supported values:* `rmw_zenoh_cpp`, `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/docker/Dockerfile b/docker/Dockerfile index a7c56e3..2aa3e07 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -214,7 +214,7 @@ RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ ARG RMW_IMPLEMENTATION="rmw_cyclonedds_cpp" ENV RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION} RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ - if [[ "$RMW_IMPLEMENTATION" == "rmw_zenoh" ]]; then \ + if [[ "$RMW_IMPLEMENTATION" == "rmw_zenoh_cpp" ]]; then \ git clone https://github.com/ros2/rmw_zenoh.git $WORKSPACE/src/upstream/rmw_zenoh && \ rosdep init || true && \ rosdep update --rosdistro $ROS_DISTRO && \ From aa26a12422ad7c2b6855c82b0a29b96fecf758b8 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Wed, 23 Oct 2024 16:56:50 +0200 Subject: [PATCH 4/8] already build rmw_zenoh in dependecies-install stage --- docker/Dockerfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 2aa3e07..990ca15 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -215,12 +215,17 @@ ARG RMW_IMPLEMENTATION="rmw_cyclonedds_cpp" ENV RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION} RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ if [[ "$RMW_IMPLEMENTATION" == "rmw_zenoh_cpp" ]]; then \ - git clone https://github.com/ros2/rmw_zenoh.git $WORKSPACE/src/upstream/rmw_zenoh && \ + mkdir -p /opt/ws_rmw_zenoh/src && \ + git clone https://github.com/ros2/rmw_zenoh.git /opt/ws_rmw_zenoh/src/rmw_zenoh && \ rosdep init || true && \ rosdep update --rosdistro $ROS_DISTRO && \ apt-get update && \ - rosdep install -y --from-paths $WORKSPACE/src/upstream/rmw_zenoh --ignore-src --rosdistro $ROS_DISTRO && \ - rm -rf /var/lib/apt/lists/* ; \ + cd /opt/ws_rmw_zenoh && \ + rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO && \ + rm -rf /var/lib/apt/lists/* && \ + source /opt/ros/${ROS_DISTRO}/setup.bash && \ + colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release && \ + echo "source /opt/ws_rmw_zenoh/install/setup.bash" >> ~/.bashrc ; \ elif [[ "$ROS_VERSION" == "2" ]]; then \ apt-get update && \ RMW_PACKAGE=ros-$ROS_DISTRO-$(echo $RMW_IMPLEMENTATION | tr '_' '-') && \ From 4ec60afc0d9aa23b018cfa40f374b450aef7bbb5 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Wed, 23 Oct 2024 17:31:09 +0200 Subject: [PATCH 5/8] source rmw_zenoh before building ws --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 990ca15..37756ca 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -257,6 +257,7 @@ FROM dev AS build # build ROS workspace RUN if [[ -x "$(command -v colcon)" ]]; then \ source /opt/ros/${ROS_DISTRO}/setup.bash && \ + [[ -f /opt/ws_rmw_zenoh/install/setup.bash ]] && source /opt/ws_rmw_zenoh/install/setup.bash ; \ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release ; \ elif [[ -x "$(command -v catkin)" ]]; then \ catkin config --install --extend /opt/ros/${ROS_DISTRO} && \ From cd936d14e01edced2fcec2773e7b2f8040c0bd2c Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Wed, 23 Oct 2024 23:29:46 +0200 Subject: [PATCH 6/8] build rmw_zenoh into `/opt/ros/` --- docker/Dockerfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 37756ca..ba53c61 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -215,17 +215,17 @@ ARG RMW_IMPLEMENTATION="rmw_cyclonedds_cpp" ENV RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION} RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ if [[ "$RMW_IMPLEMENTATION" == "rmw_zenoh_cpp" ]]; then \ - mkdir -p /opt/ws_rmw_zenoh/src && \ - git clone https://github.com/ros2/rmw_zenoh.git /opt/ws_rmw_zenoh/src/rmw_zenoh && \ + mkdir -p /tmp/ws_rmw_zenoh/src && \ + git clone https://github.com/ros2/rmw_zenoh.git /tmp/ws_rmw_zenoh/src/ && \ rosdep init || true && \ rosdep update --rosdistro $ROS_DISTRO && \ apt-get update && \ - cd /opt/ws_rmw_zenoh && \ + cd /tmp/ws_rmw_zenoh && \ rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO && \ rm -rf /var/lib/apt/lists/* && \ source /opt/ros/${ROS_DISTRO}/setup.bash && \ - colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release && \ - echo "source /opt/ws_rmw_zenoh/install/setup.bash" >> ~/.bashrc ; \ + colcon build --install-base /opt/ros/${ROS_DISTRO}/ --merge-install --cmake-args -DCMAKE_BUILD_TYPE=Release && \ + rm -rf /tmp/ws_rmw_zenoh ; \ elif [[ "$ROS_VERSION" == "2" ]]; then \ apt-get update && \ RMW_PACKAGE=ros-$ROS_DISTRO-$(echo $RMW_IMPLEMENTATION | tr '_' '-') && \ @@ -257,7 +257,6 @@ FROM dev AS build # build ROS workspace RUN if [[ -x "$(command -v colcon)" ]]; then \ source /opt/ros/${ROS_DISTRO}/setup.bash && \ - [[ -f /opt/ws_rmw_zenoh/install/setup.bash ]] && source /opt/ws_rmw_zenoh/install/setup.bash ; \ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release ; \ elif [[ -x "$(command -v catkin)" ]]; then \ catkin config --install --extend /opt/ros/${ROS_DISTRO} && \ From 3864662220cbc0dd42775aac18764929b415142c Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Fri, 25 Oct 2024 23:07:39 +0200 Subject: [PATCH 7/8] Revert "build rmw_zenoh into `/opt/ros/`" This reverts commit cd936d14e01edced2fcec2773e7b2f8040c0bd2c. --- docker/Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ba53c61..37756ca 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -215,17 +215,17 @@ ARG RMW_IMPLEMENTATION="rmw_cyclonedds_cpp" ENV RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION} RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ if [[ "$RMW_IMPLEMENTATION" == "rmw_zenoh_cpp" ]]; then \ - mkdir -p /tmp/ws_rmw_zenoh/src && \ - git clone https://github.com/ros2/rmw_zenoh.git /tmp/ws_rmw_zenoh/src/ && \ + mkdir -p /opt/ws_rmw_zenoh/src && \ + git clone https://github.com/ros2/rmw_zenoh.git /opt/ws_rmw_zenoh/src/rmw_zenoh && \ rosdep init || true && \ rosdep update --rosdistro $ROS_DISTRO && \ apt-get update && \ - cd /tmp/ws_rmw_zenoh && \ + cd /opt/ws_rmw_zenoh && \ rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO && \ rm -rf /var/lib/apt/lists/* && \ source /opt/ros/${ROS_DISTRO}/setup.bash && \ - colcon build --install-base /opt/ros/${ROS_DISTRO}/ --merge-install --cmake-args -DCMAKE_BUILD_TYPE=Release && \ - rm -rf /tmp/ws_rmw_zenoh ; \ + colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release && \ + echo "source /opt/ws_rmw_zenoh/install/setup.bash" >> ~/.bashrc ; \ elif [[ "$ROS_VERSION" == "2" ]]; then \ apt-get update && \ RMW_PACKAGE=ros-$ROS_DISTRO-$(echo $RMW_IMPLEMENTATION | tr '_' '-') && \ @@ -257,6 +257,7 @@ FROM dev AS build # build ROS workspace RUN if [[ -x "$(command -v colcon)" ]]; then \ source /opt/ros/${ROS_DISTRO}/setup.bash && \ + [[ -f /opt/ws_rmw_zenoh/install/setup.bash ]] && source /opt/ws_rmw_zenoh/install/setup.bash ; \ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release ; \ elif [[ -x "$(command -v catkin)" ]]; then \ catkin config --install --extend /opt/ros/${ROS_DISTRO} && \ From c6d40870129b0340630a91bbf003cda14ac11c48 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Fri, 25 Oct 2024 23:09:21 +0200 Subject: [PATCH 8/8] add sourcing of rmw_zenoh into entrypoint --- docker/entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 5b30c74..e31252c 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -3,6 +3,7 @@ set -e # source ROS workspace source /opt/ros/$ROS_DISTRO/setup.bash +[[ -f /opt/ws_rmw_zenoh/install/setup.bash ]] && source /opt/ws_rmw_zenoh/install/setup.bash [[ -f $WORKSPACE/devel/setup.bash ]] && source $WORKSPACE/devel/setup.bash [[ -f $WORKSPACE/install/setup.bash ]] && source $WORKSPACE/install/setup.bash