1
- ARG ROS_DISTRO=iron
2
- ARG USERNAME=blue
3
- ARG USER_GID=1000
4
- ARG USER_UID=1000
1
+ ARG ROS_DISTRO=rolling
2
+ FROM ros:$ROS_DISTRO-ros-base AS ci
5
3
6
4
FROM ros:$ROS_DISTRO-ros-base AS ci
7
5
ARG USERNAME
@@ -25,6 +23,7 @@ RUN apt-get -q update \
25
23
clang-tools \
26
24
python3-pip \
27
25
python3-dev \
26
+ python3-venv \
28
27
lsb-release \
29
28
wget \
30
29
gnupg \
@@ -54,14 +53,14 @@ RUN apt-get -q update \
54
53
#
55
54
FROM ci AS robot
56
55
57
- # Configure a new non-root user
58
- ARG USERNAME=blue
56
+ #
57
+ # Ubuntu 24.04 "Noble", which is used as the base image for
58
+ # jazzy and rolling images, now includes a user "ubuntu" at UID 1000
59
+ ARG USERNAME=ubuntu
59
60
ARG USER_UID=1000
60
61
ARG USER_GID=1000
61
62
62
- RUN groupadd --gid $USER_GID $USERNAME \
63
- && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
64
- && echo $USERNAME ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
63
+ RUN echo $USERNAME ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
65
64
&& chmod 0440 /etc/sudoers.d/$USERNAME \
66
65
&& usermod -a -G dialout $USERNAME \
67
66
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc
@@ -72,6 +71,16 @@ ENV DEBIAN_FRONTEND=noninteractive
72
71
USER $USERNAME
73
72
ENV USER=$USERNAME
74
73
74
+ # Python in Ubuntu is now marked as a "Externally managed environment",
75
+ # Per best practice, create a venv for local python packages
76
+ #
77
+ # These two ENVs effectively "activate" the venv for subsequent calls to
78
+ # python/pip in the Dockerfile
79
+ WORKDIR /home/$USERNAME
80
+ ENV VIRTUAL_ENV=/home/$USERNAME/.venv/blue
81
+ RUN python3 -m venv --system-site-packages --symlinks $VIRTUAL_ENV
82
+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
83
+
75
84
# Install MAVROS dependencies
76
85
WORKDIR /home/$USERNAME
77
86
RUN wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh \
@@ -106,10 +115,16 @@ RUN sudo apt-get -q update \
106
115
&& sudo apt-get clean -y \
107
116
&& sudo rm -rf /var/lib/apt/lists/*
108
117
118
+ # Manually install MAVROS from source in the ws_blue/ workspace
119
+ WORKDIR $USER_WORKSPACE/src/
120
+ ARG MAVROS_RELEASE=ros2
121
+ ARG MAVLINK_RELEASE=release/rolling/mavlink
122
+ RUN git clone --depth 1 -b ${MAVROS_RELEASE} https://github.com/mavlink/mavros.git
123
+ RUN git clone --depth 1 --recursive -b ${MAVLINK_RELEASE} https://github.com/ros2-gbp/mavlink-gbp-release.git mavlink
124
+
109
125
WORKDIR $USER_WORKSPACE
110
126
RUN sudo apt-get -q update \
111
127
&& sudo apt-get -q -y upgrade \
112
- && sudo chown -R ${USER_UID}:${USER_GID} src \
113
128
&& vcs import src < src/blue/blue.repos \
114
129
&& rosdep update \
115
130
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \
@@ -119,16 +134,15 @@ RUN sudo apt-get -q update \
119
134
120
135
# Actually build workspace
121
136
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
122
- && sudo chown -R ${USER_UID}:${USER_GID} $USER_WORKSPACE \
123
137
&& colcon build
124
138
125
139
RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
126
- && echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc
140
+ && echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc \
141
+ && echo "source $VIRTUAL_ENV/bin/activate" >> /home/$USERNAME/.bashrc \
142
+ && echo "\n # Ensure colcon is run in the venv\n alias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc
127
143
128
144
FROM robot AS desktop
129
- ARG USERNAME
130
- ARG USER_UID
131
- ARG USER_GID
145
+
132
146
ENV DEBIAN_FRONTEND=noninteractive
133
147
ENV GZ_VERSION=harmonic
134
148
@@ -137,18 +151,13 @@ ENV GZ_VERSION=harmonic
137
151
# https://github.com/hadolint/hadolint/wiki/DL3004
138
152
USER root
139
153
# Install custom rosdep list
140
- # ADD --chown=root:root --chmod=0644 https://raw.githubusercontent.com/osrf/osrf-rosdep/master/gz/00-gazebo.list /etc/ros/rosdep/sources.list.d/00-gazebo.list
141
- ADD https://raw.githubusercontent.com/osrf/osrf-rosdep/master/gz/00-gazebo.list /etc/ros/rosdep/sources.list.d/00-gazebo.list
142
-
143
- RUN sudo chown root:root /etc/ros/rosdep/sources.list.d/00-gazebo.list \
144
- && sudo chmod 0644 /etc/ros/rosdep/sources.list.d/00-gazebo.list
145
-
154
+ ADD --chown=root:root --chmod=0644 https://raw.githubusercontent.com/osrf/osrf-rosdep/master/gz/00-gazebo.list /etc/ros/rosdep/sources.list.d/00-gazebo.list
146
155
RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
147
156
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null \
148
157
&& apt-get -q update \
149
158
&& apt-get -y --quiet --no-install-recommends install \
159
+ cppzmq-dev \
150
160
gz-${GZ_VERSION} \
151
- ros-${ROS_DISTRO}-ros-gz${GZ_VERSION} \
152
161
python3-pexpect \
153
162
python3-wxgtk4.0 \
154
163
python3-future \
@@ -160,7 +169,7 @@ RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pk
160
169
&& apt-get clean -y \
161
170
&& rm -rf /var/lib/apt/lists/*
162
171
USER $USERNAME
163
- RUN echo $USERNAME
172
+
164
173
# Clone ArduSub
165
174
# ArduSub is installed for simulation purposes ONLY
166
175
# When deployed onto hardware, the native installation of ArduSub
@@ -174,7 +183,12 @@ RUN git clone -b ${ARDUPILOT_RELEASE} https://github.com/ArduPilot/ardupilot.git
174
183
# Install ArduSub dependencies
175
184
WORKDIR /home/$USERNAME/ardupilot
176
185
ENV SKIP_AP_EXT_ENV=1 SKIP_AP_GRAPHIC_ENV=1 SKIP_AP_COV_ENV=1 SKIP_AP_GIT_CHECK=1
177
- RUN Tools/environment_install/install-prereqs-ubuntu.sh -y
186
+ # Do not install the STM development tools
187
+ ENV DO_AP_STM_ENV=0
188
+ # Do not activate the Ardupilot venv by default
189
+ ENV DO_PYTHON_VENV_ENV=0
190
+ RUN echo "\n # Below from ardupilot script \" install-prereqs-ubuntu.sh\"\n " >> /home/$USERNAME/.bashrc && \
191
+ Tools/environment_install/install-prereqs-ubuntu.sh -y
178
192
179
193
# Build ArduSub
180
194
WORKDIR /home/$USERNAME/ardupilot
@@ -197,6 +211,7 @@ RUN [ "/bin/bash" , "-c" , " \
197
211
WORKDIR $USER_WORKSPACE
198
212
RUN sudo apt-get -q update \
199
213
&& sudo apt-get -q -y upgrade \
214
+ && vcs import src < src/blue/sim.repos \
200
215
&& rosdep update \
201
216
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --skip-keys="gz-transport12 gz-sim7 gz-math7 gz-msgs9 gz-plugin2" \
202
217
&& sudo apt-get autoremove -y \
@@ -231,6 +246,15 @@ export GZ_SIM_SYSTEM_PLUGIN_PATH=\$HOME/ardupilot_gazebo/build:\$GZ_SIM_SYSTEM_P
231
246
export GZ_SIM_RESOURCE_PATH=\$ HOME/ardupilot_gazebo/models:\$ HOME/ardupilot_gazebo/worlds:\$ GZ_SIM_RESOURCE_PATH
232
247
EOT
233
248
249
+ FROM desktop AS desktop-nvidia
250
+
251
+ # Add ardupilot_gazebo plugin
252
+ export GZ_SIM_SYSTEM_PLUGIN_PATH=\$ HOME/ardupilot_gazebo/build:\$ GZ_SIM_SYSTEM_PLUGIN_PATH
253
+
254
+ # Add ardupilot_gazebo models and worlds
255
+ export GZ_SIM_RESOURCE_PATH=\$ HOME/ardupilot_gazebo/models:\$ HOME/ardupilot_gazebo/worlds:\$ GZ_SIM_RESOURCE_PATH
256
+ EOT
257
+
234
258
FROM desktop AS desktop-nvidia
235
259
ARG USERNAME
236
260
ARG USER_UID
@@ -257,19 +281,3 @@ RUN sudo apt-get update \
257
281
ENV NVIDIA_VISIBLE_DEVICES=all
258
282
ENV NVIDIA_DRIVER_CAPABILITIES=graphics,utility,compute
259
283
ENV QT_X11_NO_MITSHM=1
260
-
261
- # # Incase rqt is not showing all the plugins.
262
- # RUN sudo apt update
263
- # RUN sudo apt install ros-${ROS_DISTRO}-rqt* -y
264
-
265
-
266
-
267
- # # Install OMPL with ROS2
268
- # RUN curl http://repo.ros2.org/repos.key | sudo apt-key add -
269
- # RUN sudo apt-get update
270
- # RUN sudo apt-get install -y ros-${ROS_DISTRO}-ompl
271
-
272
- # # Install learn_ros2
273
- # RUN cd ../..
274
- # RUN colcon build --packages-select learn_ros2
275
- # RUN . install/setup.bash
0 commit comments