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

Updates to support ROS 2 Rolling (backport #41) #42

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ AlignAfterOpenBracket: AlwaysBreak
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 2
DerivePointerAlignment: false
AllowAllParametersOfDeclarationOnNextLine: false
PointerAlignment: Middle
PackConstructorInitializers: Never
BinPackArguments: false
BinPackParameters: false

# Configure brace wrapping cases
BreakBeforeBraces: Custom
Expand Down
2 changes: 0 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ Checks: >
-google-readability-namespace-comments,
-google-runtime-references,
-misc-non-private-member-variables-in-classes,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-magic-numbers,
Expand Down
76 changes: 33 additions & 43 deletions .docker/Dockerfile → .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG ROS_DISTRO=iron
FROM ros:$ROS_DISTRO-ros-base as ci
ARG ROS_DISTRO=rolling
FROM ros:$ROS_DISTRO-ros-base

ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /root/ws_ros
Expand All @@ -15,86 +15,76 @@ RUN apt-get -q update \
git \
sudo \
clang \
clang-format-14 \
clang-tidy \
clang-tools \
python3-pip \
python3-dev \
python3-venv \
apt-utils \
software-properties-common \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install all ROS dependencies needed for CI
RUN vcs import src < src/$PROJECT_NAME/ros2.repos \
&& 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 \
&& rm -rf src \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

FROM ci as desktop

# Configure a new non-root user
ARG USERNAME=ros
# Configure the ubuntu non-root user
ARG USERNAME=ubuntu
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
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

# Switch to the non-root user
# Switch to the ubuntu user
USER $USERNAME
ENV USER=$USERNAME

ENV DEBIAN_FRONTEND=noninteractive
ENV USER_WORKSPACE=/home/$USERNAME/ws_ros
WORKDIR $USER_WORKSPACE

COPY --chown=$USER_UID:$USER_GID . src/$PROJECT_NAME

# Create a new virtual environment for Python
ENV VIRTUAL_ENV=$USER_WORKSPACE/.venv/$PROJECT_NAME
RUN python3 -m venv --system-site-packages $VIRTUAL_ENV \
&& echo "source ${VIRTUAL_ENV}/bin/activate" >> /home/$USERNAME/.bashrc \
&& touch .venv/COLCON_IGNORE \
&& echo "\n# Ensure colcon is run in the venv\nalias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Install all ROS dependencies
RUN vcs import src < src/$PROJECT_NAME/ros2.repos
WORKDIR $USER_WORKSPACE
RUN vcs import src < src/$PROJECT_NAME/ros2.repos \
&& sudo apt-get -q update \
RUN sudo apt-get -q update \
&& sudo apt-get -q -y upgrade \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src -r --rosdistro ${ROS_DISTRO} \
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*

RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
&& colcon build \
&& sudo sed -i "s#/opt/ros/\$ROS_DISTRO/setup.bash#$USER_WORKSPACE/setup.sh#g" /ros_entrypoint.sh \
&& echo "source ${USER_WORKSPACE}/install/setup.bash" >> /home/$USERNAME/.bashrc \
&& echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc

FROM desktop as desktop-nvidia
WORKDIR $USER_WORKSPACE

# Install NVIDIA software
RUN sudo apt-get update \
# Install debugging/linting Python packages
RUN pip install \
pre-commit \
mypy

# Install debugging/linting C++ packages
RUN sudo apt-get -q update \
&& sudo apt-get -q -y upgrade \
&& sudo apt-get install -y -qq --no-install-recommends \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
libxext6 \
libx11-6 \
&& sudo apt-get install -y \
clang-format-18 \
clang-tidy \
clang-tools \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*

# Env vars for the nvidia-container-runtime.
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES graphics,utility,compute
ENV QT_X11_NO_MITSHM 1
# Disable the setuputils installation warning
# This prevents us from needing to pin the setuputils version (which doesn't always work)
ENV PYTHONWARNINGS="ignore"
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "ROS 2 Dev Container",
"dockerFile": "Dockerfile",
"context": "../",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/ubuntu/ws_ros/src/auv_controllers,type=bind",
"workspaceFolder": "/home/ubuntu/ws_ros/src/auv_controllers",
"remoteUser": "ubuntu",
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"ms-python.python",
"njpwerner.autodocstring",
"ms-vscode.cpptools",
"redhat.vscode-xml",
"redhat.vscode-yaml",
"smilerobotics.urdf",
"DavidAnson.vscode-markdownlint",
"esbenp.prettier-vscode",
"xaver.clang-format",
"charliermarsh.ruff",
"ms-vscode.cmake-tools"
]
}
}
}
27 changes: 0 additions & 27 deletions .devcontainer/nouveau/Dockerfile

This file was deleted.

42 changes: 0 additions & 42 deletions .devcontainer/nouveau/devcontainer.json

This file was deleted.

27 changes: 0 additions & 27 deletions .devcontainer/nvidia/Dockerfile

This file was deleted.

46 changes: 0 additions & 46 deletions .devcontainer/nvidia/devcontainer.json

This file was deleted.

4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# ignore everything

*

# Except the following
!requirements-dev.txt

!auv_controllers
!velocity_controllers
!thruster_allocation_matrix_controller
!thruster_controllers
!auv_control_msgs
!auv_control_demos
!ros2.repos
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
fail-fast: false
matrix:
env:
- IMAGE: iron-ci
ROS_DISTRO: iron
- ROS_DISTRO: rolling
steps:
- name: Checkout repository
uses: actions/checkout@v4
<<<<<<< HEAD
with:
submodules: recursive

Expand All @@ -33,15 +33,15 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
=======
>>>>>>> ad612dc (Updates to support ROS 2 Rolling (#41))

- name: Run ROS Industrial CI
uses: ros-industrial/industrial_ci@master
env:
DOCKER_IMAGE: ghcr.io/robotic-decision-making-lab/auv_controllers:${{ matrix.env.IMAGE }}
ROS_DISTRO: ${{ matrix.env.ROS_DISTRO }}
CXXFLAGS: -Wall -Wextra -Wpedantic
CLANG_TIDY: true
UPSTREAM_WORKSPACE: ros2.repos
AFTER_SETUP_UPSTREAM_WORKSPACE: vcs pull $BASEDIR/upstream_ws/src
AFTER_SETUP_DOWNSTREAM_WORKSPACE: vcs pull $BASEDIR/downstream_ws/src
CXXFLAGS: >-
-Wall -Wextra -Wpedantic -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls
CC: ${{ env.CLANG_TIDY && 'clang' }}
CXX: ${{ env.CLANG_TIDY && 'clang++' }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
build/
install/
log/

.mypy_cache/
.ruff_cache/
Loading
Loading