-
Notifications
You must be signed in to change notification settings - Fork 183
/
Dockerfile
168 lines (139 loc) · 5.2 KB
/
Dockerfile
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
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# Build this Dockerfile by running the following commands:
#
# $ cd /path/to/your/jetbot_ros
# $ docker/build.sh
#
# Also you should set your docker default-runtime to nvidia:
# https://github.com/dusty-nv/jetson-containers#docker-default-runtime
#
ARG BASE_IMAGE=dustynv/ros:foxy-pytorch-l4t-r32.5.0
FROM ${BASE_IMAGE}
SHELL ["/bin/bash", "-c"]
ENV SHELL /bin/bash
ENV DEBIAN_FRONTEND=noninteractive
ARG MAKEFLAGS=-j$(nproc)
ENV LANG=en_US.UTF-8
ENV PYTHONIOENCODING=utf-8
RUN locale-gen en_US en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
WORKDIR /tmp
#
# install gazebo & utilities
#
RUN apt-get update && \
apt-get install -y --no-install-recommends \
nano \
xterm \
lxterminal \
blender \
libgazebo9-dev \
gazebo9 \
gazebo9-common \
gazebo9-plugin-base \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
RUN git clone https://github.com/dusty-nv/py3gazebo /opt/py3gazebo && \
pip3 install protobuf>=2.6 --verbose && \
pip3 install trollius --verbose && \
pip3 install pynput --verbose
ENV PYTHONPATH=/opt/py3gazebo
#
# Gazebo plugins for ROS
#
RUN source ${ROS_ROOT}/install/setup.bash && \
export ROS_PACKAGE_PATH=${AMENT_PREFIX_PATH} && \
cd ${ROS_ROOT} && \
mkdir -p src/gazebo && \
rosinstall_generator --deps --exclude RPP --rosdistro ${ROS_DISTRO} \
gazebo_ros_pkgs \
> ros2.${ROS_DISTRO}.gazebo.rosinstall && \
cat ros2.${ROS_DISTRO}.gazebo.rosinstall && \
vcs import src/gazebo < ros2.${ROS_DISTRO}.gazebo.rosinstall && \
apt-get update && \
rosdep install -y \
--ignore-src \
--from-paths src/gazebo \
--rosdistro ${ROS_DISTRO} \
--skip-keys "gazebo11 libgazebo11-dev libopencv-dev libopencv-contrib-dev libopencv-imgproc-dev python-opencv python3-opencv" && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean && \
colcon build --merge-install --base-paths src/gazebo \
&& rm -rf ${ROS_ROOT}/src \
&& rm -rf ${ROS_ROOT}/logs \
&& rm -rf ${ROS_ROOT}/build
#
# JetBot hw controllers
#
RUN pip3 install Adafruit-MotorHAT Adafruit-SSD1306 pyserial sparkfun-qwiic --verbose
#
# environment setup
#
ENV WORKSPACE_ROOT=/workspace
ENV JETBOT_ROOT=${WORKSPACE_ROOT}/src/jetbot_ros
ARG ROS_ENVIRONMENT=${ROS_ROOT}/install/setup.bash
ENV GAZEBO_MODEL_PATH=/usr/share/gazebo-9/models:/root/.gazebo/models:${JETBOT_ROOT}/gazebo/models
ENV GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:${JETBOT_ROOT}/gazebo/plugins/build/:/usr/local/lib/
ENV GAZEBO_MASTER_URI=http://localhost:11346
# setup workspace
WORKDIR ${WORKSPACE_ROOT}
RUN mkdir -p ${WORKSPACE_ROOT}/src
COPY scripts/setup_workspace.sh ${WORKSPACE_ROOT}/setup_workspace.sh
ENV PYTHONPATH="${JETBOT_ROOT}:${PYTHONPATH}"
#
# ros_deep_learning package
#
RUN source ${ROS_ENVIRONMENT} && \
cd ${WORKSPACE_ROOT}/src && \
git clone https://github.com/dusty-nv/ros_deep_learning && \
cd ../ && \
colcon build --symlink-install --event-handlers console_direct+
#
# build project
#
COPY jetbot_ros ${JETBOT_ROOT}/jetbot_ros
COPY launch ${JETBOT_ROOT}/launch
COPY gazebo ${JETBOT_ROOT}/gazebo
COPY resource ${JETBOT_ROOT}/resource
COPY package.xml ${JETBOT_ROOT}
COPY setup.py ${JETBOT_ROOT}
COPY setup.cfg ${JETBOT_ROOT}
RUN cd ${JETBOT_ROOT}/gazebo/plugins/ && \
mkdir build && \
cd build && \
cmake ../ && \
make -j$(nproc) && \
make install
RUN source ${ROS_ENVIRONMENT} && \
cd ${WORKSPACE_ROOT} && \
colcon build --symlink-install --event-handlers console_direct+
#
# setup entrypoint
#
COPY scripts/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 && \
echo 'source ${WORKSPACE_ROOT}/install/local_setup.bash' >> /root/.bashrc
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]