ROS 1 extension

The ROS 1 extension, referred to internally as ros1-noetic, helps fill in common settings for software built with the ROS Noetic Ninjemys libraries.

This extension requires Snapcraft 7.3 or higher, and is supported with the core20 base.

Included parts

The extension adds its own part to the project, which pulls in the ROS build packages.

Included parts
snapcraft.yaml
ros1-noetic-extension:
  build-packages:
    - ros-noetic-catkin
  plugin: make
  source: $SNAPCRAFT_EXTENSIONS_DIR/ros1

Included build environment variables

For the main part of the project, the extension sets the following build environment variables.

Included build environment variables
snapcraft.yaml
build-environment:
  - ROS_VERSION: "1"
  - ROS_DISTRO: noetic

Included runtime environment settings

For all apps that use the extension, it initializes a runtime environment required by ROS before launching the app, similar to sourcing the typical ROS setup.sh or local_setup.sh.

Included runtime environment settings
snapcraft.yaml
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}
  ROS_DISTRO: noetic
  ROS_VERSION: "1"

Included package repositories

The extension adds the ROS APT package repository to the build-time configuration for the snap, which installs the necessary GPG key.

Included package repositories
snapcraft.yaml
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

Example expanded project file

Here is an example of the result of a project file that uses the ROS 1 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 ros2-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-roslaunch
+    build-environment:
+      - ROS_VERSION: "1"
+      - ROS_DISTRO: noetic
+  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
+    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}
+      ROS_DISTRO: noetic
+      ROS_VERSION: "1"
+
+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