Skip to content

Commit 69b95df

Browse files
committed
Merge branch 'main' of https://github.com/Robotic-Decision-Making-Lab/blue into dev/mavros_in_build_stage
2 parents 06ca909 + fe3861d commit 69b95df

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

.docker/Dockerfile

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ ENV VIRTUAL_ENV=/home/$USERNAME/.venv/blue
151151
RUN python3 -m venv --system-site-packages --symlinks $VIRTUAL_ENV
152152
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
153153

154+
# Python in Ubuntu is now marked as a "Externally managed environment",
155+
# Per best practice, create a venv for local python packages
156+
#
157+
# These two ENVs effectively "activate" the venv for subsequent calls to
158+
# python/pip in the Dockerfile
159+
WORKDIR /home/$USERNAME
160+
ENV VIRTUAL_ENV=/home/$USERNAME/.venv/blue
161+
RUN python3 -m venv --system-site-packages --symlinks $VIRTUAL_ENV
162+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
163+
154164
# Install MAVROS dependencies
155165
WORKDIR /home/$USERNAME
156166
RUN wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh \
@@ -183,6 +193,25 @@ RUN sudo apt-get -q update \
183193
&& sudo apt-get clean -y \
184194
&& sudo rm -rf /var/lib/apt/lists/*
185195

196+
# Manually install MAVROS from source in the ws_blue/ workspace
197+
WORKDIR $USER_WORKSPACE/src/
198+
ARG MAVROS_RELEASE=ros2
199+
ARG MAVLINK_RELEASE=release/rolling/mavlink
200+
RUN git clone --depth 1 -b ${MAVROS_RELEASE} https://github.com/mavlink/mavros.git
201+
RUN git clone --depth 1 --recursive -b ${MAVLINK_RELEASE} https://github.com/mavlink/mavlink-gbp-release.git mavlink
202+
# - mavgen uses future.standard_library for backwards compatibility with Python2;
203+
# However, this caused issues with Python 3.12 installed in "noble".
204+
# Comment those lines out in mavlink.
205+
#
206+
# - Fix linkage for yaml-cpp in mavros_extra_plugins
207+
RUN sed -i -e 's/^from future import standard_library/#from future import standard_library/' \
208+
-e 's/standard_library.install_aliases()/#standard_library.install_aliases()/' \
209+
mavlink/pymavlink/generator/mavgen.py && \
210+
sed -i -e 's/^# find_package(yaml_cpp REQUIRED)/find_package(yaml-cpp REQUIRED)/' \
211+
-e '/^ament_target_dependencies(mavros_extras_plugins$/i target_link_libraries(mavros_extras_plugins yaml-cpp::yaml-cpp)' \
212+
-e '/^ament_target_dependencies(mavros_extras$/i target_link_libraries(mavros_extras yaml-cpp::yaml-cpp)' \
213+
mavros/mavros_extras/CMakeLists.txt
214+
186215
WORKDIR $USER_WORKSPACE
187216
RUN sudo apt-get -q update \
188217
&& sudo apt-get -q -y upgrade \
@@ -199,7 +228,7 @@ RUN sudo apt-get -q update \
199228
RUN . "${MAVROS_WORKSPACE}/install/setup.sh" \
200229
&& colcon build
201230

202-
RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
231+
RUN echo "source ${MAVROS_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
203232
&& echo "source $VIRTUAL_ENV/bin/activate" >> /home/$USERNAME/.bashrc \
204233
&& echo "\n# Ensure colcon is run in the venv\nalias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc
205234

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"editor.defaultFormatter": "charliermarsh.ruff"
4444
},
45+
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/blue/bin/python",
4546
"[dockerfile]": {
4647
"editor.quickSuggestions": {
4748
"strings": true

0 commit comments

Comments
 (0)