diff --git a/dependencies.repos b/dependencies.repos new file mode 100644 index 0000000..12e6b41 --- /dev/null +++ b/dependencies.repos @@ -0,0 +1,13 @@ +repositories: + + # CPS Bot Mini Dependencies + + odrive_ros2_control: + type: git + url: https://github.com/bjoernellens1/odrive_ros2_control + version: humble-fw-v0.5.1 + + Lslidar_ROS2_driver: + 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 new file mode 100644 index 0000000..2bb5036 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,191 @@ +version: "3.9" + +services: + # Base image containing dependencies. + base: + image: ghcr.io/bjoernellens1/ros2_rmp/rmp:base + build: + context: . + dockerfile: docker/Dockerfile + args: + ROS_DISTRO: humble + target: base + x-bake: + platforms: + - linux/arm64 + - linux/amd64 + + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + # Needed to display graphical applications + privileged: true + environment: + # Allows graphical programs in the container. + - DISPLAY=${DISPLAY} + - QT_X11_NO_MITSHM=1 + - NVIDIA_DRIVER_CAPABILITIES=all + volumes: + # Allows graphical programs in the container. + - /tmp/.X11-unix:/tmp/.X11-unix:rw + - ${XAUTHORITY:-$HOME/.Xauthority}:/root/.Xauthority + + # Overlay image containing the project specific source code. + overlay: + extends: base + image: ghcr.io/bjoernellens1/ros2_rmp/rmp:overlay + build: + context: . + dockerfile: docker/Dockerfile + tags: + - ghcr.io/bjoernellens1/ros2_rmp/rmp:overlay + target: overlay + x-bake: + platforms: + - linux/arm64 + - linux/amd64 + volumes: + - .:/repo + + # Additional dependencies for GUI applications + guis: + extends: overlay + image: ghcr.io/bjoernellens1/ros2_rmp/rmp:guis + build: + context: . + dockerfile: docker/Dockerfile + tags: + - ghcr.io/bjoernellens1/ros2_rmp/rmp:guis + target: guis + x-bake: + platforms: + - linux/arm64 + - linux/amd64 + #entrypoint: /bin/bash + command: > + /bin/bash + + # Robot State Publisher + robot_state_publisher: + extends: overlay + command: > + ros2 launch cps_rmp220_support rsp.launch.py --ros-args -r __ns:=/probeNamespace + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + + # Controller + controller: + extends: overlay + command: > + ros2 launch cps_rmp220_support robot_controller.launch.py __ns:=/probeNamespace + devices: + - /dev/ttyUSB0:/dev/ttyUSB0 + - /dev/ttyACM0:/dev/ttyACM0 + - /dev/input/js0:/dev/input/js0 + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + # Needed to display graphical applications + privileged: true + # depends_on: + # - robot_state_publisher + + # teleop + teleop: + extends: overlay + command: > + ros2 launch cps_rmp220_support robot_joystick.launch.py + devices: + - /dev/ttyUSB0:/dev/ttyUSB0 + - /dev/ttyACM0:/dev/ttyACM0 + - /dev/input/js0:/dev/input/js0 + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + # Needed to display graphical applications + privileged: true + + # lidar + lidar: + extends: overlay + command: > + ros2 launch cps_rmp220_support robot_lidar.launch.py + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + depends_on: + - robot_state_publisher + + # mapping + mapping: + extends: overlay + command: > + ros2 launch cps_rmp220_support robot_mapping.launch.py + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + + # navigation + navigation: + extends: overlay + command: > + ros2 launch cps_rmp220_support robot_navigation.launch.py + map_subscribe_transient_local:=true + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + + # bash + bash: + extends: overlay + command: > + /bin/bash + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + + # rviz2 + rviz2: + extends: guis + # command: > + # ros2 launch cps_rmp220_support robot_rviz2.launch.py + command: > + rviz2 + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + # Needed to display graphical applications + privileged: true + environment: + # Allows graphical programs in the container. + - DISPLAY=${DISPLAY} + - QT_X11_NO_MITSHM=1 + - NVIDIA_DRIVER_CAPABILITIES=all + volumes: + # Allows graphical programs in the container. + - /tmp/.X11-unix:/tmp/.X11-unix:rw + - ${XAUTHORITY:-$HOME/.Xauthority}:/root/.Xauthority \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..72a5bb2 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,89 @@ +ARG ROS_DISTRO=humble +ARG UNDERLAY_WS=/bot_mini_ws +ARG OVERLAY_WS=/bot_mini_ws + +# This file should work for both amd64 and arm64 builds. + +######################################## +# Base Image for Bot Mini Control # +######################################## +FROM ros:${ROS_DISTRO} as base +ENV ROS_DISTRO=${ROS_DISTRO} +ENV UNDERLAY_WS=${UNDERLAY_WS} + +SHELL ["/bin/bash", "-c"] + +# Create Colcon workspace with external dependencies +RUN mkdir -p /${UNDERLAY_WS}/src +WORKDIR /${UNDERLAY_WS}/src +COPY dependencies.repos . + +#RUN vcs import < dependencies.repos +RUN vcs import < dependencies.repos; + +# Build the base Colcon workspace, installing dependencies first. +WORKDIR /${UNDERLAY_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 \ + && rm -rf /var/lib/apt/lists/* + +# Use Cyclone DDS as middleware +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \ + ros-${ROS_DISTRO}-xacro \ + && rm -rf /var/lib/apt/lists/* + +ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp + +########################################### +# Overlay Image for Bot Mini Control # +########################################### +FROM base AS overlay + +ENV OVERLAY_WS=${OVERLAY_WS} + +# 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} + +RUN source /${UNDERLAY_WS}/install/setup.bash \ + && colcon build --symlink-install \ + && apt-get update \ + && rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -y \ + && rm -rf /var/lib/apt/lists/* + +# 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" ] + +########################################### +# GUI Additions for Ros2 # +########################################### +FROM overlay AS guis + +# Install additional GUI tools +RUN source /${UNDERLAY_WS}/install/setup.bash \ + && colcon build --symlink-install \ + && apt-get update \ + && apt-get install -y --no-install-recommends ros-${ROS_DISTRO}-rviz2 \ + && rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -y \ + && rm -rf /var/lib/apt/lists/* + +# Set up the entrypoint +ENTRYPOINT [ "/entrypoint.sh" ] + +LABEL org.opencontainers.image.source=https://github.com/bjoernellens1/ros2_rmp \ No newline at end of file