@@ -18,6 +18,7 @@ RUN apt-get -q update \
18
18
clang-tools \
19
19
python3-pip \
20
20
python3-dev \
21
+ python3-venv \
21
22
lsb-release \
22
23
wget \
23
24
gnupg \
@@ -47,14 +48,14 @@ RUN apt-get -q update \
47
48
#
48
49
FROM ci AS robot
49
50
50
- # Configure a new non-root user
51
- ARG USERNAME=blue
51
+ #
52
+ # Ubuntu 24.04 "Noble", which is used as the base image for
53
+ # jazzy and rolling images, now includes a user "ubuntu" at UID 1000
54
+ ARG USERNAME=ubuntu
52
55
ARG USER_UID=1000
53
56
ARG USER_GID=$USER_UID
54
57
55
- RUN groupadd --gid $USER_GID $USERNAME \
56
- && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
57
- && echo $USERNAME ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
58
+ RUN echo $USERNAME ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
58
59
&& chmod 0440 /etc/sudoers.d/$USERNAME \
59
60
&& usermod -a -G dialout $USERNAME \
60
61
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc
@@ -65,6 +66,16 @@ ENV DEBIAN_FRONTEND=noninteractive
65
66
USER $USERNAME
66
67
ENV USER=$USERNAME
67
68
69
+ # Python in Ubuntu is now marked as a "Externally managed environment",
70
+ # Per best practice, create a venv for local python packages
71
+ #
72
+ # These two ENVs effectively "activate" the venv for subsequent calls to
73
+ # python/pip in the Dockerfile
74
+ WORKDIR /home/$USERNAME
75
+ ENV VIRTUAL_ENV=/home/$USERNAME/.venv/blue
76
+ RUN python3 -m venv --system-site-packages --symlinks $VIRTUAL_ENV
77
+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
78
+
68
79
# Install MAVROS dependencies
69
80
WORKDIR /home/$USERNAME
70
81
RUN wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh \
@@ -97,6 +108,25 @@ RUN sudo apt-get -q update \
97
108
&& sudo apt-get clean -y \
98
109
&& sudo rm -rf /var/lib/apt/lists/*
99
110
111
+ # Manually install MAVROS from source in the ws_blue/ workspace
112
+ WORKDIR $USER_WORKSPACE/src/
113
+ ARG MAVROS_RELEASE=ros2
114
+ ARG MAVLINK_RELEASE=release/rolling/mavlink
115
+ RUN git clone --depth 1 -b ${MAVROS_RELEASE} https://github.com/mavlink/mavros.git
116
+ RUN git clone --depth 1 --recursive -b ${MAVLINK_RELEASE} https://github.com/mavlink/mavlink-gbp-release.git mavlink
117
+ # - mavgen uses future.standard_library for backwards compatibility with Python2;
118
+ # However, this caused issues with Python 3.12 installed in "noble".
119
+ # Comment those lines out in mavlink.
120
+ #
121
+ # - Fix linkage for yaml-cpp in mavros_extra_plugins
122
+ RUN sed -i -e 's/^from future import standard_library/#from future import standard_library/' \
123
+ -e 's/standard_library.install_aliases()/#standard_library.install_aliases()/' \
124
+ mavlink/pymavlink/generator/mavgen.py && \
125
+ sed -i -e 's/^# find_package(yaml_cpp REQUIRED)/find_package(yaml-cpp REQUIRED)/' \
126
+ -e '/^ament_target_dependencies(mavros_extras_plugins$/i target_link_libraries(mavros_extras_plugins yaml-cpp::yaml-cpp)' \
127
+ -e '/^ament_target_dependencies(mavros_extras$/i target_link_libraries(mavros_extras yaml-cpp::yaml-cpp)' \
128
+ mavros/mavros_extras/CMakeLists.txt
129
+
100
130
WORKDIR $USER_WORKSPACE
101
131
RUN sudo apt-get -q update \
102
132
&& sudo apt-get -q -y upgrade \
@@ -112,48 +142,58 @@ RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
112
142
&& colcon build
113
143
114
144
RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
115
- && echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc
145
+ && echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/$USERNAME/.bashrc \
146
+ && echo "source $VIRTUAL_ENV/bin/activate" >> /home/$USERNAME/.bashrc \
147
+ && echo "\n # Ensure colcon is run in the venv\n alias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc
116
148
117
149
FROM robot AS desktop
118
150
119
151
ENV DEBIAN_FRONTEND=noninteractive
120
- ENV GZ_VERSION=garden
121
-
122
- # Install Gazebo Garden: https://gazebosim.org/docs/garden/install_ubuntu
123
- RUN sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
124
- && 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" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null \
125
- && sudo apt-get -q update \
126
- && sudo apt-get -y --quiet --no-install-recommends install \
127
- gz-garden \
128
- && sudo apt-get autoremove -y \
129
- && sudo apt-get clean -y \
130
- && sudo rm -rf /var/lib/apt/lists/*
131
-
132
- # Install ArduPilot and ardupilot_gazebo dependencies
133
- RUN sudo apt-get -q update \
134
- && sudo apt-get -q -y upgrade \
135
- && sudo apt-get -q install --no-install-recommends -y \
152
+ ENV GZ_VERSION=harmonic
153
+
154
+ # Install Gazebo Harmonic: https://gazebosim.org/docs/harmonic/install_ubuntu
155
+ # Per DL3004, use "USER root" rather than "sudo"
156
+ # https://github.com/hadolint/hadolint/wiki/DL3004
157
+ USER root
158
+ # Install custom rosdep list
159
+ 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
160
+ RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
161
+ && 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 \
162
+ && apt-get -q update \
163
+ && apt-get -y --quiet --no-install-recommends install \
164
+ cppzmq-dev \
165
+ gz-${GZ_VERSION} \
166
+ python3-pexpect \
136
167
python3-wxgtk4.0 \
168
+ python3-future \
137
169
rapidjson-dev \
138
170
xterm \
139
- libgz-sim7-dev \
140
171
rapidjson-dev \
141
172
libopencv-dev \
142
- && sudo apt-get autoremove -y \
143
- && sudo apt-get clean -y \
144
- && sudo rm -rf /var/lib/apt/lists/*
173
+ && apt-get autoremove -y \
174
+ && apt-get clean -y \
175
+ && rm -rf /var/lib/apt/lists/*
176
+ USER $USERNAME
145
177
146
178
# Clone ArduSub
147
179
# ArduSub is installed for simulation purposes ONLY
148
180
# When deployed onto hardware, the native installation of ArduSub
149
181
# (on the FCU) will be used.
150
182
WORKDIR /home/$USERNAME
151
- RUN git clone https://github.com/ArduPilot/ardupilot.git --recurse-submodules
183
+ # Really should do version pinning but Sub-4.5 is waaaay behind master
184
+ # (e.g. it doesn't know about "noble" yet)
185
+ ARG ARDUPILOT_RELEASE=master
186
+ RUN git clone -b ${ARDUPILOT_RELEASE} https://github.com/ArduPilot/ardupilot.git --recurse-submodules
152
187
153
188
# Install ArduSub dependencies
154
189
WORKDIR /home/$USERNAME/ardupilot
155
190
ENV SKIP_AP_EXT_ENV=1 SKIP_AP_GRAPHIC_ENV=1 SKIP_AP_COV_ENV=1 SKIP_AP_GIT_CHECK=1
156
- RUN Tools/environment_install/install-prereqs-ubuntu.sh -y
191
+ # Do not install the STM development tools
192
+ ENV DO_AP_STM_ENV=0
193
+ # Do not activate the Ardupilot venv by default
194
+ ENV DO_PYTHON_VENV_ENV=0
195
+ RUN echo "\n # Below from ardupilot script \" install-prereqs-ubuntu.sh\"\n " >> /home/$USERNAME/.bashrc && \
196
+ Tools/environment_install/install-prereqs-ubuntu.sh -y
157
197
158
198
# Build ArduSub
159
199
WORKDIR /home/$USERNAME/ardupilot
0 commit comments