From c1089695ff6f22b6ec0c78d83ddfdd2e3eacfaaf Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 12 Feb 2024 14:08:29 -0800 Subject: [PATCH 1/4] Remove dual ROS 1+2 devcontainer, remove ROS Galactic from the support matrix --- .devcontainer/Dockerfile | 100 -------------------------------- .devcontainer/devcontainer.json | 9 +-- .github/workflows/ci.yml | 2 +- .vscode/c_cpp_properties.json | 4 +- Makefile | 2 +- README.md | 5 +- 6 files changed, 9 insertions(+), 113 deletions(-) delete mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 446f55d..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,100 +0,0 @@ -FROM ros:noetic-ros-core - -# Install system dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - bash-completion \ - build-essential \ - clang \ - clang-format \ - curl \ - gdb \ - git \ - git-lfs \ - gnupg \ - lsb-release \ - openssh-client \ - python3-catkin-tools \ - python3-colcon-common-extensions \ - python3-pip \ - python3-rosdep \ - python3-rosinstall \ - python3-rosinstall-generator \ - python3-wstool \ - strace \ - sudo \ - && rm -rf /var/lib/apt/lists/* - -ENV CC=clang -ENV CXX=clang++ - -# Authorize the ROS 2 GPG key and add the ROS 2 apt repository -RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg -RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu focal main" > /etc/apt/sources.list.d/ros2.list - -# Install ROS 2 -RUN apt-get update && apt-get install -y --no-install-recommends \ - ros-galactic-foxglove-msgs \ - ros-galactic-ros-core \ - ros-galactic-rosbag2 \ - ros-galactic-rosbag2-storage-mcap \ - ros-galactic-tf2-msgs \ - && rm -rf /var/lib/apt/lists/* - -# Create a non-root user -# Taken from https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user -ARG USERNAME=vscode -ARG USER_UID=1000 -ARG USER_GID=$USER_UID - -# Create the user -RUN groupadd --gid $USER_GID $USERNAME \ - && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # - # [Optional] Add sudo support. Omit if you don't need to install software after connecting. - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME - -# [Optional] Set the default user. Omit if you want to keep the default as root. -USER $USERNAME - -COPY --chown=$USERNAME:$USERNAME package.xml /ros_ws/src/ros-foxglove-bridge/package.xml - -# Initialize rosdep -RUN sudo rosdep init && rosdep update --include-eol-distros - -# Install rosdep dependencies for ROS 1 -RUN . /opt/ros/noetic/setup.sh && \ - sudo apt-get update && rosdep update && rosdep install -y \ - --from-paths /ros_ws/src \ - --ignore-src \ - && sudo rm -rf /var/lib/apt/lists/* - -# Install rosdep dependencies for ROS 2 -RUN . /opt/ros/galactic/setup.sh && \ - sudo apt-get update && rosdep update --include-eol-distros && rosdep install -y \ - --from-paths /ros_ws/src \ - --ignore-src \ - && sudo rm -rf /var/lib/apt/lists/* - -RUN catkin config --init --install \ - --workspace /ros_ws \ - --extend /opt/ros/noetic \ - --build-space build_ros1 \ - --devel-space devel_ros1 \ - --install-space install_ros1 \ - --log-space log_ros1 - -ENV COLCON_DEFAULTS_FILE=/ros_ws/src/ros-foxglove-bridge/.devcontainer/colcon_defaults.yaml - -SHELL ["/bin/bash", "-c"] - -# Unset the ROS_DISTRO and add aliases to .bashrc -RUN echo $'\ -unset ROS_DISTRO\n\ -alias ros1_build_debug="catkin build -DCMAKE_BUILD_TYPE=Debug"\n\ -alias ros1_build_release="catkin build -DCMAKE_BUILD_TYPE=RelWithDebInfo"\n\ -alias ros1_foxglove_bridge="/ros_ws/install_ros1/env.sh roslaunch foxglove_bridge foxglove_bridge.launch --screen"\n\ -alias ros2_build_debug="source /opt/ros/galactic/setup.bash && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug"\n\ -alias ros2_build_release="source /opt/ros/galactic/setup.bash && colcon build --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo"\n\ -alias ros2_foxglove_bridge="source /ros_ws/install_ros2/setup.bash && ros2 run foxglove_bridge foxglove_bridge --ros-args --log-level debug --log-level rcl:=INFO"\n\ -' >> ~/.bashrc diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 51dbd25..65e88ad 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,10 +1,9 @@ // -*- jsonc -*- { - // ROS 1 / ROS 2 hybrid dev environment - "name": "ROS 1 + 2", + "name": "ROS 2", "workspaceFolder": "/ros_ws/src/ros-foxglove-bridge", "workspaceMount": "source=${localWorkspaceFolder},target=/ros_ws/src/ros-foxglove-bridge,type=bind,consistency=cached", - "dockerFile": "./Dockerfile", + "dockerFile": "../Dockerfile.ros2", "context": "..", "forwardPorts": [ 8765 @@ -32,7 +31,5 @@ }, "capAdd": [ "SYS_PTRACE" - ], - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - "remoteUser": "vscode" + ] } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a999d4b..1330029 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - ros_distribution: [melodic, noetic, galactic, humble, iron, rolling] + ros_distribution: [melodic, noetic, humble, iron, rolling] name: Test (ROS ${{ matrix.ros_distribution }}) runs-on: ubuntu-latest diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index f95bd61..dd27810 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -5,14 +5,14 @@ "name": "Linux", "includePath": [ "${workspaceFolder}/**", - "/opt/ros/galactic/include/**", + "/opt/ros/humble/include/**", "/opt/ros/noetic/include/**", "/usr/include/**" ], "browse": { "path": [ "${workspaceFolder}", - "/opt/ros/galactic/include", + "/opt/ros/humble/include", "/opt/ros/noetic/include", "/usr/include" ] diff --git a/Makefile b/Makefile index 6f67375..08876b3 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ ROS1_DISTRIBUTIONS := melodic noetic -ROS2_DISTRIBUTIONS := galactic humble iron rolling +ROS2_DISTRIBUTIONS := humble iron rolling define generate_ros1_targets .PHONY: $(1) diff --git a/README.md b/README.md index 7c6ce18..6dd0ca2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ foxglove_bridge [![ROS Melodic version](https://img.shields.io/ros/v/melodic/foxglove_bridge)](https://index.ros.org/p/foxglove_bridge/github-foxglove-ros-foxglove-bridge/#melodic) [![ROS Noetic version](https://img.shields.io/ros/v/noetic/foxglove_bridge)](https://index.ros.org/p/foxglove_bridge/github-foxglove-ros-foxglove-bridge/#noetic) -[![ROS Galactic version](https://img.shields.io/ros/v/galactic/foxglove_bridge)](https://index.ros.org/p/foxglove_bridge/github-foxglove-ros-foxglove-bridge/#galactic) [![ROS Humble version](https://img.shields.io/ros/v/humble/foxglove_bridge)](https://index.ros.org/p/foxglove_bridge/github-foxglove-ros-foxglove-bridge/#humble) [![ROS Iron version](https://img.shields.io/ros/v/iron/foxglove_bridge)](https://index.ros.org/p/foxglove_bridge/github-foxglove-ros-foxglove-bridge/#iron) [![ROS Rolling version](https://img.shields.io/ros/v/rolling/foxglove_bridge)](https://index.ros.org/p/foxglove_bridge/github-foxglove-ros-foxglove-bridge/#rolling) @@ -121,7 +120,7 @@ A VSCode container is provided with a dual ROS 1 and ROS 2 installation and enough tools to build and run the bridge. Some bash aliases are defined to simplify the common workflow. Here's an example of building and running the ROS 2 node: ```bash -source /opt/ros/galactic/setup.bash +source /opt/ros/humble/setup.bash ros2_build_debug # or ros2_build_release ros2_foxglove_bridge ``` @@ -135,7 +134,7 @@ To test the bridge with example data, open another terminal and download the tes Then start playback: ```bash -source /opt/ros/galactic/setup.bash +source /opt/ros/humble/setup.bash ros2 bag play -l --clock 100 -s mcap data/nuScenes-v1.0-mini-scene-0061-ros2.mcap ``` From 0e57bb2f830d8dab893f20ee6703244ba03770ae Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 12 Feb 2024 14:22:58 -0800 Subject: [PATCH 2/4] Add devcontainer Dockerfile back, ROS 2 only --- .devcontainer/Dockerfile | 55 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..cc74d61 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,55 @@ +ARG ROS_DISTRIBUTION=humble +FROM ros:$ROS_DISTRIBUTION-ros-base + +# Install clang and set as default compiler. +RUN apt-get update && apt-get install -y --no-install-recommends \ + clang \ + && rm -rf /var/lib/apt/lists/* + +ENV CC=clang +ENV CXX=clang++ + +# Set environment and working directory +ENV ROS_WS /ros2_ws +WORKDIR $ROS_WS + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + bash-completion \ + build-essential \ + clang \ + clang-format \ + curl \ + gdb \ + git \ + git-lfs \ + gnupg \ + libasio-dev \ + libboost-all-dev \ + libssl-dev \ + libwebsocketpp-dev \ + nlohmann-json3-dev \ + strace \ + && rm -rf /var/lib/apt/lists/* + +# Add package.xml so we can install package dependencies +COPY package.xml src/ros-foxglove-bridge/ + +# Install rosdep dependencies +RUN . /opt/ros/$ROS_DISTRO/setup.sh && \ + apt-get update && rosdep update --include-eol-distros && rosdep install -y \ + --from-paths \ + src \ + --ignore-src \ + && rm -rf /var/lib/apt/lists/* + +ENV COLCON_DEFAULTS_FILE=/ros_ws/src/ros-foxglove-bridge/.devcontainer/colcon_defaults.yaml + +SHELL ["/bin/bash", "-c"] + +# Add aliases to .bashrc +RUN echo $'\ +alias ros2_build_debug="source /opt/ros/humble/setup.bash && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug"\n\ +alias ros2_build_release="source /opt/ros/humble/setup.bash && colcon build --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo"\n\ +alias ros2_foxglove_bridge="source /ros_ws/install_ros2/setup.bash && ros2 run foxglove_bridge foxglove_bridge --ros-args --log-level debug --log-level rcl:=INFO"\n\ +' >> ~/.bashrc diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 65e88ad..472afc5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,7 @@ "name": "ROS 2", "workspaceFolder": "/ros_ws/src/ros-foxglove-bridge", "workspaceMount": "source=${localWorkspaceFolder},target=/ros_ws/src/ros-foxglove-bridge,type=bind,consistency=cached", - "dockerFile": "../Dockerfile.ros2", + "dockerFile": "./Dockerfile", "context": "..", "forwardPorts": [ 8765 From 399829dd5944f04cef777b72a6a6d15b4792fdc3 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 13 Feb 2024 13:11:44 -0800 Subject: [PATCH 3/4] Address feedback --- .devcontainer/Dockerfile | 15 +++++++++++++++ .devcontainer/devcontainer.json | 4 +++- .github/workflows/ci.yml | 2 +- .vscode/c_cpp_properties.json | 2 -- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index cc74d61..f450706 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -30,6 +30,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libwebsocketpp-dev \ nlohmann-json3-dev \ strace \ + sudo \ && rm -rf /var/lib/apt/lists/* # Add package.xml so we can install package dependencies @@ -47,6 +48,20 @@ ENV COLCON_DEFAULTS_FILE=/ros_ws/src/ros-foxglove-bridge/.devcontainer/colcon_de SHELL ["/bin/bash", "-c"] +# Create a non-root user +# Taken from https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Create the user and add them to sudoers +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 \ + && chmod 0440 /etc/sudoers.d/$USERNAME + +USER $USERNAME + # Add aliases to .bashrc RUN echo $'\ alias ros2_build_debug="source /opt/ros/humble/setup.bash && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug"\n\ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 472afc5..6b6f288 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -31,5 +31,7 @@ }, "capAdd": [ "SYS_PTRACE" - ] + ], + // More info: + "remoteUser": "vscode" } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1330029..a999d4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - ros_distribution: [melodic, noetic, humble, iron, rolling] + ros_distribution: [melodic, noetic, galactic, humble, iron, rolling] name: Test (ROS ${{ matrix.ros_distribution }}) runs-on: ubuntu-latest diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index dd27810..23dc80f 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -6,14 +6,12 @@ "includePath": [ "${workspaceFolder}/**", "/opt/ros/humble/include/**", - "/opt/ros/noetic/include/**", "/usr/include/**" ], "browse": { "path": [ "${workspaceFolder}", "/opt/ros/humble/include", - "/opt/ros/noetic/include", "/usr/include" ] }, From b57bd08490bc2ec8354259ae5c7d1c137ce8ce65 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 13 Feb 2024 13:13:20 -0800 Subject: [PATCH 4/4] Remove galactic from test matrix, it no longer has Makefile entries --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a999d4b..1330029 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - ros_distribution: [melodic, noetic, galactic, humble, iron, rolling] + ros_distribution: [melodic, noetic, humble, iron, rolling] name: Test (ROS ${{ matrix.ros_distribution }}) runs-on: ubuntu-latest