Skip to content

Commit

Permalink
Hybrid ROS 1 / ROS 2 devcontainer (#18)
Browse files Browse the repository at this point in the history
**Public-Facing Changes**

**Description**
Use a single devcontainer.json that contains ROS 1 noetic and ROS 2
galactic in Ubuntu 20.04. Fixes
#17
  • Loading branch information
jhurliman authored Nov 8, 2022
1 parent ae13282 commit 7c3ecb2
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 72 deletions.
43 changes: 43 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ros:noetic-ros-core

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
clang-format \
curl \
git \
gnupg \
libasio-dev \
libssl-dev \
libwebsocketpp-dev \
lsb-release \
nlohmann-json3-dev \
python3-colcon-common-extensions \
python3-pip \
python3-rosdep \
python3-rosinstall \
python3-rosinstall-generator \
python3-wstool \
&& rm -rf /var/lib/apt/lists/*

# 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-ros-core \
&& rm -rf /var/lib/apt/lists/*

SHELL ["/bin/bash", "-c"]

# Create a ROS workspace
RUN mkdir -p /ros_ws/src/ros-foxglove-bridge

# Unset the ROS_DISTRO and add aliases to .bashrc
RUN echo $'\
unset ROS_DISTRO\n\
alias ros2_build_debug="colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Debug"\n\
alias ros2_build_release="colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release"\n\
alias ros2_foxglove_bridge="source /ros_ws/install/setup.bash && ros2 run foxglove_bridge foxglove_bridge --ros-args --log-level debug"\n\
' >> ~/.bashrc
23 changes: 0 additions & 23 deletions .devcontainer/Dockerfile.ros1

This file was deleted.

28 changes: 0 additions & 28 deletions .devcontainer/Dockerfile.ros2

This file was deleted.

18 changes: 5 additions & 13 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
// -*- jsonc -*-
{
// ROS 2 dev environment
"name": "ROS 2",
"workspaceFolder": "/ros2_ws/src/ros-foxglove-bridge",
"workspaceMount": "source=${localWorkspaceFolder},target=/ros2_ws/src/ros-foxglove-bridge,type=bind,consistency=cached",
"dockerFile": "./Dockerfile.ros2",

// ROS 1 dev environment
// "name": "ROS 1",
// "workspaceFolder": "/ros1_ws/src/ros-foxglove-bridge",
// "workspaceMount": "source=${localWorkspaceFolder},target=/ros1_ws/src/ros-foxglove-bridge,type=bind,consistency=cached",
// "dockerFile": "./Dockerfile.ros1",

// Shared configuration between ROS 1 and ROS 2 environments
// ROS 1 / ROS 2 hybrid dev environment
"name": "ROS 1 + 2",
"workspaceFolder": "/ros_ws/src/ros-foxglove-bridge",
"workspaceMount": "source=${localWorkspaceFolder},target=/ros_ws/src/ros-foxglove-bridge,type=bind,consistency=cached",
"dockerFile": "./Dockerfile",
"context": "..",
"forwardPorts": [
8765
Expand Down
6 changes: 4 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/opt/ros/${env:ROS_DISTRO}/include/**",
"/opt/ros/galactic/include/**",
"/opt/ros/noetic/include/**",
"/usr/include/**"
],
"browse": {
"path": [
"${workspaceFolder}",
"/opt/ros/${env:ROS_DISTRO}/include",
"/opt/ros/galactic/include",
"/opt/ros/noetic/include",
"/usr/include"
]
},
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ humble:
rolling:
docker build -t foxglove_bridge_rolling -f Dockerfile.ros2 --build-arg ROS_DISTRIBUTION=rolling .

.PHONY: ros2dev
ros2dev:
docker build -t foxglove_bridge_ros2dev -f .devcontainer/Dockerfile.ros2 .
.PHONY: rosdev
rosdev:
docker build -t foxglove_bridge_rosdev -f .devcontainer/Dockerfile .

clean:
docker rmi -f foxglove_bridge_ros1
Expand All @@ -40,7 +40,7 @@ clean:
docker rmi -f foxglove_bridge_galactic
docker rmi -f foxglove_bridge_humble
docker rmi -f foxglove_bridge_rolling
docker rmi -f foxglove_bridge_ros2dev
docker rmi -f foxglove_bridge_rosdev

.PHONY: melodic-test
melodic-test: melodic
Expand All @@ -63,5 +63,5 @@ rolling-test: rolling
docker run -t --rm foxglove_bridge_rolling colcon test --event-handlers console_cohesion+

.PHONY: lint
lint: ros2dev
docker run -t --rm -v $(CURDIR):/src foxglove_bridge_ros2dev python3 /src/scripts/format.py /src
lint: rosdev
docker run -t --rm -v $(CURDIR):/src foxglove_bridge_rosdev python3 /src/scripts/format.py /src

0 comments on commit 7c3ecb2

Please sign in to comment.