Skip to content
Merged
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
1 change: 1 addition & 0 deletions features/src/ros2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Install ROS 2 and the tools needed to develop ROS packages.
|-----|-----|-----|-----|
| distro | ROS 2 distribution to install. By default, select the recommended distribution for the container's Ubuntu release. | string | auto |
| package | ROS 2 metapackage to install. | string | desktop |
| additionalPackages | Space-separated ROS package suffixes to install in addition to the selected metapackage, without the ros-<distro>- prefix. | string | - |
| workspace | Workspace whose install/setup.sh file should be sourced when present. | string | ${containerWorkspaceFolder} |

## Supported Ubuntu releases
Expand Down
5 changes: 5 additions & 0 deletions features/src/ros2/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"default": "desktop",
"description": "ROS 2 metapackage to install."
},
"additionalPackages": {
"type": "string",
"default": "",
"description": "Space-separated ROS package suffixes to install in addition to the selected metapackage, without the ros-<distro>- prefix."
},
"workspace": {
"type": "string",
"default": "${containerWorkspaceFolder}",
Expand Down
10 changes: 10 additions & 0 deletions features/src/ros2/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -euo pipefail

ros_distro="${DISTRO:-auto}"
ros_package="${PACKAGE:-desktop}"
ros_additional_packages="${ADDITIONALPACKAGES:-}"
ros_workspace="${WORKSPACE:-${_REMOTE_USER_HOME:-/workspaces}/ros2_ws}"
feature_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
distribution_config="${feature_dir}/distributions.json"
Expand Down Expand Up @@ -130,8 +131,17 @@ dpkg -i "${ros_apt_source_package}"
rm -f "${ros_apt_source_package}"

apt-get update
additional_apt_packages=()
if [[ -n "${ros_additional_packages}" ]]; then
read -r -a additional_package_names <<<"${ros_additional_packages}"
for additional_package_name in "${additional_package_names[@]}"; do
additional_apt_packages+=("ros-${ros_distro}-${additional_package_name}")
done
fi

apt-get install -y --no-install-recommends \
"ros-${ros_distro}-${ros_package}" \
"${additional_apt_packages[@]}" \
python3-colcon-common-extensions \
python3-rosdep \
python3-vcstool \
Expand Down
10 changes: 10 additions & 0 deletions features/test/ros2/additional_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e
source dev-container-features-test-lib

check "ROS 2 Kilted is selected" bash -lc '[ "${ROS_DISTRO:-}" = "kilted" ]'
check "ROS 2 CLI is installed" bash -lc 'command -v ros2 >/dev/null'
check "RViz is installed" bash -lc 'ros2 pkg prefix rviz2 >/dev/null'

reportResults
10 changes: 10 additions & 0 deletions features/test/ros2/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
"features": { "ros2": { "distro": "kilted", "package": "ros-base" } }
},
"additional_packages": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
"features": {
"ros2": {
"distro": "kilted",
"package": "ros-base",
"additionalPackages": "rviz2"
}
}
},
"lyrical": {
"image": "ubuntu:26.04",
"features": { "ros2": { "package": "ros-base" } }
Expand Down