ROS 2 extensions¶
The ROS 2 extensions, helps fill in common settings for software built with the ROS 2 libraries.
There are three extensions in this family, each for a different version of ROS 2.
Extension |
Internal name |
ROS 2 version |
Snap requirements |
ROS 2 Foxy |
|
core20 |
|
ROS 2 Humble |
|
core22 |
|
ROS 2 Jazzy |
|
core24 |
All three extensions require Snapcraft 7.3 or higher.
Included parts¶
The extension adds its own part to the project, which pulls in the ROS 2 build packages.
Included parts
ros2-foxy-extension:
build-packages:
- ros-foxy-ros-environment
- ros-foxy-ros-workspace
- ros-foxy-ament-index-cpp
- ros-foxy-ament-index-python
plugin: make
source: $SNAPCRAFT_EXTENSIONS_DIR/ros2
Included parts
ros2-humble/ros2-launch:
source: /snap/snapcraft/13181/share/snapcraft/extensions/ros2
plugin: make
build-packages:
- ros-humble-ros-environment
- ros-humble-ros-workspace
- ros-humble-ament-index-cpp
- ros-humble-ament-index-python
Included parts
ros2-jazzy/ros2-launch:
source: /snap/snapcraft/13181/share/snapcraft/extensions/ros2
plugin: make
build-packages:
- ros-jazzy-ros-environment
- ros-jazzy-ros-workspace
- ros-jazzy-ament-index-cpp
- ros-jazzy-ament-index-python
Included build environment variables¶
For the main part of the project, the extension sets the following build environment variables.
Included build environment variables
build-environment:
- ROS_VERSION: "2"
- ROS_DISTRO: foxy
Included build environment variables
build-environment:
- ROS_VERSION: "2"
- ROS_DISTRO: humble
Included build environment variables
build-environment:
- ROS_VERSION: "2"
- ROS_DISTRO: jazzy
Included runtime environment settings¶
For all apps that use the extension, it initializes a runtime environment required by
ROS 2 before launching the app, similar to sourcing the typical ROS 2
local_setup.bash.
Included runtime environment settings
command-chain:
- snap/command-chain/ros2-launch
environment:
PYTHONPATH: $SNAP/opt/ros/foxy/lib/python3.8/site-packages:$SNAP/usr/lib/python3/dist-packages:${PYTHONPATH}
ROS_DISTRO: foxy
ROS_VERSION: "2"
Included runtime environment settings
environment:
ROS_VERSION: "2"
ROS_DISTRO: humble
PYTHONPATH: $SNAP/opt/ros/humble/lib/python3.10/site-packages:$SNAP/usr/lib/python3/dist-packages:${PYTHONPATH}
ROS_HOME: $SNAP_USER_DATA/ros
command-chain:
- snap/command-chain/ros2-launch
Included runtime environment settings
environment:
ROS_VERSION: "2"
ROS_DISTRO: jazzy
PYTHONPATH: $SNAP/opt/ros/jazzy/lib/python3.12/site-packages:$SNAP/usr/lib/python3/dist-packages:${PYTHONPATH}
ROS_HOME: $SNAP_USER_DATA/ros
command-chain:
- snap/command-chain/ros2-launch
Included package repositories¶
The extension adds the ROS 2 APT package repository build-time configuration for the snap, which installs the necessary GPG key.
Included package repositories
package-repositories:
- components:
- main
formats:
- deb
key-id: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
key-server: keyserver.ubuntu.com
suites:
- focal
type: apt
url: http://repo.ros2.org/ubuntu/main
Included package repositories
package-repositories:
- type: apt
url: http://repo.ros2.org/ubuntu/main
components:
- main
formats:
- deb
key-id: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
key-server: keyserver.ubuntu.com
suites:
- jammy
Included package repositories
package-repositories:
- type: apt
url: http://packages.ros.org/ros2/ubuntu
components:
- main
formats:
- deb
key-id: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
key-server: keyserver.ubuntu.com
suites:
- noble
Example expanded project file¶
Here are examples of the result project files that use the ROS 2 extensions. They demonstrates the added plugs, packages, variables, and layouts that the extensions add to the project file immediately prior to build.
Each example contains the difference between the original file and the output of the snapcraft expand-extensions command. Some of the text has been altered for ease of reading.
The files are based on the ros2-talker-listener project.
Expanded project file for ros2-talker-listener
name: ros2-talker-listener
version: "0.1"
summary: ROS 2 Talker/Listener Example
description: |
This example launches a ROS 2 talker and listener.
confinement: devmode
base: core20
parts:
ros-demos:
plugin: colcon
source: https://github.com/ros2/demos.git
source-branch: foxy
source-subdir: demo_nodes_cpp
stage-packages:
- ros-foxy-ros2launch
+ build-environment:
+ - ROS_VERSION: "2"
+ - ROS_DISTRO: foxy
+ ros2-foxy-extension:
+ build-packages:
+ - ros-foxy-ros-environment
+ - ros-foxy-ros-workspace
+ - ros-foxy-ament-index-cpp
+ - ros-foxy-ament-index-python
+ plugin: make
+ source: $SNAPCRAFT_EXTENSIONS_DIR/ros2
apps:
ros2-talker-listener:
command: opt/ros/foxy/bin/ros2 launch demo_nodes_cpp talker_listener.launch.py
- extensions:
- - ros2-foxy
+ command-chain:
+ - snap/command-chain/ros2-launch
+ environment:
+ PYTHONPATH: $SNAP/opt/ros/foxy/lib/python3.8/site-packages:$SNAP/usr/lib/python3/dist-packages:${PYTHONPATH}
+ ROS_DISTRO: foxy
+ ROS_VERSION: "2"
+
+package-repositories:
+ - components:
+ - main
+ formats:
+ - deb
+ key-id: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
+ key-server: keyserver.ubuntu.com
+ suites:
+ - focal
+ type: apt
+ url: http://repo.ros2.org/ubuntu/main
Expanded project file for ros2-talker-listener
name: ros2-talker-listener
version: "0.1"
summary: ROS 2 Talker/Listener Example
description: |
This example launches a ROS 2 talker and listener.
confinement: devmode
base: core22
architectures:
- build-on:
- amd64
build-for:
- amd64
parts:
ros-demos:
plugin: colcon
source: https://github.com/ros2/demos.git
source-branch: humble
source-subdir: demo_nodes_cpp
stage-packages:
- ros-humble-ros2launch
+ build-environment:
+ - ROS_VERSION: "2"
+ - ROS_DISTRO: humble
+ ros2-humble/ros2-launch:
+ source: /snap/snapcraft/13181/share/snapcraft/extensions/ros2
+ plugin: make
+ build-packages:
+ - ros-humble-ros-environment
+ - ros-humble-ros-workspace
+ - ros-humble-ament-index-cpp
+ - ros-humble-ament-index-python
apps:
ros2-talker-listener:
command: opt/ros/humble/bin/ros2 launch demo_nodes_cpp talker_listener.launch.py
- extensions:
- - ros2-humble
+ environment:
+ ROS_VERSION: "2"
+ ROS_DISTRO: humble
+ PYTHONPATH: $SNAP/opt/ros/humble/lib/python3.10/site-packages:$SNAP/usr/lib/python3/dist-packages:${PYTHONPATH}
+ ROS_HOME: $SNAP_USER_DATA/ros
+ command-chain:
+ - snap/command-chain/ros2-launch
+
+package-repositories:
+ - type: apt
+ url: http://repo.ros2.org/ubuntu/main
+ components:
+ - main
+ formats:
+ - deb
+ key-id: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
+ key-server: keyserver.ubuntu.com
+ suites:
+ - jammy
+
+lint:
+ ignore:
+ - unused-library:
+ - opt/ros/*
+ - lib/*/libcrypt.so*
+ - lib/*/libexpat.so*
+ - lib/*/libtirpc.so*
+ - lib/*/libz.so*
+ - usr/lib/*libatomic.so*
+ - usr/lib/*libconsole_bridge.so*
+ - usr/lib/*libfmt.so*
+ - usr/lib/*libicui18n.so*
+ - usr/lib/*libicuio.so*
+ - usr/lib/*libicutest.so*
+ - usr/lib/*libicutu.so*
+ - usr/lib/*libpython3.10.so*
+ - usr/lib/*libspdlog.so*
+ - usr/lib/*libtinyxml2.so*
Expanded project file for ros2-talker-listener
name: ros2-talker-listener
version: "0.1"
summary: ROS 2 Talker/Listener Example
description: |
This example launches a ROS 2 talker and listener.
confinement: devmode
base: core24
parts:
ros-demos:
plugin: colcon
source: https://github.com/ros2/demos.git
source-branch: jazzy
source-subdir: demo_nodes_cpp
stage-packages:
- ros-jazzy-ros2launch
+ build-environment:
+ - ROS_VERSION: "2"
+ - ROS_DISTRO: jazzy
+ ros2-jazzy/ros2-launch:
+ source: /snap/snapcraft/13181/share/snapcraft/extensions/ros2
+ plugin: make
+ build-packages:
+ - ros-jazzy-ros-environment
+ - ros-jazzy-ros-workspace
+ - ros-jazzy-ament-index-cpp
+ - ros-jazzy-ament-index-python
apps:
ros2-talker-listener:
command: ros2 launch demo_nodes_cpp talker_listener.launch.py
- extensions:
- - ros2-jazzy
+ environment:
+ ROS_VERSION: "2"
+ ROS_DISTRO: jazzy
+ PYTHONPATH: $SNAP/opt/ros/jazzy/lib/python3.12/site-packages:$SNAP/usr/lib/python3/dist-packages:${PYTHONPATH}
+ ROS_HOME: $SNAP_USER_DATA/ros
+ command-chain:
+ - snap/command-chain/ros2-launch
+
+package-repositories:
+ - type: apt
+ url: http://packages.ros.org/ros2/ubuntu
+ components:
+ - main
+ formats:
+ - deb
+ key-id: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
+ key-server: keyserver.ubuntu.com
+ suites:
+ - noble
+
+lint:
+ ignore:
+ - unused-library:
+ - opt/ros/*
+ - lib/*/libcrypt.so*
+ - lib/*/libexpat.so*
+ - lib/*/libtirpc.so*
+ - lib/*/libz.so*
+ - usr/lib/*libatomic.so*
+ - usr/lib/*libconsole_bridge.so*
+ - usr/lib/*libfmt.so*
+ - usr/lib/*libicui18n.so*
+ - usr/lib/*libicuio.so*
+ - usr/lib/*libicutest.so*
+ - usr/lib/*libicutu.so*
+ - usr/lib/*libpython3.10.so*
+ - usr/lib/*libspdlog.so*
+ - usr/lib/*libtinyxml2.so*