ROS 1 Content extensions

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

These extensions are split across content types, and are declared with the format ros1-noetic-<metapackage>. The available extensions are:

  • ros1-noetic-ros-core

  • ros1-noetic-ros-base

  • ros1-noetic-desktop

  • ros1-noetic-perception

  • ros1-noetic-robot

Included interface connections

The most important modification the content extension makes 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 ROS 1 extension.

Then, it adds the ROS environment library as a stage package.

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 ROS 1 extension.

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

Example expanded project file

Here is an example of the result of a project file that uses an ROS 1 Content extension. 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 ros1-talker-listener project.

Expanded project file for ros2-talker-listener
 name: ros-talker-listener
 version: "0.1"
 summary: ROS Talker/Listener Example
 description: |
   This example launches a ROS talker and listener.
 
 confinement: devmode
 base: core20
 
 parts:
   ros-tutorials:
     plugin: catkin
     source: https://github.com/ros/ros_tutorials.git
     source-branch: noetic-devel
     catkin-packages:
       - roscpp_tutorials
     stage-packages:
+      - ros-noetic-ros-environment
       - ros-noetic-roslaunch
+    build-environment:
+      - ROS_VERSION: "1"
+      - ROS_DISTRO: noetic
+    ros-content-sharing-extension-cmake-args:
+      - -DCMAKE_SYSTEM_PREFIX_PATH="/snap/ros-noetic-desktop-dev/current/usr"
+    ros-build-snaps:
+      - ros-noetic-desktop-dev
+  ros1-noetic-extension:
+    build-packages:
+      - ros-noetic-catkin
+    plugin: make
+    source: $SNAPCRAFT_EXTENSIONS_DIR/ros1
 
 apps:
   ros-talker-listener:
     command: opt/ros/noetic/bin/roslaunch roscpp_tutorials talker_listener.launch
-    extensions:
-      - ros1-noetic-desktop
+    command-chain:
+      - snap/command-chain/ros1-launch
+    environment:
+      PYTHONPATH: $SNAP/opt/ros/noetic/lib/python3.8/site-packages:$SNAP/usr/lib/python3/dist-packages:${PYTHONPATH}:$SNAP/opt/ros/underlay_ws/opt/ros/noetic/lib/python3.8/site-packages:$SNAP/opt/ros/underlay_ws/usr/lib/python3/dist-packages
+      ROS_DISTRO: noetic
+      ROS_VERSION: "1"
+
+plugs:
+  ros-noetic-desktop:
+    content: ros-noetic-desktop
+    default-provider: ros-noetic-desktop
+    interface: content
+    target: $SNAP/opt/ros/underlay_ws
+
+package-repositories:
+  - components:
+      - main
+    formats:
+      - deb
+    key-id: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
+    key-server: keyserver.ubuntu.com
+    suites:
+      - focal
+    type: apt
+    url: http://packages.ros.org/ros/ubuntu