Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build for Jazzy with mavros from source #1

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .devcontainer/robot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Dockerfile for *-robot development container
#
FROM ghcr.io/robotic-decision-making-lab/blue:jazzy-robot

# Install ROS dependencies
# This is done in a previous stage, but we include it again here in case anyone wants to
# add new dependencies during development
ENV USERNAME=blue
ENV USER_WORKSPACE=/home/$USERNAME/ws_blue
WORKDIR $USER_WORKSPACE

COPY --chown=$USER_UID:$USER_GID . src/blue
RUN sudo apt-get -q update \
&& sudo apt-get -q -y upgrade \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --skip-keys="gz-transport12 gz-sim7 gz-math7 gz-msgs9 gz-plugin2" \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*

# Install debugging/linting Python packages
RUN /home/$USERNAME/.venv/blue/bin/python3 -m pip install \
pre-commit \
mypy

# Disable the setuputils installation warning
# This prevents us from needing to pin the setuputils version (which doesn't always work)
ENV PYTHONWARNINGS="ignore"
39 changes: 39 additions & 0 deletions .devcontainer/robot/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "Robot Dev Container",
"dockerFile": "Dockerfile",
"context": "../..",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/blue/ws_blue/src/blue,type=bind",
"workspaceFolder": "/home/blue/ws_blue/src/blue",
"remoteUser": "blue",
"runArgs": [
"--network=host",
"--cap-add=SYS_PTRACE",
"--security-opt=seccomp:unconfined",
"--security-opt=apparmor:unconfined",
"--volume=/dev:/dev",
"--privileged",
"--volume=/run/user/1000:/run/user/1000"
],
"containerEnv": {
"DISPLAY": "${localEnv:DISPLAY}",
"WAYLAND_DISPLAY": "${localEnv:WAYLAND_DISPLAY}",
"XDG_RUNTIME_DIR": "${localEnv:XDG_RUNTIME_DIR}",
"PULSE_SERVER": "${localEnv:PULSE_SERVER}"
},
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"ms-python.python",
"njpwerner.autodocstring",
"redhat.vscode-xml",
"redhat.vscode-yaml",
"smilerobotics.urdf",
"esbenp.prettier-vscode",
"charliermarsh.ruff",
"josetr.cmake-language-support-vscode",
"unifiedjs.vscode-mdx"
]
}
}
}
39 changes: 31 additions & 8 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN apt-get -q update \
clang-tools \
python3-pip \
python3-dev \
python3-venv \
lsb-release \
wget \
gnupg \
Expand All @@ -27,10 +28,11 @@ RUN apt-get -q update \
&& rm -rf /var/lib/apt/lists/*

# Install all ROS dependencies
# Don't try to resolve "mavros" or "mavros_extras", we will install those manually
RUN apt-get -q update \
&& apt-get -q -y upgrade \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false --skip-keys="mavros mavros_extras" \
&& rm -rf src \
&& apt-get autoremove -y \
&& apt-get clean -y \
Expand All @@ -40,7 +42,7 @@ FROM ci as robot

# Configure a new non-root user
ARG USERNAME=blue
ARG USER_UID=1000
ARG USER_UID=1001 # ros image now includes a user "ubuntu" at UID 1000

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may run into permissions issues here when trying to use the devcontainer. The blue user likely won't belong to the same group as your personal user on your local system (set to 1000 by default). My solution has been to go along with the ubuntu user standardization.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I hadn't considered the permission ramifications. So you are using the user ubuntu?

# Configure a new non-root user
#
# ros image now includes a user "ubuntu" at UID 1000
ARG USERNAME=ubuntu
ARG USER_UID=1000  
ARG USER_GID=$USER_UID

RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
    && chmod 0440 /etc/sudoers.d/$USERNAME \
    && usermod -a -G dialout $USERNAME \
    && echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. This was motivated by discussions in cloud-images!2005129, which make it seem like the Ubuntu devs are attempting to standardize the ubuntu user. You could still delete the ubuntu user to regain access to UID 1000, but I opted against that.

ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
Expand All @@ -56,8 +58,19 @@ ENV DEBIAN_FRONTEND=noninteractive
USER $USERNAME
ENV USER=$USERNAME

# Install MAVROS dependencies
# Given Ubuntu is now marked as a "Externally managed environment",
# Create venv for local python packages install by "$USERNAME" with pip
# Is there a more elegant way to handle this?
#
# These two ENVs effectively "activate" the venv for all subsequent calls to python
WORKDIR /home/$USERNAME
ENV VIRTUAL_ENV=/home/$USERNAME/.venv/blue
RUN python3 -m venv --system-site-packages $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN echo "source /home/$USERNAME/.venv/blue/bin/activate" >> /home/$USERNAME/.bashrc

# Install MAVROS dependencies
RUN wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh \
&& chmod +x install_geographiclib_datasets.sh \
&& sudo ./install_geographiclib_datasets.sh
Expand All @@ -67,7 +80,7 @@ WORKDIR $USER_WORKSPACE
COPY --chown=$USER_UID:$USER_GID . src/blue

# Install the Python requirements that aren't available as rosdeps
RUN python3 -m pip install -r $(pwd)/src/blue/requirements-build.txt
RUN pip install -r $(pwd)/src/blue/requirements-build.txt

# Install gstreamer
RUN sudo apt-get -q update \
Expand All @@ -85,10 +98,18 @@ RUN sudo apt-get -q update \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*

# Manually install MAVROS source
WORKDIR $USER_WORKSPACE/src/
RUN git clone --depth 1 -b ros2 https://github.com/mavlink/mavros.git
RUN git clone --depth 1 --recursive -b release/rolling/mavlink https://github.com/mavlink/mavlink-gbp-release.git mavlink
RUN ls -al $USER_WORKSPACE/src/blue/**
RUN patch -d mavlink -p 1 < $USER_WORKSPACE/src/blue/.docker/patches/mavlink_standard_library.patch
WORKDIR $USER_WORKSPACE

RUN sudo apt-get -q update \
&& sudo apt-get -q -y upgrade \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \
&& rosdep install -y --from-paths src --ignore-src --as-root=pip:false --rosdistro ${ROS_DISTRO} \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*
Expand All @@ -99,14 +120,14 @@ RUN echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashr
FROM robot as desktop

ENV DEBIAN_FRONTEND=noninteractive
ENV GZ_VERSION=garden
ENV GZ_VERSION=harmonic

# Install Gazebo Garden: https://gazebosim.org/docs/garden/install_ubuntu
# Install Gazebo Hamonic: https://gazebosim.org/docs/harmonic/install_ubuntu
RUN sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
&& 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 \
&& sudo apt-get -q update \
&& sudo apt-get -y --quiet --no-install-recommends install \
gz-garden \
gz-${GZ_VERSION} \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*
Expand All @@ -115,6 +136,8 @@ RUN sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrin
RUN sudo apt-get -q update \
&& sudo apt-get -q -y upgrade \
&& sudo apt-get -q install --no-install-recommends -y \
cppzmq-dev \
python3-pexpect \
python3-wxgtk4.0 \
rapidjson-dev \
xterm \
Expand Down
15 changes: 15 additions & 0 deletions .docker/patches/mavlink_standard_library.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/pymavlink/generator/mavgen.py b/pymavlink/generator/mavgen.py
index ea62c961..35353184 100755
--- a/pymavlink/generator/mavgen.py
+++ b/pymavlink/generator/mavgen.py
@@ -23,8 +23,8 @@ General process:
'''

from __future__ import print_function
-from future import standard_library
-standard_library.install_aliases()
+#from future import standard_library
+#standard_library.install_aliases()
from builtins import object
import os
import re
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
!blue_demos
!blue.repos
!.docker/entrypoints
!.docker/patches
!requirements-build.txt
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
fail-fast: false
matrix:
env:
- IMAGE: rolling-ci
ROS_DISTRO: rolling
- IMAGE: jazzy-ci
ROS_DISTRO: jazzy
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [rolling]
ROS_DISTRO: [jazzy]
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [rolling]
ROS_DISTRO: [jazzy]
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [rolling]
ROS_DISTRO: [jazzy]
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [rolling]
ROS_DISTRO: [jazzy]
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down
2 changes: 1 addition & 1 deletion blue.repos
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repositories:
ros_gz:
type: git
url: https://github.com/gazebosim/ros_gz
version: ros2
version: jazzy

hydrodynamics:
type: git
Expand Down