-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile.vins.gpu
246 lines (210 loc) · 8.48 KB
/
Dockerfile.vins.gpu
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#
# this dockerfile roughly follows the 'Ubuntu install of ROS Melodic' from:
# http://wiki.ros.org/melodic/Installation/Ubuntu
#
ARG BASE_IMAGE=Dockerfile.ros.melodic
FROM ${BASE_IMAGE}
ARG ROS_PKG=ros_base
ENV ROS_DISTRO=melodic
ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /
# Create src folder inside the HOME folder
# This is for installing non-ROS packages from source
RUN cd $HOME && mkdir src
RUN apt update && apt-get install -y --no-install-recommends \
software-properties-common \
apt-utils \
gedit \
net-tools \
iputils-ping \
nano \
bash-completion \
python3-pip \
python-catkin-tools \
libcurl4-openssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Eigen 3.3.7
# Remove pre-built Eigen
#RUN apt-get remove libeigen3-dev
RUN apt update && apt install -y unzip
RUN cd $HOME/src/ &&\
wget -O eigen.zip https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip &&\
unzip eigen.zip &&\
mkdir eigen-build && cd eigen-build &&\
cmake ../eigen-3.3.7/ && make install
#pkg-config --modversion eigen3 # Check Eigen Version
# Add MAVLink and mavros
RUN apt-get update && apt-get -y --quiet --no-install-recommends install \
geographiclib-tools \
libgeographic-dev \
libyaml-cpp-dev \
python-pip \
python-tk \
ros-melodic-mav-msgs \
ros-melodic-mavlink \
ros-melodic-mavros \
ros-melodic-mavros-extras \
&& geographiclib-get-geoids egm96-5 \
&& apt-get -y autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/*
# Create ROS catkin_ws to host ROS packages
RUN mkdir -p $HOME/catkin_ws/src \
&& cd $HOME/catkin_ws \
&& catkin init \
&& catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release \
&& catkin config --merge-devel \
&& catkin config --extend /opt/ros/$ROS_DISTRO \
&& catkin build
# Ceres solver
RUN apt update && apt install -y libgoogle-glog-dev libatlas-base-dev libsuitesparse-dev
RUN cd $HOME/src/ &&\
wget http://ceres-solver.org/ceres-solver-1.14.0.tar.gz &&\
tar zxf ceres-solver-1.14.0.tar.gz &&\
mkdir ceres-bin &&\
mkdir solver && cd ceres-bin &&\
cmake ../ceres-solver-1.14.0 -DEXPORT_BUILD_DIR=ON &&\
make -j3 &&\
make install &&\
bin/simple_bundle_adjuster ../ceres-solver-1.14.0/data/problem-16-22106-pre.txt
# remove prebuilt opencv
RUN apt-get purge libopencv* python-opencv
RUN apt-get update &&\
apt-get install -y build-essential pkg-config
RUN apt-get install -y cmake libavcodec-dev libavformat-dev libavutil-dev \
libglew-dev libgtk2.0-dev libgtk-3-dev libjpeg-dev libpng-dev libpostproc-dev \
libswscale-dev libtbb-dev libtiff5-dev libv4l-dev libxvidcore-dev \
libx264-dev qt5-default zlib1g-dev libgl1 libglvnd-dev pkg-config \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev mesa-utils
RUN apt-get install -y python2.7-dev python3-dev python-numpy python3-numpy
#
# setup environment
#
ENV CUDA_HOME="/usr/local/cuda"
ENV PATH="/usr/local/cuda/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"
#
# Download & install OpenCV - https://github.com/mdegans/nano_build_opencv/blob/master/build_opencv.sh
#
# OpenCV looks for the cuDNN version in cudnn_version.h, but it's been renamed to cudnn_version_v8.h
RUN ln -s /usr/include/aarch64-linux-gnu/cudnn_version_v8.h /usr/include/aarch64-linux-gnu/cudnn_version.h
ARG OPENCV_VERSION="3.4.1"
RUN cd $HOME/src/ &&\
git clone --depth 1 --branch ${OPENCV_VERSION} https://github.com/opencv/opencv.git &&\
cd opencv && mkdir build && cd build &&\
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D CPACK_BINARY_DEB=ON \
-D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \
-D WITH_EIGEN=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_opencv_java=OFF \
-D WITH_CUDA=ON \
-D CUDA_ARCH_BIN=5.3,6.2,7.2 \
-D CUDA_ARCH_PTX="" \
-D ENABLE_FAST_MATH=ON \
-D CUDA_FAST_MATH=ON \
-D WITH_CUBLAS=ON \
-D WITH_LIBV4L=ON \
-D WITH_GSTREAMER=ON \
-D WITH_GSTREAMER_0_10=OFF \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D WITH_IPP=OFF \
-D CUDA_NVCC_FLAGS="--expt-relaxed-constexpr" \
-D WITH_TBB=ON \
../
# references to related OpenCV compilation problems:
# Ref1: https://forums.developer.nvidia.com/t/opencv-with-gl-support-at-xavier/76752
# Ref2: https://forums.developer.nvidia.com/t/building-opencv-with-opengl-support/49741/17
# WARNING: The following COPY won't work as /usr/local/cuda/ is actually a mounted volume from the host!
# You will need to modify /usr/local/cuda/include/cuda_gl_interop.h on the HOST system
# COPY ./packages/cuda_gl_interop.h /usr/local/cuda/include/
# COPY ./packages/cuda_gl_interop.h /usr/local/cuda-10.2/include/
RUN cd /usr/lib/aarch64-linux-gnu/ &&\
ln -sf libGL.so.1.0.0 libGL.so
RUN cd $HOME/src/opencv/build/ && make -j$(nproc)
RUN cd $HOME/src/opencv/build/ && make install
RUN cd $HOME/src/opencv/build/ && make package
# Make OpenCV debian pkgs so it can be easily installed later
RUN cd $HOME/src/opencv/build/ && tar -czvf OpenCV-${OPENCV_VERSION}-aarch64.tar.gz *.deb
RUN cp $HOME/src/opencv/build/OpenCV-${OPENCV_VERSION}-aarch64.tar.gz $HOME/src/
#Can save ~ 10GB !
RUN rm -rf $HOME/src/opencv/build
# Check opencv verison
RUN pkg-config --modversion opencv
#
# Install cv_bridge from source
#
RUN cd $HOME/catkin_ws/src &&\
git clone --branch $ROS_DISTRO https://github.com/ros-perception/vision_opencv
# Finally build cv_bridge
RUN cd $HOME/catkin_ws/ && catkin build
#
# VINS-FUSION-GPU
#
# Dependecies
RUN apt update && apt install -y ros-melodic-tf \
ros-melodic-image-transport \
ros-melodic-rviz
RUN cd $HOME/catkin_ws/src &&\
git clone https://github.com/pjrambo/VINS-Fusion-gpu
COPY ./patches/vins-fusion/loop_fusion/CMakeLists.txt /root/catkin_ws/src/VINS-Fusion-gpu/loop_fusion/
COPY ./patches/vins-fusion/vins_estimator/CMakeLists.txt /root/catkin_ws/src/VINS-Fusion-gpu/vins_estimator/
# Build
RUN cd $HOME/catkin_ws/ &&\
bash devel/setup.bash &&\
catkin build camera_models
RUN cd $HOME/catkin_ws/ &&\
bash devel/setup.bash &&\
catkin build
#
# Realsense SDK
#
RUN apt install -y rsync
# dependencies
RUN apt-get install -y libssl-dev freeglut3-dev libusb-1.0-0-dev pkg-config libgtk-3-dev unzip
# From source
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
RUN add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u
RUN cd $HOME/src &&\
wget https://github.com/IntelRealSense/librealsense/archive/v2.48.0.tar.gz &&\
tar -xvf v2.48.0.tar.gz
RUN cd $HOME/src/librealsense-2.48.0/config &&\
cp 99-realsense-libusb.rules /etc/udev/rules.d/
RUN cd $HOME/src/librealsense-2.48.0/ && mkdir build && cd build &&\
cmake ../ \
-DFORCE_RSUSB_BACKEND=true \
-DCMAKE_BUILD_TYPE=release \
-DBUILD_EXAMPLES=true \
-DBUILD_WITH_CUDA=true \
-DBUILD_GRAPHICAL_EXAMPLES=true &&\
make -j$(nproc) && make clean && make install
# From binaries
# RUN cd $HOME/src/ &&\
# git clone https://github.com/jetsonhacks/installRealSenseSDK.git &&\
# cd installRealSenseSDK &&\
# ./installLibrealsense.sh
# realsense-ros package
RUN cd $HOME/src/ &&\
git clone https://github.com/mzahana/installRealSenseROS.git &&\
cd installRealSenseROS &&\
./installRealSenseROS.sh
# NOTE: You will need to run the 'installRealSenseROS/disableAutosuspend.sh' script on the HOST; NOT inside the container
# A convenience package that has some launch files to run all VINS nodes at once instead of doing it on multiple terminals
# Also has some config YAML files for D435i depth camera
RUN cd $HOME/catkin_ws/src/ &&\
git clone https://github.com/mzahana/jetson_vins_fusion_scripts.git &&\
cd $HOME/catkin_ws/ && catkin build
RUN echo "source /etc/profile.d/bash_completion.sh" >> /root/.bashrc
# ROS setup.bash scripts
RUN echo 'source /opt/ros/${ROS_DISTRO}/setup.bash' >> /root/.bashrc
RUN echo 'source /root/catkin_ws/devel/setup.bash' >> /root/.bashrc
# setup entrypoint
COPY ./scripts/ros_entrypoint.sh /ros_entrypoint.sh
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]
WORKDIR /root