forked from dusty-nv/jetson-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.ros.foxy
233 lines (200 loc) · 7.04 KB
/
Dockerfile.ros.foxy
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
#
# this dockerfile roughly follows the 'Install ROS From Source' procedures from:
# https://index.ros.org/doc/ros2/Installation/Foxy/Linux-Development-Setup/
#
ARG BASE_IMAGE=nvcr.io/nvidia/l4t-base:r32.5.0
FROM ${BASE_IMAGE}
ARG ROS_PKG=ros_base
ENV ROS_DISTRO=foxy
ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}
ENV ROS_PYTHON_VERSION=3
ENV DEBIAN_FRONTEND=noninteractive
ENV SHELL /bin/bash
SHELL ["/bin/bash", "-c"]
WORKDIR /tmp
# change the locale from POSIX to UTF-8
RUN locale-gen en_US en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV PYTHONIOENCODING=utf-8
#
# add the ROS deb repo to the apt sources list
#
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
wget \
gnupg2 \
lsb-release \
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
#
# install development packages
#
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
libbullet-dev \
libpython3-dev \
python3-colcon-common-extensions \
python3-flake8 \
python3-pip \
python3-numpy \
python3-pytest-cov \
python3-rosdep \
python3-setuptools \
python3-vcstool \
python3-rosinstall-generator \
libasio-dev \
libtinyxml2-dev \
libcunit1-dev \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# install some pip packages needed for testing
RUN python3 -m pip install -U \
argcomplete \
flake8-blind-except \
flake8-builtins \
flake8-class-newline \
flake8-comprehensions \
flake8-deprecated \
flake8-docstrings \
flake8-import-order \
flake8-quotes \
pytest-repeat \
pytest-rerunfailures \
pytest
#
# install OpenCV (with CUDA)
#
ARG OPENCV_URL=https://nvidia.box.com/shared/static/2hssa5g3v28ozvo3tc3qwxmn78yerca9.gz
ARG OPENCV_DEB=OpenCV-4.5.0-aarch64.tar.gz
RUN apt-get purge -y '*opencv*' || echo "previous OpenCV installation not found" && \
mkdir opencv && \
cd opencv && \
wget --quiet --show-progress --progress=bar:force:noscroll --no-check-certificate ${OPENCV_URL} -O ${OPENCV_DEB} && \
tar -xzvf ${OPENCV_DEB} && \
dpkg -i --force-depends *.deb && \
apt-get update && \
apt-get install -y -f --no-install-recommends && \
dpkg -i *.deb && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean && \
cd ../ && \
rm -rf opencv && \
PYTHON3_VERSION=`python3 -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}".format(*version))'` && \
cp -r /usr/include/opencv4 /usr/local/include/opencv4 && \
cp -r /usr/lib/python${PYTHON3_VERSION}/dist-packages/cv2 /usr/local/lib/python${PYTHON3_VERSION}/dist-packages/cv2
#
# upgrade cmake - https://stackoverflow.com/a/56690743
# this is needed to build some of the ROS2 packages
#
RUN apt-get update && \
apt-get install -y --no-install-recommends \
software-properties-common \
apt-transport-https \
ca-certificates \
gnupg \
lsb-release \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
RUN wget -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc | apt-key add - && \
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" && \
apt-get update && \
apt-get install -y --no-install-recommends --only-upgrade \
cmake \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
RUN cmake --version
#
# compile yaml-cpp-0.6, which some ROS packages may use (but is not in the 18.04 apt repo)
#
RUN git clone --branch yaml-cpp-0.6.0 https://github.com/jbeder/yaml-cpp yaml-cpp-0.6 && \
cd yaml-cpp-0.6 && \
mkdir build && \
cd build && \
cmake -DBUILD_SHARED_LIBS=ON .. && \
make -j$(nproc) && \
cp libyaml-cpp.so.0.6.0 /usr/lib/aarch64-linux-gnu/ && \
ln -s /usr/lib/aarch64-linux-gnu/libyaml-cpp.so.0.6.0 /usr/lib/aarch64-linux-gnu/libyaml-cpp.so.0.6
#
# download/build ROS from source
#
RUN mkdir -p ${ROS_ROOT}/src && \
cd ${ROS_ROOT} && \
# https://answers.ros.org/question/325245/minimal-ros2-installation/?answer=325249#post-id-325249
rosinstall_generator --deps --rosdistro ${ROS_DISTRO} ${ROS_PKG} \
launch_xml \
launch_yaml \
launch_testing \
launch_testing_ament_cmake \
demo_nodes_cpp \
demo_nodes_py \
example_interfaces \
camera_calibration_parsers \
camera_info_manager \
cv_bridge \
v4l2_camera \
vision_opencv \
vision_msgs \
image_geometry \
image_pipeline \
image_transport \
compressed_image_transport \
compressed_depth_image_transport \
> ros2.${ROS_DISTRO}.${ROS_PKG}.rosinstall && \
cat ros2.${ROS_DISTRO}.${ROS_PKG}.rosinstall && \
vcs import src < ros2.${ROS_DISTRO}.${ROS_PKG}.rosinstall && \
# install dependencies using rosdep
apt-get update && \
cd ${ROS_ROOT} && \
rosdep init && \
rosdep update && \
rosdep install -y \
--ignore-src \
--from-paths src \
--rosdistro ${ROS_DISTRO} \
--skip-keys "libopencv-dev libopencv-contrib-dev libopencv-imgproc-dev python-opencv python3-opencv" && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean && \
# build it!
colcon build \
--merge-install \
--cmake-args -DCMAKE_BUILD_TYPE=Release && \
# remove build files
rm -rf ${ROS_ROOT}/src && \
rm -rf ${ROS_ROOT}/logs && \
rm -rf ${ROS_ROOT}/build && \
rm ${ROS_ROOT}/*.rosinstall
#
# fix broken package.xml in test_pluginlib that crops up if/when rosdep is run again
#
# Error(s) in package '/opt/ros/foxy/build/pluginlib/prefix/share/test_pluginlib/package.xml':
# Package 'test_pluginlib' must declare at least one maintainer
# The package node must contain at least one "license" tag
#
#RUN TEST_PLUGINLIB_PACKAGE="${ROS_ROOT}/build/pluginlib/prefix/share/test_pluginlib/package.xml" && \
# sed -i '/<\/description>/a <license>BSD<\/license>' $TEST_PLUGINLIB_PACKAGE && \
# sed -i '/<\/description>/a <maintainer email="[email protected]">Michael Carroll<\/maintainer>' $TEST_PLUGINLIB_PACKAGE && \
# cat $TEST_PLUGINLIB_PACKAGE
#
# Set the default DDS middleware to cyclonedds
# https://github.com/ros2/rclcpp/issues/1335
#
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
#
# setup entrypoint
#
COPY ./packages/ros_entrypoint.sh /ros_entrypoint.sh
RUN sed -i \
's/ros_env_setup="\/opt\/ros\/$ROS_DISTRO\/setup.bash"/ros_env_setup="${ROS_ROOT}\/install\/setup.bash"/g' \
/ros_entrypoint.sh && \
cat /ros_entrypoint.sh
RUN echo 'source ${ROS_ROOT}/install/setup.bash' >> /root/.bashrc
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]
WORKDIR /