ROS 2 Content extensions

The ROS 2 Content extensions comprise the main ROS 2 extensions, plus additional settings to enable content sharing.

These extensions are split across ROS 2 versions and content types, and are declared with the format ros2-<version>-<metapackage>. The available extensions are:

  • ros2-foxy-ros-core

  • ros2-foxy-ros-base

  • ros2-foxy-desktop

These extensions require Snapcraft 8 and higher, and are experimental.

Included interface connections

The most important modification the content extensions make to the project file is to connect the content plug which mounts the provider snap content at $SNAP/opt/ros/underlay_ws and defines a default provider.

Included build environment settings

First, the content extension includes all the build settings from the corresponding ROS 2 Foxy extension.

Then, it adds stage packages for the environment, workspace, and the C++ and Python libraries for the ament resource index.

It sets the CMAKE_SYSTEM_PREFIX_PATH variable to point at the mounted system path.

Lastly, it adds the build snap that provides the build-time equivalent of the default content-sharing provider snap to ros-build-snaps.

Included runtime environment settings

First, the content extension includes all the runtime variables from the corresponding ROS 2 extension.

It then expands the runtime environment required by ROS 2 to include the ROS 2 workspace provided by the content-sharing snap – similar to the conventional chaining of ROS 2 workspaces.

Example expanded project file

Here is an example of the result of a project file that uses a content extension for ROS 2 Jazzy Jalisco. It demonstrates the added plugs, packages, variables, and layouts that the content extensions add to the project file immediately prior to build.

This 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 file is 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: 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
+    colcon-ros-build-snaps:
+      - ros-jazzy-desktop-dev
+    colcon-cmake-args:
+      - -DCMAKE_SYSTEM_PREFIX_PATH="/snap/ros-jazzy-desktop-dev/current/usr"
+  ros2-jazzy-desktop/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
+      - libpython3.12-dev
+    stage-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-desktop
+    environment:
+      ROS_VERSION: "2"
+      ROS_DISTRO: jazzy
+      PYTHONPATH: $SNAP/opt/ros/jazzy/lib/python3.12/site-packages:$SNAP/usr/lib/python3/dist-packages:${PYTHONPATH}:$SNAP/opt/ros/underlay_ws/opt/ros/jazzy/lib/python3.12/site-packages:$SNAP/opt/ros/underlay_ws/usr/lib/python3/dist-packages
+      ROS_HOME: $SNAP_USER_DATA/ros
+    command-chain:
+      - snap/command-chain/ros2-launch
+
+plugs:
+  ros-jazzy-desktop:
+    content: ros-jazzy-desktop
+    interface: content
+    target: $SNAP/opt/ros/underlay_ws
+    default-provider: ros-jazzy-desktop
+
+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*