forked from dusty-nv/jetson-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.ros.galactic
195 lines (168 loc) · 5.73 KB
/
Dockerfile.ros.galactic
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
#
# this dockerfile roughly follows the 'Install ROS From Source' procedures from:
# https://docs.ros.org/en/galactic/Installation/Ubuntu-Development-Setup.html
#
ARG BASE_IMAGE=nvcr.io/nvidia/l4t-base:r32.5.0
FROM ${BASE_IMAGE}
ARG ROS_PKG=ros_base
ENV ROS_DISTRO=galactic
ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}
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 \
libgazebo9-dev \
gazebo9 \
gazebo9-common \
gazebo9-plugin-base \
&& 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/5v89u6g5rb62fpz4lh0rz531ajo2t5ef.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 && \
cp -r /usr/include/opencv4 /usr/local/include/opencv4 && \
cp -r /usr/lib/python3.6/dist-packages/cv2 /usr/local/lib/python3.6/dist-packages/cv2
#
# 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 && \
# 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/pluginlib_enable_plugin_testing/install/test_pluginlib__test_pluginlib/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 /