forked from suchetanrs/ORB-SLAM3-ROS2-Docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
144 lines (117 loc) · 5.77 KB
/
Dockerfile
File metadata and controls
144 lines (117 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Image taken from https://github.com/turlucode/ros-docker-gui
# ===============================================================================
# Default to cpu build. Cuda kernels are built only if `--target nvidia` is specified.
# ===============================================================================
ARG TARGET=cpu
# ===============================================================================
# Base stage (Common dependencies for CPU and NVIDIA GPU builds)
# ===============================================================================
FROM osrf/ros:humble-desktop-full-jammy AS base
ARG USE_CI
RUN apt-get update
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y gnupg2 curl lsb-core vim wget python3-pip libpng16-16 libjpeg-turbo8 libtiff5
RUN apt-get install -y \
# Base tools
cmake \
build-essential \
git \
unzip \
pkg-config \
python3-dev \
# OpenCV dependencies
python3-numpy \
# Pangolin dependencies
libgl1-mesa-dev \
libglew-dev \
libpython3-dev \
libeigen3-dev \
apt-transport-https \
ca-certificates\
software-properties-common
RUN apt update
# Build OpenCV
RUN apt-get install -y python3-dev python3-numpy python2-dev
RUN apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
RUN apt-get install -y libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev
RUN apt-get install -y libgtk-3-dev
RUN cd /tmp && git clone https://github.com/opencv/opencv.git && \
cd opencv && \
git checkout 4.4.0 && mkdir build && cd build && \
cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_EXAMPLES=OFF -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j8 && make install && \
cd / && rm -rf /tmp/opencv
# Build vscode (can be removed later for deployment)
COPY ./container_root/shell_scripts/vscode_install.sh /root/
RUN cd /root/ && sudo chmod +x * && ./vscode_install.sh && rm -rf vscode_install.sh
RUN apt-get update && apt-get install ros-humble-pcl-ros tmux -y
RUN apt-get install ros-humble-nav2-common x11-apps nano -y
RUN apt-get install -y gdb gdbserver ros-humble-rmw-cyclonedds-cpp ros-humble-cv-bridge ros-humble-image-transport ros-humble-image-common ros-humble-vision-opencv
# ===============================================================================
# NVIDIA GPU image stage (built if `--target nvidia_gpu` is specified)
# ===============================================================================
FROM nvidia/opengl:1.0-glvnd-devel-ubuntu18.04 AS glvnd
FROM base AS nvidia_gpu
RUN apt-get update && apt-get install -y --no-install-recommends \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
libgles2
COPY --from=glvnd /usr/share/glvnd/egl_vendor.d/10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:-all}
# Basic deps for adding NVIDIA apt repo
RUN apt-get update && apt-get install -y --no-install-recommends \
wget ca-certificates gnupg
# Add NVIDIA CUDA repo keyring (Ubuntu 22.04 repo)
RUN wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb \
&& dpkg -i cuda-keyring_1.1-1_all.deb && rm -rf cuda-keyring_1.1-1_all.deb
# Install CUDA Toolkit 12.2 (no driver)
RUN apt-get update && apt-get install -y --no-install-recommends \
cuda-toolkit-12-2
# make CUDA visible on PATH
ENV PATH=/usr/local/cuda-12.2/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda-12.2/lib64:${LD_LIBRARY_PATH}
ENV CUDA_CACHE_PATH=/tmp/cuda_cache
COPY FastTrack/Thirdparty/Pangolin /tmp/Pangolin
RUN cd /tmp/Pangolin && mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-std=c++14 -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j8 && \
make install && \
cd / && rm -rf /tmp/Pangolin && ldconfig
COPY FastTrack /home/orb/ORB_SLAM3
COPY orb_slam3_ros2_wrapper /root/colcon_ws/src/orb_slam3_ros2_wrapper
COPY orb_slam3_map_generator /root/colcon_ws/src/orb_slam3_map_generator
COPY slam_msgs /root/colcon_ws/src/slam_msgs
# Build ORB-SLAM3 with its dependencies.
RUN if [ "$USE_CI" = "true" ]; then \
. /opt/ros/humble/setup.sh && cd /home/orb/ORB_SLAM3 && mkdir -p build && ./build.sh && \
. /opt/ros/humble/setup.sh && cd /root/colcon_ws/ && colcon build --symlink-install; \
fi
RUN rm -rf /home/orb/ORB_SLAM3 /root/colcon_ws
# ===============================================================================
# CPU image stage (Default) (ignored if `--target nvidia_gpu` is specified)
# ===============================================================================
FROM base AS cpu
# Build Pangolin
RUN cd /tmp && git clone https://github.com/stevenlovegrove/Pangolin && \
cd Pangolin && git checkout v0.9.1 && mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-std=c++14 -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j8 && \
make install && \
cd / && rm -rf /tmp/Pangolin && ldconfig
COPY ORB_SLAM3 /home/orb/ORB_SLAM3
COPY orb_slam3_ros2_wrapper /root/colcon_ws/src/orb_slam3_ros2_wrapper
COPY orb_slam3_map_generator /root/colcon_ws/src/orb_slam3_map_generator
COPY slam_msgs /root/colcon_ws/src/slam_msgs
# Build ORB-SLAM3 with its dependencies.
RUN if [ "$USE_CI" = "true" ]; then \
. /opt/ros/humble/setup.sh && cd /home/orb/ORB_SLAM3 && mkdir -p build && ./build.sh && \
. /opt/ros/humble/setup.sh && cd /root/colcon_ws/ && colcon build --symlink-install; \
fi
RUN rm -rf /home/orb/ORB_SLAM3 /root/colcon_ws
# ===============================================================================
# Final stage (Either CPU or NVIDIA GPU based on `--target` flag)
# ===============================================================================
FROM ${TARGET} AS final