Skip to content

Commit 158b9cd

Browse files
evan-palmermergify[bot]
authored andcommitted
Updates to support ROS 2 Rolling (#41)
* Updated dockerfile and devcontainer * Cleanup controllers for latest version of ros2_control * Removed dll_export stuff * Cleanup devcontainer * Updated to use latest version of hydrodynamics * Fix clang tidy errors * Resolve final error in CI * Fixed dev container name (cherry picked from commit ad612dc) # Conflicts: # .devcontainer/Dockerfile # .devcontainer/nouveau/Dockerfile # .devcontainer/nvidia/Dockerfile # .github/workflows/ci.yml # .github/workflows/docker.yml # .vscode/c_cpp_properties.json # .vscode/settings.json # thruster_allocation_matrix_controller/include/thruster_allocation_matrix_controller/thruster_allocation_matrix_controller.hpp # thruster_allocation_matrix_controller/src/thruster_allocation_matrix_controller.cpp # thruster_controllers/include/thruster_controllers/polynomial_thrust_curve_controller.hpp # thruster_controllers/src/polynomial_thrust_curve_controller.cpp # velocity_controllers/include/velocity_controllers/integral_sliding_mode_controller.hpp # velocity_controllers/src/integral_sliding_mode_controller.cpp
1 parent 05aeace commit 158b9cd

38 files changed

+887
-1088
lines changed

.clang-format

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ AlignAfterOpenBracket: AlwaysBreak
1212
ConstructorInitializerIndentWidth: 0
1313
ContinuationIndentWidth: 2
1414
DerivePointerAlignment: false
15+
AllowAllParametersOfDeclarationOnNextLine: false
1516
PointerAlignment: Middle
1617
PackConstructorInitializers: Never
18+
BinPackArguments: false
19+
BinPackParameters: false
1720

1821
# Configure brace wrapping cases
1922
BreakBeforeBraces: Custom

.clang-tidy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ Checks: >
1313
-google-readability-namespace-comments,
1414
-google-runtime-references,
1515
-misc-non-private-member-variables-in-classes,
16-
-modernize-return-braced-init-list,
17-
-modernize-use-trailing-return-type,
1816
-readability-braces-around-statements,
1917
-readability-identifier-length,
2018
-readability-magic-numbers,
Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
<<<<<<< HEAD:.docker/Dockerfile
12
ARG ROS_DISTRO=humble
23
FROM ros:$ROS_DISTRO-ros-base as ci
4+
=======
5+
ARG ROS_DISTRO=rolling
6+
FROM ros:$ROS_DISTRO-ros-base
7+
>>>>>>> ad612dc (Updates to support ROS 2 Rolling (#41)):.devcontainer/Dockerfile
38

49
ENV DEBIAN_FRONTEND=noninteractive
510
WORKDIR /root/ws_ros
@@ -15,86 +20,76 @@ RUN apt-get -q update \
1520
git \
1621
sudo \
1722
clang \
18-
clang-format-14 \
19-
clang-tidy \
20-
clang-tools \
2123
python3-pip \
2224
python3-dev \
25+
python3-venv \
2326
apt-utils \
2427
software-properties-common \
2528
&& apt-get autoremove -y \
2629
&& apt-get clean -y \
2730
&& rm -rf /var/lib/apt/lists/*
2831

29-
# Install all ROS dependencies needed for CI
30-
RUN vcs import src < src/$PROJECT_NAME/ros2.repos \
31-
&& apt-get -q update \
32-
&& apt-get -q -y upgrade \
33-
&& rosdep update \
34-
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false \
35-
&& rm -rf src \
36-
&& apt-get autoremove -y \
37-
&& apt-get clean -y \
38-
&& rm -rf /var/lib/apt/lists/*
39-
40-
FROM ci as desktop
41-
42-
# Configure a new non-root user
43-
ARG USERNAME=ros
32+
# Configure the ubuntu non-root user
33+
ARG USERNAME=ubuntu
4434
ARG USER_UID=1000
4535
ARG USER_GID=$USER_UID
4636

47-
RUN groupadd --gid $USER_GID $USERNAME \
48-
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
49-
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
37+
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
5038
&& chmod 0440 /etc/sudoers.d/$USERNAME \
5139
&& usermod -a -G dialout $USERNAME \
5240
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc
5341

54-
# Switch to the non-root user
42+
# Switch to the ubuntu user
5543
USER $USERNAME
5644
ENV USER=$USERNAME
5745

58-
ENV DEBIAN_FRONTEND=noninteractive
5946
ENV USER_WORKSPACE=/home/$USERNAME/ws_ros
6047
WORKDIR $USER_WORKSPACE
6148

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

51+
# Create a new virtual environment for Python
52+
ENV VIRTUAL_ENV=$USER_WORKSPACE/.venv/$PROJECT_NAME
53+
RUN python3 -m venv --system-site-packages $VIRTUAL_ENV \
54+
&& echo "source ${VIRTUAL_ENV}/bin/activate" >> /home/$USERNAME/.bashrc \
55+
&& touch .venv/COLCON_IGNORE \
56+
&& echo "\n# Ensure colcon is run in the venv\nalias colcon='python3 -m colcon'" >> /home/$USERNAME/.bashrc
57+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
58+
6459
# Install all ROS dependencies
60+
RUN vcs import src < src/$PROJECT_NAME/ros2.repos
6561
WORKDIR $USER_WORKSPACE
66-
RUN vcs import src < src/$PROJECT_NAME/ros2.repos \
67-
&& sudo apt-get -q update \
62+
RUN sudo apt-get -q update \
6863
&& sudo apt-get -q -y upgrade \
6964
&& rosdep update \
70-
&& rosdep install -y --from-paths src --ignore-src -r --rosdistro ${ROS_DISTRO} \
65+
&& rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} \
7166
&& sudo apt-get autoremove -y \
7267
&& sudo apt-get clean -y \
7368
&& sudo rm -rf /var/lib/apt/lists/*
7469

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

81-
FROM desktop as desktop-nvidia
75+
WORKDIR $USER_WORKSPACE
8276

83-
# Install NVIDIA software
84-
RUN sudo apt-get update \
77+
# Install debugging/linting Python packages
78+
RUN pip install \
79+
pre-commit \
80+
mypy
81+
82+
# Install debugging/linting C++ packages
83+
RUN sudo apt-get -q update \
8584
&& sudo apt-get -q -y upgrade \
86-
&& sudo apt-get install -y -qq --no-install-recommends \
87-
libglvnd0 \
88-
libgl1 \
89-
libglx0 \
90-
libegl1 \
91-
libxext6 \
92-
libx11-6 \
85+
&& sudo apt-get install -y \
86+
clang-format-18 \
87+
clang-tidy \
88+
clang-tools \
9389
&& sudo apt-get autoremove -y \
9490
&& sudo apt-get clean -y \
9591
&& sudo rm -rf /var/lib/apt/lists/*
9692

97-
# Env vars for the nvidia-container-runtime.
98-
ENV NVIDIA_VISIBLE_DEVICES all
99-
ENV NVIDIA_DRIVER_CAPABILITIES graphics,utility,compute
100-
ENV QT_X11_NO_MITSHM 1
93+
# Disable the setuputils installation warning
94+
# This prevents us from needing to pin the setuputils version (which doesn't always work)
95+
ENV PYTHONWARNINGS="ignore"

.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "ROS 2 Dev Container",
3+
"dockerFile": "Dockerfile",
4+
"context": "../",
5+
"workspaceMount": "source=${localWorkspaceFolder},target=/home/ubuntu/ws_ros/src/auv_controllers,type=bind",
6+
"workspaceFolder": "/home/ubuntu/ws_ros/src/auv_controllers",
7+
"remoteUser": "ubuntu",
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"ms-azuretools.vscode-docker",
12+
"ms-python.python",
13+
"njpwerner.autodocstring",
14+
"ms-vscode.cpptools",
15+
"redhat.vscode-xml",
16+
"redhat.vscode-yaml",
17+
"smilerobotics.urdf",
18+
"DavidAnson.vscode-markdownlint",
19+
"esbenp.prettier-vscode",
20+
"xaver.clang-format",
21+
"charliermarsh.ruff",
22+
"ms-vscode.cmake-tools"
23+
]
24+
}
25+
}
26+
}

.devcontainer/nouveau/devcontainer.json

Lines changed: 0 additions & 42 deletions
This file was deleted.

.devcontainer/nvidia/devcontainer.json

Lines changed: 0 additions & 46 deletions
This file was deleted.

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# ignore everything
2+
23
*
34

45
# Except the following
5-
!requirements-dev.txt
6+
67
!auv_controllers
78
!velocity_controllers
89
!thruster_allocation_matrix_controller
910
!thruster_controllers
1011
!auv_control_msgs
12+
!auv_control_demos
1113
!ros2.repos

.github/workflows/ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
env:
22+
<<<<<<< HEAD
2223
- IMAGE: humble-ci
2324
ROS_DISTRO: humble
2425
steps:
@@ -33,15 +34,19 @@ jobs:
3334
registry: ghcr.io
3435
username: ${{ github.actor }}
3536
password: ${{ secrets.GITHUB_TOKEN }}
37+
=======
38+
- ROS_DISTRO: rolling
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v4
42+
>>>>>>> ad612dc (Updates to support ROS 2 Rolling (#41))
3643

3744
- name: Run ROS Industrial CI
3845
uses: ros-industrial/industrial_ci@master
3946
env:
40-
DOCKER_IMAGE: ghcr.io/robotic-decision-making-lab/auv_controllers:${{ matrix.env.IMAGE }}
47+
ROS_DISTRO: ${{ matrix.env.ROS_DISTRO }}
48+
CXXFLAGS: -Wall -Wextra -Wpedantic
49+
CLANG_TIDY: true
4150
UPSTREAM_WORKSPACE: ros2.repos
4251
AFTER_SETUP_UPSTREAM_WORKSPACE: vcs pull $BASEDIR/upstream_ws/src
4352
AFTER_SETUP_DOWNSTREAM_WORKSPACE: vcs pull $BASEDIR/downstream_ws/src
44-
CXXFLAGS: >-
45-
-Wall -Wextra -Wpedantic -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls
46-
CC: ${{ env.CLANG_TIDY && 'clang' }}
47-
CXX: ${{ env.CLANG_TIDY && 'clang++' }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
build/
33
install/
44
log/
5+
6+
.mypy_cache/
7+
.ruff_cache/

.pre-commit-config.yaml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 23.1.0
4-
hooks:
5-
- id: black
6-
72
- repo: https://github.com/astral-sh/ruff-pre-commit
83
rev: v0.0.291
94
hooks:
@@ -14,17 +9,17 @@ repos:
149
rev: v2.2.4
1510
hooks:
1611
- id: codespell
17-
args: ["--write-changes"]
1812

19-
- repo: local
13+
- repo: https://github.com/pre-commit/mirrors-clang-format
14+
rev: v18.1.8
15+
hooks:
16+
- id: clang-format
17+
types_or: [c++, c]
18+
19+
- repo: https://github.com/BlankSpruce/gersemi
20+
rev: 0.13.5
2021
hooks:
21-
- id: clang-format
22-
name: clang-format
23-
description: Format files with ClangFormat.
24-
entry: clang-format-14
25-
language: system
26-
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
27-
args: ['-fallback-style=Google', '-i']
22+
- id: gersemi
2823

2924
- repo: https://github.com/pre-commit/pre-commit-hooks
3025
rev: v4.4.0
@@ -36,9 +31,6 @@ repos:
3631
- id: check-yaml
3732
- id: check-xml
3833
- id: check-merge-conflict
39-
- id: check-symlinks
40-
- id: debug-statements
41-
- id: destroyed-symlinks
4234
- id: detect-private-key
4335
- id: end-of-file-fixer
4436
- id: mixed-line-ending

.vscode/c_cpp_properties.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
"name": "Linux",
55
"includePath": [
66
"${workspaceFolder}/**",
7+
<<<<<<< HEAD
78
"/opt/ros/humble/include/**",
9+
=======
10+
"/opt/ros/rolling/include/**",
11+
>>>>>>> ad612dc (Updates to support ROS 2 Rolling (#41))
812
"/usr/include/eigen3/**",
9-
"/home/ros/ws_ros/**"
13+
"/home/${USER}/ws_ros/install/**"
1014
],
1115
"defines": [],
12-
"compilerPath": "/usr/bin/gcc",
16+
"compilerPath": "/usr/bin/clang",
1317
"cStandard": "c99",
1418
"cppStandard": "c++20",
15-
"intelliSenseMode": "linux-gcc-x64"
19+
"intelliSenseMode": "linux-clang-x64"
1620
}
1721
],
1822
"version": 4

0 commit comments

Comments
 (0)