ROS 2 is distributed via Open Robotics’ own Debian archive, along with many community-supported tools. It’s possible to get your own application into their archive as well, but it requires that the application is open-source.
You’re also left with the question of how to update ROS 2 and your application on a robotic platform that has already been shipped. With snapcraft it’s just one command to bundle a specific ROS 2 version along with your application (proprietary or open-source) into a snap that works anywhere and can be automatically updated.
Ready to get started? By the end of this guide, you’ll understand how to make a snap of your app that can be published in the Snap Store, showcasing it to millions of Linux users.
For a brief overview of the snap creation process, including how to install snapcraft and how it’s used, see Snapcraft overview. For a more comprehensive breakdown of the steps involved, take a look at Creating a snap.
There are currently four supported bases for ROS 2, core18, core20, core22 and core24.
core18 is based on Ubuntu 18.04 LTS.
core20 is based on Ubuntu 20.04 LTS.
core22 is based on Ubuntu 22.04 LTS.
core24 is based on Ubuntu 24.04 LTS.
Let us explore the differences between the different bases.
Snapcraft 7.x or lower is required to build core18 snaps. Snapcraft 8 does not support core18.
Switch with: sudo snap refresh snapcraft --channel=7.x/stable
.
Snaps are defined in a single YAML file placed in the root folder of your project. The following example shows the entire snapcraft.yaml file for an example project, ros2-talker-listener. Don’t worry, we’ll break this down.
name: ros2-talker-listener
version: '0.1'
summary: ROS 2 Talker/Listener Example
description: |
This example launches a ROS 2 talker and listener.
base: core18
confinement: devmode
parts:
ros-demos:
plugin: colcon
source: https://github.com/ros2/demos.git
source-branch: dashing
colcon-rosdistro: dashing
colcon-source-space: demo_nodes_cpp
stage-packages: [ros-dashing-ros2launch]
apps:
ros2-talker-listener:
command: opt/ros/dashing/bin/ros2 launch demo_nodes_cpp talker_listener.launch.py
You can download the example repository with the following command:
$ git clone https://github.com/snapcraft-docs/ros2-talker-listener
The snapcraft.yaml
file starts with a small amount of human-readable metadata, which usually can be lifted from the GitHub description or project README.md. This data is used in the presentation of your app in the Snap Store.
name: ros2-talker-listener
version: '0.1'
summary: ROS 2 Talker/Listener Example
description: |
This example launches a ROS 2 talker and listener.
The name
must be unique in the Snap Store. Valid snap names consist of lower-case alphanumeric characters and hyphens. They cannot be all numbers and they also cannot start or end with a hyphen.
Versions carry no semantic meaning in snaps and this version is arbitrary. It’s also possible to write a script to calculate the version, or to take a tag or commit from a git repository.
The summary
can not exceed 79 characters. You can use a chevron ‘>’ in the description
key to declare a multi-line description.
For more information about top level metadata, see, top-level-metadata.
The base keyword defines a special kind of snap that provides a run-time environment with a minimal set of libraries that are common to most applications. They’re transparent to users, but they need to be considered, and specified, when building a snap.
base: core18
core18
is based on Ubuntu 18.04 LTS. It is therefore the base for ROS Melodic and ROS 2 Dashing snaps.
To get started we won’t confine this application. Unconfined applications, specified with devmode
, can only be released to the hidden “edge” channel.
confinement: devmode
For more information about security model, see, choosing-a-security-model.
Parts define how to build your app and can be anything: programs, libraries, or other assets needed to create and run your application. Their source can be local directories, remote git repositories, or tarballs. In this example, we have a single part: ros-demos.
Snapcraft relies on well known and well established ROS tools such as, in this example, colcon
.
Note: It is easy to forget the importance of complete install rules, i.e. rules for installing every component of the package necessary to run, or every component necessary to use a given library.
The packages you’re building must have install rules, or else snapcraft
won’t know which components to place into the snap. Make sure you install binaries, libraries, header files, launch files, etc.
parts:
ros-demos:
plugin: colcon
source: https://github.com/ros2/demos.git
source-branch: dashing
colcon-rosdistro: dashing
colcon-source-space: demo_nodes_cpp
stage-packages: [ros-dashing-ros2launch]
For more details on colcon-specific metadata, see the colcon plugin documentation. For more information about general parts metadata, see parts-metadata.
Apps are the commands and services exposed to end users. Each entry under apps
is the command name that should be exposed to the end users.
The command
specifies the full path to the binary to be run.
apps:
ros2-talker-listener:
command: opt/ros/dashing/bin/ros2 launch demo_nodes_cpp talker_listener.launch.py
In snap, an application is usually prefixed by the snap name so that the application my-app
from the snap my-snap
can be executed calling my-snap.my-app
. However, if both the snap and the app are called the same, as is the case in our ROS 2 example, the execution command collapses to avoid the tediousness of writing twice the same words. The command ros2-talker-listener.ros2-talker-listener
simply becomes ros2-talker-listener
.
After you’ve created the snapcraft.yaml, you can build the snap by simply executing the snapcraft command in the project directory:
$ snapcraft
Using 'snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Launching a VM.
[...]
Snapped ros2-talker-listener_0.1_amd64.snap
The warnings regarding missing libraries that you might see when building your snap are false positive. These libraries are build time dependencies only.
The resulting snap can be installed locally. This requires the --dangerous
flag because the snap is not signed by the Snap Store. The --devmode
flag acknowledges that you are installing an unconfined application:
$ sudo snap install ros2-talker-listener_*.snap --devmode --dangerous
You can then try it out:
$ ros2-talker-listener
[INFO] [launch]: All log files can be found below /home/user/snap/ros2-talker-listener/x1/.ros/log/2022-03-09-15-33-33-276616-computer-1876564
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [talker-1]: process started with pid [1876618]
[INFO] [listener-2]: process started with pid [1876620]
[talker-1] [INFO] [1646836414.794632135] [talker]: Publishing: 'Hello World: 1'
[listener-2] [INFO] [1646836414.795643603] [listener]: I heard: [Hello World: 1]
[talker-1] [INFO] [1646836415.794321203] [talker]: Publishing: 'Hello World: 2'
[listener-2] [INFO] [1646836415.795037146] [listener]: I heard: [Hello World: 2]
[...]
Removing the snap is simple too:
$ sudo snap remove ros2-talker-listener
Once done developing your snap, you can easily clean up the build environment:
$ snapcraft clean
Snaps are defined in a single YAML file placed in the root folder of your project. The following example shows the entire snapcraft.yaml file for an example project, ros2-talker-listener-core20. Don’t worry, we’ll break this down.
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]
apps:
ros2-talker-listener:
command: opt/ros/foxy/bin/ros2 launch demo_nodes_cpp talker_listener.launch.py
extensions: [ros2-foxy]
You can download the example repository with the following command:
$ git clone https://github.com/snapcraft-docs/ros2-talker-listener-core20
The snapcraft.yaml file starts with a small amount of human-readable metadata, which usually can be lifted from the GitHub description or project README.md. This data is used in the presentation of your app in the Snap Store (see e.g. the PlotJuggler front page).
name: ros2-talker-listener
version: '0.1'
summary: ROS 2 Talker/Listener Example
description: |
This example launches a ROS 2 talker and listener.
The name
must be unique in the Snap Store. Valid snap names consist of lower-case alphanumeric characters and hyphens. They cannot be all numbers and they also cannot start or end with a hyphen.
This is a declarative version of the packaged software and is not linked to the version of the snap itself. It’s also possible to write a script to calculate the version, or to take a tag or commit from a git repository.
The summary
can not exceed 79 characters. You can use a chevron ‘>’ in the description
key to declare a multi-line description.
For more information about top level metadata, see, top-level-metadata.
The base
keyword defines a special kind of snap that provides a run-time environment with a minimal set of libraries that are common to most applications. They’re transparent to users, but they need to be considered, and specified, when building a snap.
base: core20
core20 is the current standard base for snap building and is based on Ubuntu 20.04 LTS. It is therefore the base for ROS Noetic and ROS 2 Foxy snaps.
To get started, we won’t confine this application. Unconfined applications, specified with devmode
, can only be released to the “edge” channel.
confinement: devmode
For more information about security model, see, choosing-a-security-model.
Parts define how to build your app and can be anything: programs, libraries, or other assets needed to create and run your application. Their source can be local directories, remote git repositories, or tarballs. In this example, we have a single part: ros-demos.
Snapcraft relies on well known and well established ROS tools such as, in this example, colcon
.
Note: It is easy to forget the importance of complete install rules, i.e. rules for installing every component of the package necessary to run, or every component necessary to use a given library.
The packages you’re building must have install rules, or else snapcraft won’t know which components to place into the snap. Make sure you install binaries, libraries, header files, launch files, etc.
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]
For more details on colcon-specific metadata, see the colcon plugin documentation. For more information about general parts metadata, see parts-metadata.
Apps are the commands and services exposed to end users. Each entry under apps is the command name that should be exposed to the end users.
The command specifies the path to the binary to be run. This is resolved relative to the root of your snap contents.
apps:
ros2-talker-listener:
command: opt/ros/foxy/bin/ros2 launch demo_nodes_cpp talker_listener.launch.py
extensions: [ros2-foxy]
For more details about the ros2-foxy extension, see ros2-foxy extension.
In snap, an application is usually prefixed by the snap name so that the application my-app
from the snap my-snap
can be executed calling my-snap.my-app
. However, if both the snap and the app are called the same, as is the case in our ROS 2 example, the execution command collapses to avoid the tediousness of writing twice the same words. The command ros2-talker-listener.ros2-talker-listener
simply becomes ros2-talker-listener
.
After you’ve created the snapcraft.yaml, you can build the snap by simply executing the snapcraft command in the project directory:
$ snapcraft
Using 'snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Launching a VM.
[...]
Snapped ros2-talker-listener_0.1_amd64.snap
The warnings regarding missing libraries that you might see when building your snap are false positive. These libraries are build time dependencies only.
The resulting snap can be immediately installed. This requires the --dangerous
flag because the snap is not signed by the Snap Store. Furthermore, the --devmode
flag acknowledges that you are installing an unconfined application:
$ sudo snap install ros2-talker-listener_*.snap --devmode --dangerous
You can then try it out:
$ ros2-talker-listener
[INFO] [launch]: All log files can be found below /home/user/snap/ros2-talker-listener/x1/.ros/log/2022-03-09-15-33-33-276616-computer-1876564
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [talker-1]: process started with pid [1876618]
[INFO] [listener-2]: process started with pid [1876620]
[talker-1] [INFO] [1646836414.794632135] [talker]: Publishing: 'Hello World: 1'
[listener-2] [INFO] [1646836414.795643603] [listener]: I heard: [Hello World: 1]
[talker-1] [INFO] [1646836415.794321203] [talker]: Publishing: 'Hello World: 2'
[listener-2] [INFO] [1646836415.795037146] [listener]: I heard: [Hello World: 2]
[...]
Removing the snap is simple too:
$ sudo snap remove ros2-talker-listener
Once done developing your snap, you can easily clean up the build environment:
$ snapcraft clean
Snaps are defined in a single YAML file placed in the root folder of your project. The following example shows the entire snapcraft.yaml file for an example project, ros2-talker-listener-core22. Don’t worry, we’ll break this down.
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
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]
apps:
ros2-talker-listener:
command: opt/ros/humble/bin/ros2 launch demo_nodes_cpp talker_listener.launch.py
extensions: [ros2-humble]
You can download the example repository with the following command:
$ git clone https://github.com/snapcraft-docs/ros2-talker-listener-core22
The snapcraft.yaml file starts with a small amount of human-readable metadata, which usually can be lifted from the GitHub description or project README.md. This data is used in the presentation of your app in the Snap Store (see e.g. PlotJuggler front page).
name: ros2-talker-listener
version: '0.1'
summary: ROS 2 Talker/Listener Example
description: |
This example launches a ROS 2 talker and listener.
The name
must be unique in the Snap Store. Valid snap names consist of lower-case alphanumeric characters and hyphens. They cannot be all numbers and they also cannot start or end with a hyphen.
This is a declarative version of the packaged software and is not linked to the version of the snap itself. It’s also possible to write a script to calculate the version, or to take a tag or commit from a git repository.
The summary
can not exceed 79 characters. You can use a chevron ‘>’ in the description
key to declare a multi-line description.
For more information about top level metadata, see, top-level-metadata.
The base
keyword defines a special kind of snap that provides a run-time environment with a minimal set of libraries that are common to most applications. They’re transparent to users, but they need to be considered, and specified, when building a snap.
base: core22
core22 is the current standard base for snap building and is based on Ubuntu 22.04 LTS. It is therefore the base for ROS 2 Humble snaps.
To get started, we won’t confine this application. Unconfined applications, specified with devmode
, can only be released to the “edge” channel.
confinement: devmode
For more information about security model, see, choosing-a-security-model.
Parts define how to build your app and can be anything: programs, libraries, or other assets needed to create and run your application. Their source can be local directories, remote git repositories, or tarballs. In this example, we have a single part: ‘ros-demos’.
Snapcraft relies on well known and well established ROS tools such as, in this example, colcon
.
Note: It is easy to forget the importance of complete install rules, i.e. rules for installing every component of the package necessary to run, or every component necessary to use a given library.
The packages you’re building must have install rules, or else snapcraft won’t know which components to place into the snap. Make sure you install binaries, libraries, header files, launch files, etc.
parts:
ros-demos:
plugin: colcon
source: https://github.com/ros2/demos.git
source-branch: humble
colcon-packages: [demo_nodes_cpp]
stage-packages: [ros-humble-ros2launch]
For more details on colcon-specific metadata, see the colcon plugin documentation. For more information about general parts metadata, see, parts-metadata.
Apps are the commands and services exposed to end users. Each entry under apps is the command name that should be exposed to the end users.
The command specifies the path to the binary to be run. This is resolved relative to the root of your snap contents.
apps:
ros2-talker-listener:
command: opt/ros/humble/bin/ros2 launch demo_nodes_cpp talker_listener.launch.py
extensions: [ros2-humble]
For more details about the ‘ros2-humble’ extension, have a look at its documentation.
In snap, an application is usually prefixed by the snap name so that the application my-app
from the snap my-snap
can be executed calling my-snap.my-app
. However, if both the snap and the app are called the same, as is the case in our ROS 2 example, the execution command collapses to avoid the tediousness of writing twice the same words. The command ros2-talker-listener.ros2-talker-listener
simply becomes ros2-talker-listener
.
After you’ve created the snapcraft.yaml, you can build the snap by simply executing the snapcraft command in the project directory:
Due to a bug in the current version of Snapcraft, you will not be prompted to first install LXD if it’s not already installed, causing Snapcraft to hang indefinitely.
To install and initialise LXD, run the following:
sudo snap install lxd && sudo lxd init --auto
$ snapcraft
Launching instance...
[...]
Created snap package ros2-talker-listener_0.1_amd64.snap
The resulting snap can be immediately installed. This requires the --dangerous
flag because the snap is not signed by the Snap Store. Furthermore, the --devmode
flag acknowledges that you are installing an unconfined application:
$ sudo snap install ros2-talker-listener_*.snap --devmode --dangerous
You can then try it out:
$ ros2-talker-listener
[INFO] [launch]: All log files can be found below /home/user/snap/ros2-talker-listener/x1/ros/log/2022-07-08-14-47-49-370040-host-26782
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [talker-1]: process started with pid [27671]
[INFO] [listener-2]: process started with pid [27674]
[talker-1] [INFO] [1657306071.096406021] [talker]: Publishing: 'Hello World: 1'
[listener-2] [INFO] [1657306071.096756965] [listener]: I heard: [Hello World: 1]
[talker-1] [INFO] [1657306072.096312107] [talker]: Publishing: 'Hello World: 2'
[listener-2] [INFO] [1657306072.096541441] [listener]: I heard: [Hello World: 2]
[...]
Removing the snap is simple too:
$ sudo snap remove ros2-talker-listener
Once done developing your snap, you can easily clean up the build environment:
$ snapcraft clean
Snaps are defined in a single YAML file placed in the root folder of your project. The following example shows the entire snapcraft.yaml file for an example project, ros2-talker-listener-core24. Don’t worry, we’ll break this down.
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]
apps:
ros2-talker-listener:
command: ros2 launch demo_nodes_cpp talker_listener.launch.py
extensions: [ros2-jazzy]
You can download the example repository with the following command:
$ git clone https://github.com/snapcraft-docs/ros2-talker-listener-core24
The snapcraft.yaml file starts with a small amount of human-readable metadata, which usually can be lifted from the GitHub description or project README.md. This data is used in the presentation of your app in the Snap Store (see e.g. PlotJuggler front page).
name: ros2-talker-listener
version: '0.1'
summary: ROS 2 Talker/Listener Example
description: |
This example launches a ROS 2 talker and listener.
The name
must be unique in the Snap Store. Valid snap names consist of lower-case alphanumeric characters and hyphens. They cannot be all numbers and they also cannot start or end with a hyphen.
This is a declarative version of the packaged software and is not linked to the version of the snap itself. It’s also possible to write a script to calculate the version, or to take a tag or commit from a git repository.
The summary
can not exceed 79 characters. You can use a chevron ‘>’ in the description
key to declare a multi-line description.
For more information about top level metadata, see, top-level-metadata.
The base
keyword defines a special kind of snap that provides a run-time environment with a minimal set of libraries that are common to most applications. They’re transparent to users, but they need to be considered, and specified, when building a snap.
base: core24
core24 is the current standard base for snap building and is based on Ubuntu 24.04 LTS. It is therefore the base for ROS 2 Jazzy snaps.
To get started, we won’t confine this application. Unconfined applications, specified with devmode
, can only be released to the “edge” channel.
confinement: devmode
For more information about security model, see, choosing-a-security-model.
Parts define how to build your app and can be anything: programs, libraries, or other assets needed to create and run your application. Their source can be local directories, remote git repositories, or tarballs. In this example, we have a single part: ‘ros-demos’.
Snapcraft relies on well known and well established ROS tools such as, in this example, colcon
.
Note: It is easy to forget the importance of complete install rules, i.e. rules for installing every component of the package necessary to run, or every component necessary to use a given library.
The packages you’re building must have install rules, or else snapcraft won’t know which components to place into the snap. Make sure you install binaries, libraries, header files, launch files, etc.
parts:
ros-demos:
plugin: colcon
source: https://github.com/ros2/demos.git
source-branch: humble
colcon-packages: [demo_nodes_cpp]
stage-packages: [ros-jazzy-ros2launch]
For more details on colcon-specific metadata, see the colcon plugin documentation. For more information about general parts metadata, see, parts-metadata.
Apps are the commands and services exposed to end users. Each entry under apps is the command name that should be exposed to the end users.
The command specifies the path to the binary to be run. This is resolved relative to the root of your snap contents.
apps:
ros2-talker-listener:
command: opt/ros/jazzy/bin/ros2 launch demo_nodes_cpp talker_listener.launch.py
extensions: [ros2-jazzy]
For more details about the ‘ros2-jazzy’ extension, have a look at its documentation.
In snap, an application is usually prefixed by the snap name so that the application my-app
from the snap my-snap
can be executed calling my-snap.my-app
. However, if both the snap and the app are called the same, as is the case in our ROS 2 example, the execution command collapses to avoid the tediousness of writing twice the same words. The command ros2-talker-listener.ros2-talker-listener
simply becomes ros2-talker-listener
.
After you’ve created the snapcraft.yaml, you can build the snap by simply executing the snapcraft command in the project directory:
Due to a bug in the current version of Snapcraft, you will not be prompted to first install LXD if it’s not already installed, causing Snapcraft to hang indefinitely.
To install and initialise LXD, run the following:
sudo snap install lxd && sudo lxd init --auto
$ snapcraft
Launching instance...
[...]
Created snap package ros2-talker-listener_0.1_amd64.snap
The resulting snap can be immediately installed. This requires the --dangerous
flag because the snap is not signed by the Snap Store. Furthermore, the --devmode
flag acknowledges that you are installing an unconfined application:
$ sudo snap install ros2-talker-listener_*.snap --devmode --dangerous
You can then try it out:
$ ros2-talker-listener
[INFO] [launch]: All log files can be found below /home/user/snap/ros2-talker-listener/x1/ros/log/2022-07-08-14-47-49-370040-host-26782
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [talker-1]: process started with pid [27671]
[INFO] [listener-2]: process started with pid [27674]
[talker-1] [INFO] [1657306071.096406021] [talker]: Publishing: 'Hello World: 1'
[listener-2] [INFO] [1657306071.096756965] [listener]: I heard: [Hello World: 1]
[talker-1] [INFO] [1657306072.096312107] [talker]: Publishing: 'Hello World: 2'
[listener-2] [INFO] [1657306072.096541441] [listener]: I heard: [Hello World: 2]
[...]
Removing the snap is simple too:
$ sudo snap remove ros2-talker-listener
Once done developing your snap, you can easily clean up the build environment:
$ snapcraft clean
The bases core20, core22 and core24 also offer the possibility to build your ROS snap using snaps’ content-sharing feature. This allows for sharing the common ROS 2 packages across multiple snaps avoiding duplicates and thus saving space and making sure the same ROS 2 packages versions are used throughout your entire stack when deployed as multiple snaps.
Re-using the example given in the core20 section, applying content sharing is as simple as changing the declared snapcraft extension to be used. In the snapcraft.yaml file, look for the entry extensions: [ros2-foxy]
and replace it with extensions: [ros2-foxy-ros-base]
or any other Foxy content-sharing extension listed on the dedicated documentation page. But let us look at the whole snapcraft.yaml file below and examine the few differences.
name: ros2-talker-listener
version: '0.1'
summary: ROS 2 Talker/Listener Example using snaps’ content-sharing
description: |
This example launches a ROS 2 talker and listener.
The ROS 2 libraries are provided by a second snap through content-sharing.
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]
apps:
ros2-talker-listener:
command: ros2 launch demo_nodes_cpp talker_listener.launch.py
- extensions: [ros2-foxy]
+ extensions: [ros2-foxy-ros-base]
Going through the file, the first difference we can notice, besides the snaps description, is that there are no more stage-packages
. That is because while the previous example needed to stage ros2launch
so that it is available within the snap, in this case ros2launch
is already available in the content-sharing snap.
The second difference we can notice is the extension used in the ‘ros-demos
’ part as pointed out earlier.
From there, you may now go on following the core20 tutorial building and installing the snap. However, before launching the app for the first time, we encounter our last difference. Since our application snap makes use of the content provided by another snap, we have to connect them. To do so, enter the following,
snap connect ros2-talker-listener:ros-foxy ros-foxy-ros-base
We can verify that the connection has indeed been established,
$ snap connections ros2-talker-listener
Interface Plug Slot Notes
content[ros-humble] ros2-talker-listener:ros-foxy ros-foxy-ros-base:ros-foxy manual
…
Making use of content-sharing for ROS 2 is nearly seamless. Note that while detailing what content-sharing is and how does it compare to not using it is out of the scope of this hands-on example, the interested reader can find more information at both the content-sharing documentation page as well as at the ROS architectures with snaps documentation pages.
After you’ve created the snapcraft.yaml
, you can build the snap by simply executing the snapcraft command in the project directory:
The snapcraft ROS content-sharing extension is currently marked as experimental. We enable experimental extensions with the environment variable: SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS
.
$ SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1 snapcraft
Launching instance...
[...]
Created snap package ros2-talker-listener_0.1_amd64.snap
The resulting snap can be immediately installed. This requires the --dangerous
flag because the snap is not signed by the Snap Store. Furthermore, the --devmode
flag acknowledges that you are installing an unconfined application:
$ sudo snap install ros2-talker-listener_*.snap --devmode --dangerous
You can then try it out:
$ ros2-talker-listener
[INFO] [launch]: All log files can be found below /home/user/snap/ros2-talker-listener/x1/ros/log/2022-07-08-14-47-49-370040-host-26782
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [talker-1]: process started with pid [27671]
[INFO] [listener-2]: process started with pid [27674]
[talker-1] [INFO] [1657306071.096406021] [talker]: Publishing: 'Hello World: 1'
[listener-2] [INFO] [1657306071.096756965] [listener]: I heard: [Hello World: 1]
[talker-1] [INFO] [1657306072.096312107] [talker]: Publishing: 'Hello World: 2'
[listener-2] [INFO] [1657306072.096541441] [listener]: I heard: [Hello World: 2]
[...]
Re-using the example given in core22, applying content sharing is as simple as changing the declared snapcraft extension to be used. In the snapcraft.yaml file, look for the entry extensions: [ros2-humble]
and replace it with extensions: [ros2-humble-base]
or any other Humble content-sharing extension listed on the dedicated documentation page. But let us look at the whole snapcraft.yaml file below and examine the few differences.
name: ros2-talker-listener
version: '0.1'
summary: ROS 2 Talker/Listener Example using snaps’ content-sharing
description: |
This example launches a ROS 2 talker and listener.
The ROS 2 libraries are provided by a second snap through content-sharing.
confinement: devmode
base: core22
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]
apps:
ros2-talker-listener:
command: ros2 launch demo_nodes_cpp talker_listener.launch.py
- extensions: [ros2-humble]
+ extensions: [ros2-humble-ros-base]
Going through the file, the first difference we can notice, besides the snaps description, is that there are no more stage-packages
. That is because while the previous example needed to stage ros2launch
so that it is available within the snap, in this case ros2launch
is already available in the content-sharing snap.
The second difference we can notice is the extension used in the ‘ros-demos
’ part as pointed out earlier.
From there, you may now go on following the core22 tutorial building and installing the snap. However, before launching the app for the first time, we encounter our last difference. Since our application snap makes use of the content provided by another snap, we have to connect them. To do so, enter the following,
snap connect ros2-talker-listener:ros-humble-ros-base ros-humble-ros-base:ros-humble-ros-base
We can verify that the connection has indeed been established,
$ snap connections ros2-talker-listener
Interface Plug Slot Notes
content[ros-humble] ros2-talker-listener:ros-humble-ros-base ros-humble-ros-base:ros-humble-ros-base manual
…
Making use of content-sharing for ROS 2 is nearly seamless. Note that while detailing what content-sharing is and how does it compare to not using it is out of the scope of this hands-on example, the interested reader can find more information at both the content-sharing documentation page as well as at the ROS architectures with snaps documentation pages.
After you’ve created the snapcraft.yaml
, you can build the snap by simply executing the snapcraft command in the project directory:
The snapcraft ROS content-sharing extension is currently marked as experimental. We enable experimental extensions with the environment variable: SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS
.
$ SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1 snapcraft
Launching instance...
[...]
Created snap package ros2-talker-listener_0.1_amd64.snap
The resulting snap can be immediately installed. This requires the --dangerous
flag because the snap is not signed by the Snap Store. Furthermore, the --devmode
flag acknowledges that you are installing an unconfined application:
$ sudo snap install ros2-talker-listener_*.snap --devmode --dangerous
You can then try it out:
$ ros2-talker-listener
[INFO] [launch]: All log files can be found below /home/user/snap/ros2-talker-listener/x1/ros/log/2022-07-08-14-47-49-370040-host-26782
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [talker-1]: process started with pid [27671]
[INFO] [listener-2]: process started with pid [27674]
[talker-1] [INFO] [1657306071.096406021] [talker]: Publishing: 'Hello World: 1'
[listener-2] [INFO] [1657306071.096756965] [listener]: I heard: [Hello World: 1]
[talker-1] [INFO] [1657306072.096312107] [talker]: Publishing: 'Hello World: 2'
[listener-2] [INFO] [1657306072.096541441] [listener]: I heard: [Hello World: 2]
[...]
Re-using the example given in core24, applying content sharing is as simple as changing the declared snapcraft extension to be used. In the snapcraft.yaml file, look for the entry extensions: [ros2-jazzy]
and replace it with extensions: [ros2-jazzy-base]
or any other Jazzy content-sharing extension listed on the dedicated documentation page. But let us look at the whole snapcraft.yaml file below and examine the few differences.
name: ros2-talker-listener
version: '0.1'
summary: ROS 2 Talker/Listener Example using snaps’ content-sharing
description: |
This example launches a ROS 2 talker and listener.
The ROS 2 libraries are provided by a second snap through content-sharing.
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]
apps:
ros2-talker-listener:
command: ros2 launch demo_nodes_cpp talker_listener.launch.py
- extensions: [ros2-jazzy]
+ extensions: [ros2-jazzy-ros-base]
Going through the file, the first difference we can notice, besides the snaps description, is that there are no more stage-packages
. That is because while the previous example needed to stage ros2launch
so that it is available within the snap, in this case ros2launch
is already available in the content-sharing snap.
The second difference we can notice is the extension used in the ‘ros-demos
’ part as pointed out earlier.
From there, you may now go on following the core24 tutorial building and installing the snap. However, before launching the app for the first time, we encounter our last difference. Since our application snap makes use of the content provided by another snap, we have to connect them. To do so, enter the following,
snap connect ros2-talker-listener:ros-jazzy-ros-base ros-jazzy-ros-base:ros-jazzy-ros-base
We can verify that the connection has indeed been established,
$ snap connections ros2-talker-listener
Interface Plug Slot Notes
content[ros-jazzy] ros2-talker-listener:ros-jazzy-ros-base ros-jazzy-ros-base:ros-jazzy-ros-base manual
…
Making use of content-sharing for ROS 2 is nearly seamless. Note that while detailing what content-sharing is and how does it compare to not using it is out of the scope of this hands-on example, the interested reader can find more information at both the content-sharing documentation page as well as at the ROS architectures with snaps documentation pages.
After you’ve created the snapcraft.yaml
, you can build the snap by simply executing the snapcraft command in the project directory:
The snapcraft ROS content-sharing extension is currently marked as experimental. We enable experimental extensions with the environment variable: SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS
.
$ SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1 snapcraft
Launching instance...
[...]
Created snap package ros2-talker-listener_0.1_amd64.snap
The resulting snap can be immediately installed. This requires the --dangerous
flag because the snap is not signed by the Snap Store. Furthermore, the --devmode
flag acknowledges that you are installing an unconfined application:
$ sudo snap install ros2-talker-listener_*.snap --devmode --dangerous
You can then try it out:
$ ros2-talker-listener
[INFO] [launch]: All log files can be found below /home/user/snap/ros2-talker-listener/x1/ros/log/2022-07-08-14-47-49-370040-host-26782
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [talker-1]: process started with pid [27671]
[INFO] [listener-2]: process started with pid [27674]
[talker-1] [INFO] [1657306071.096406021] [talker]: Publishing: 'Hello World: 1'
[listener-2] [INFO] [1657306071.096756965] [listener]: I heard: [Hello World: 1]
[talker-1] [INFO] [1657306072.096312107] [talker]: Publishing: 'Hello World: 2'
[listener-2] [INFO] [1657306072.096541441] [listener]: I heard: [Hello World: 2]
[...]
To share your snaps you need to publish them in the Snap Store. First, create an account on the dashboard. Here you can customise how your snaps are presented, review your uploads and control publishing.
You’ll need to choose a unique “developer namespace” as part of the account creation process. This name will be visible by users and associated with your published snaps.
Make sure the snapcraft
command is authenticated using the email address attached to your Snap Store account:
$ snapcraft login
You can publish your own version of a snap, provided you do so under a name you have rights to. You can register a name on dashboard.snapcraft.io, or by running the following command:
$ snapcraft register myrossnap
Be sure to update the name:
in your snapcraft.yaml
to match this registered name, then run snapcraft
again.
Use snapcraft to push the snap to the Snap Store.
$ snapcraft upload --release=edge myrossnap_*.snap
If you’re happy with the result, you can commit the snapcraft.yaml to your GitHub repo and turn on automatic builds so any further commits automatically get released to edge, without requiring you to manually build locally.
Congratulations! You’ve just built and published your first ROS snap. For a more in-depth overview of the snap building process, see Creating a snap.
Last updated 3 months ago.