Skip to content

Commit

Permalink
adding ros2 iron CI / docker, fixing #1103
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Aug 5, 2023
1 parent e2f0371 commit a94a4c9
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/cmake-ros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
ros_distribution: [ noetic, humble, rolling]
ros_distribution: [ noetic, humble, iron, rolling]
include:
- ros_distribution: 'noetic'
os: ubuntu-20.04
- ros_distribution: 'humble'
os: ubuntu-22.04
- ros_distribution: 'iron'
os: ubuntu-22.04
- ros_distribution: 'rolling'
os: ubuntu-22.04

Expand Down
37 changes: 37 additions & 0 deletions docker/jammy-iron/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Image: introlab3it/rtabmap:jammy-iron

FROM introlab3it/rtabmap:jammy-iron-deps

# June 19 2023: moved opengv here so that jammy-deps can be built on my computer. Not sure why but on my machine opengv arm64 fails, but not on CI.
#commit Aug 6 2020
RUN apt-get update && apt install -y wget && \
apt-get clean && rm -rf /var/lib/apt/lists/
RUN git clone https://github.com/laurentkneip/opengv.git && \
cd opengv && \
git checkout 91f4b19c73450833a40e463ad3648aae80b3a7f3 && \
wget https://gist.githubusercontent.com/matlabbe/a412cf7c4627253874f81a00745a7fbb/raw/accc3acf465d1ffd0304a46b17741f62d4d354ef/opengv_disable_march_native.patch && \
git apply opengv_disable_march_native.patch && \
mkdir build && \
cd build && \
cmake -DCMAKE_BUILD_TYPE=Release .. && \
make -j$(nproc) && \
make install && \
cd && \
rm -r opengv

# Will be used to read/store databases on host
RUN mkdir -p /root/Documents/RTAB-Map && chmod 777 /root/Documents/RTAB-Map

# Copy current source code
COPY . /root/rtabmap

# Build RTAB-Map project
RUN source /ros_entrypoint.sh && \
cd rtabmap/build && \
cmake -DWITH_OPENGV=ON .. && \
make -j$(nproc) && \
make install && \
cd ../.. && \
rm -rf rtabmap && \
ldconfig

88 changes: 88 additions & 0 deletions docker/jammy-iron/deps/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Image: introlab3it/rtabmap:jammy-iron-deps

FROM ubuntu:22.04

# Install ROS2
RUN apt update && \
apt install software-properties-common -y && \
add-apt-repository universe && \
apt update && \
apt install curl -y && \
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null && \
apt-get clean && rm -rf /var/lib/apt/lists/

ENV DEBIAN_FRONTEND=noninteractive

# Install build dependencies
RUN apt-get update && \
apt upgrade -y && \
apt-get install -y git ros-iron-ros-base ros-dev-tools ros-iron-rtabmap-ros && \
apt-get remove -y ros-iron-rtabmap* && \
apt-get clean && rm -rf /var/lib/apt/lists/

WORKDIR /root/

# PDAL
RUN apt-get update && apt-get install -y libpdal-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/

# RealSense2
RUN apt-get update && apt-get install -y ros-iron-librealsense2 && \
apt-get clean && rm -rf /var/lib/apt/lists/

ARG TARGETPLATFORM
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
RUN echo "I am building for $TARGETPLATFORM"

# libfreenect2
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then echo "Installing libfreenect2..." && \
apt-get update && apt-get install -y mesa-utils xserver-xorg-video-all libusb-1.0-0-dev libturbojpeg0-dev libglfw3-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/ && \
git clone https://github.com/OpenKinect/libfreenect2 && \
cd libfreenect2 && \
mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc) && \
make install && \
cd && \
rm -r libfreenect2; fi

# zed open capture
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then echo "Installing zed-open-capture..." && \
apt-get update && apt install -y libusb-1.0-0-dev libhidapi-libusb0 libhidapi-dev wget && \
apt-get clean && rm -rf /var/lib/apt/lists/ && \
git clone https://github.com/stereolabs/zed-open-capture.git && \
cd zed-open-capture && \
mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc) && \
make install && \
cd && \
rm -r zed-open-capture; fi

RUN git clone --branch 4.5.4 https://github.com/opencv/opencv.git && \
git clone --branch 4.5.4 https://github.com/opencv/opencv_contrib.git && \
cd opencv && \
mkdir build && \
cd build && \
cmake -DBUILD_opencv_python3=OFF -DBUILD_opencv_python_bindings_generator=OFF -DBUILD_opencv_python_tests=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DOPENCV_ENABLE_NONFREE=ON -DOPENCV_EXTRA_MODULES_PATH=/root/opencv_contrib/modules .. && \
make -j$(nproc) && \
make install && \
cd ../.. && \
rm -rf opencv opencv_contrib

RUN rm /bin/sh && ln -s /bin/bash /bin/sh

COPY ./docker/jammy/deps/ros_entrypoint.sh /ros_entrypoint.sh
RUN chmod +x /ros_entrypoint.sh
ENTRYPOINT [ "/ros_entrypoint.sh" ]

# ros2 seems not sourcing by default its multi-arch folders
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ros/iron/lib/x86_64-linux-gnu:/opt/ros/iron/lib/aarch64-linux-gnu

# for jetson (https://github.com/introlab/rtabmap/issues/776)
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/aarch64-linux-gnu/tegra

6 changes: 6 additions & 0 deletions docker/jammy-iron/deps/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

# setup ros2 environment
source "/opt/ros/iron/setup.bash" --
exec "$@"
2 changes: 0 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

<build_depend>proj</build_depend>
<depend>cv_bridge</depend>
<depend>libfreenect-dev</depend>
<depend>libg2o</depend>
<depend>libopenni-dev</depend>
<!-- <depend>libopenni2-dev</depend> --> <!-- not available on Jessie -->
<depend>libpcl-all-dev</depend> <!-- include libvtk-qt -->
<depend>libpointmatcher</depend> <!-- optional but recommended if lidar is used, also not available on 32 bits system, but rtabmap can be built without it -->
Expand Down

0 comments on commit a94a4c9

Please sign in to comment.