From a72b6186be96e61b22ec7327125f419b4c496dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ellensohn?= Date: Fri, 28 Jul 2023 10:07:09 +0200 Subject: [PATCH] works for arm64 for now. --- docker-bake.hcl => bak/docker-bake.hcl | 0 dependencies.amd64.repos | 18 ++++++ dependencies.arm64.repos | 18 ++++++ dependencies.repos | 13 ----- docker-compose.yaml | 16 ++++-- docker/Dockerfile | 78 ++++++++++++++++++++++++++ docker/Dockerfile.amd64 | 2 +- docker/Dockerfile.arm64 | 5 +- overlay.repos | 10 ---- 9 files changed, 129 insertions(+), 31 deletions(-) rename docker-bake.hcl => bak/docker-bake.hcl (100%) create mode 100644 dependencies.amd64.repos create mode 100644 dependencies.arm64.repos delete mode 100644 dependencies.repos create mode 100644 docker/Dockerfile diff --git a/docker-bake.hcl b/bak/docker-bake.hcl similarity index 100% rename from docker-bake.hcl rename to bak/docker-bake.hcl diff --git a/dependencies.amd64.repos b/dependencies.amd64.repos new file mode 100644 index 0000000..3daafd6 --- /dev/null +++ b/dependencies.amd64.repos @@ -0,0 +1,18 @@ +repositories: + + # CPS RMP lite 220 Dependencies + + segwayrmp: + type: git + url: https://github.com/bjoernellens1/segwayrmp + version: x86 + + segway_msgs: + type: git + url: https://github.com/bjoernellens1/segway_msgs + version: main + + RPlidar_ROS2: + type: git + url: https://github.com/bjoernellens1/sllidar_ros2 + version: main \ No newline at end of file diff --git a/dependencies.arm64.repos b/dependencies.arm64.repos new file mode 100644 index 0000000..68fde00 --- /dev/null +++ b/dependencies.arm64.repos @@ -0,0 +1,18 @@ +repositories: + + # CPS RMP lite 220 Dependencies + + segwayrmp: + type: git + url: https://github.com/bjoernellens1/segwayrmp + version: humble-arm64 + + segway_msgs: + type: git + url: https://github.com/bjoernellens1/segway_msgs + version: main + + RPlidar_ROS2: + type: git + url: https://github.com/bjoernellens1/sllidar_ros2 + version: main \ No newline at end of file diff --git a/dependencies.repos b/dependencies.repos deleted file mode 100644 index 2e412e1..0000000 --- a/dependencies.repos +++ /dev/null @@ -1,13 +0,0 @@ -repositories: - - # CPS Bot Mini Dependencies - - odrive_ros2_control: - type: git - url: https://github.com/bjoernellens1/odrive_ros2_control.git - version: humble-fw-v0.5.1 - - Lslidar_ROS2: - type: git - url: https://github.com/bjoernellens1/Lslidar_ROS2_driver - version: N10_V1.0 \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 0e51ecc..e0ae3d3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,10 +5,14 @@ services: image: ghcr.io/bjoernellens1/ros2_rmp/rmp:base build: context: . - dockerfile: docker/Dockerfile.arm64 + dockerfile: docker/Dockerfile args: ROS_DISTRO: humble target: base + x-bake: + platforms: + - linux/arm64 + # - linux/amd64 # Interactive shell stdin_open: true tty: true @@ -27,16 +31,18 @@ services: - /tmp/.X11-unix:/tmp/.X11-unix:rw - ${XAUTHORITY:-$HOME/.Xauthority}:/root/.Xauthority - # Overlay image containing the example source code. + # Overlay image containing the project specific source code. overlay: extends: base image: ghcr.io/bjoernellens1/ros2_rmp/rmp:overlay - platform: linux/arm64 build: context: . - dockerfile: docker/Dockerfile.arm64 + dockerfile: docker/Dockerfile target: overlay - + x-bake: + platforms: + - linux/arm64 + # - linux/amd64 # Robot State Publisher robot_state_publisher: diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..42d233e --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,78 @@ +ARG ROS_DISTRO=humble +ARG UNDERLAY_WS=/rmp_ws +ARG TARGETPLATFORM + + +# This file should work for both amd64 and arm64 builds. Because segway did not release some source code we must copy some binaries for the specific architectures. +# That is why we must use some conditional statements to copy over the correct files during build process. +# Variable TARGETPLATFORM should be auomatically created during build process by docker. + +######################################## +# Base Image for Bot Mini Control # +######################################## +FROM ros:${ROS_DISTRO} as base +ENV ROS_DISTRO=${ROS_DISTRO} +SHELL ["/bin/bash", "-c"] + +# Create Colcon workspace with external dependencies +RUN mkdir -p /rmp_ws/src +WORKDIR /rmp_ws/src +COPY dependencies.arm64.repos . +COPY dependencies.amd64.repos . + +# Choose correct sources for architecture: +# Copy platform-specific files +# Use if condition to copy different files for different platforms +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + echo "Copying files for linux/amd64"; \ + mv dependencies.amd64.repos dependencies.repos; \ + else \ + echo "Copying files for linux/arm64"; \ + mv dependencies.arm64.repos dependencies.repos; \ + fi + +RUN vcs import < dependencies.repos + +# Build the base Colcon workspace, installing dependencies first. +WORKDIR /rmp_ws +RUN source /opt/ros/${ROS_DISTRO}/setup.bash \ + && apt-get update -y \ + && rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -y \ + && colcon build --symlink-install + +# Use Cyclone DDS as middleware +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-${ROS_DISTRO}-rmw-cyclonedds-cpp +ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp + +ENV UNDERLAY_WS=${UNDERLAY_WS} + +########################################### +# Overlay Image for Bot Mini Control # +########################################### +FROM base AS overlay + +# Create an overlay Colcon workspace +RUN mkdir -p /overlay_ws/src +WORKDIR /overlay_ws/src +COPY overlay.repos . +RUN vcs import < overlay.repos + +WORKDIR /overlay_ws +# COPY ./tb3_autonomy/ ./src/tb3_autonomy/ +# COPY ./tb3_worlds/ ./src/tb3_worlds/ +RUN source /rmp_ws/install/setup.bash \ + && colcon build --symlink-install \ + && rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -y + +# Set up the entrypoint +COPY ./docker/entrypoint.sh / +RUN chmod +x /entrypoint.sh + +COPY ./controller_startup.sh / +RUN chmod +x /controller_startup.sh + +COPY ./localization_startup.sh / +RUN chmod +x /localization_startup.sh + +ENTRYPOINT [ "/entrypoint.sh" ] \ No newline at end of file diff --git a/docker/Dockerfile.amd64 b/docker/Dockerfile.amd64 index bd7c315..be0b9e4 100644 --- a/docker/Dockerfile.amd64 +++ b/docker/Dockerfile.amd64 @@ -12,7 +12,7 @@ SHELL ["/bin/bash", "-c"] RUN mkdir -p /rmp_ws/src WORKDIR /rmp_ws/src COPY dependencies.repos . -RUN vcs import < dependencies.repos +RUN vcs import < dependencies.amd64.repos # Build the base Colcon workspace, installing dependencies first. WORKDIR /rmp_ws diff --git a/docker/Dockerfile.arm64 b/docker/Dockerfile.arm64 index 017f375..3a2db70 100644 --- a/docker/Dockerfile.arm64 +++ b/docker/Dockerfile.arm64 @@ -4,7 +4,8 @@ ARG UNDERLAY_WS=/rmp_ws ######################################## # Base Image for Bot Mini Control # ######################################## -FROM --platform=linux/arm64 ros:${ROS_DISTRO} as base +#FROM --platform=linux/arm64 ros:${ROS_DISTRO} as base +FROM ros:${ROS_DISTRO} as base ENV ROS_DISTRO=${ROS_DISTRO} SHELL ["/bin/bash", "-c"] @@ -12,7 +13,7 @@ SHELL ["/bin/bash", "-c"] RUN mkdir -p /rmp_ws/src WORKDIR /rmp_ws/src COPY dependencies.repos . -RUN vcs import < dependencies.repos +RUN vcs import < dependencies.arm64.repos # Build the base Colcon workspace, installing dependencies first. WORKDIR /rmp_ws diff --git a/overlay.repos b/overlay.repos index 6366047..acb2f94 100644 --- a/overlay.repos +++ b/overlay.repos @@ -13,14 +13,4 @@ repositories: cam_openCV: type: git url: https://github.com/bjoernellens1/ros2_cam_openCV.git - version: main - - segwayrmp: - type: git - url: https://github.com/bjoernellens1/segwayrmp.git - version: humble-arm64 - - segway_msgs: - type: git - url: https://github.com/bjoernellens1/segway_msgs.git version: main \ No newline at end of file