Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 64 additions & 11 deletions docs/how-to/integrations/craft-an-ros-2-app.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ unique when crafting a `ROS 2 <https://docs.ros.org/en/rolling/index.html>`__-ba
snap. We'll work through the aspects unique to ROS 2 apps by examining an existing
project.

There are four supported bases for ROS 2 -- core24, core22, core20, and core18.
There are five supported bases for ROS 2 -- core26, core24, core22, core20, and core18.


.. _how-to-craft-an-ros-2-app-project-files:
Expand All @@ -20,8 +20,8 @@ Example project file for ROS 2 Talker/Listener

.. tab-item:: core18

The following code comprises the project file for the `core18 version of ROS 2
Talker/Listener <https://github.com/snapcraft-docs/ros2-talker-listener>`_.
The following code comprises the `snapcraft.yaml` file for the core18 version
of a ROS 2 Talker/Listener.

.. dropdown:: Code

Expand Down Expand Up @@ -53,8 +53,8 @@ Example project file for ROS 2 Talker/Listener
.. tab-item:: core20
:sync: core20

The following code comprises the project file for the `core20 version of ROS 2
Talker/Listener <https://github.com/snapcraft-docs/ros2-talker-listener-core20>`_.
The following code comprises the `snapcraft.yaml` file for the core20 version
of a ROS 2 Talker/Listener.

.. dropdown:: Code

Expand Down Expand Up @@ -86,8 +86,8 @@ Example project file for ROS 2 Talker/Listener
.. tab-item:: core22
:sync: core22

The following code comprises the project file for the `core22 version of ROS 2
Talker/Listener <https://github.com/snapcraft-docs/ros2-talker-listener-core22>`_.
The following code comprises the `snapcraft.yaml` file for the core22 version
of a ROS 2 Talker/Listener.

.. dropdown:: Code

Expand Down Expand Up @@ -119,8 +119,8 @@ Example project file for ROS 2 Talker/Listener
.. tab-item:: core24
:sync: core24

The following code comprises the project file for the `core24 version of ROS 2
Talker/Listener <https://github.com/snapcraft-docs/ros2-talker-listener-core20>`_.
The following code comprises the `snapcraft.yaml` file for the core24 version
of a ROS 2 Talker/Listener.

.. dropdown:: Code

Expand Down Expand Up @@ -149,8 +149,40 @@ Example project file for ROS 2 Talker/Listener
command: ros2 launch demo_nodes_cpp talker_listener.launch.py
extensions: [ros2-jazzy]

.. tab-item:: core26
:sync: core26

Add an ROS 2 app
The following code comprises the `snapcraft.yaml` file for the core26 version
of a ROS 2 Talker/Listener.

.. dropdown:: Code

.. code-block:: yaml
:caption: snapcraft.yaml

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: core26

parts:
ros-demos:
plugin: colcon
source: https://github.com/ros2/demos.git
source-branch: lyrical
source-subdir: demo_nodes_cpp
stage-packages: [ros-lyrical-ros2launch]

apps:
ros2-talker-listener:
command: ros2 launch demo_nodes_cpp talker_listener.launch.py
extensions: [ros2-lyrical]

Add a ROS 2 app
----------------

ROS 2 apps depend on special extensions that initialize the build- and run-time
Expand All @@ -174,6 +206,8 @@ To add an ROS 2 app:
- :ref:`ros2-humble <reference-ros-2-extensions>`
* - core24
- :ref:`ros2-jazzy <reference-ros-2-extensions>`
* - core26
- :ref:`ros2-lyrical <reference-ros-2-extensions>`


Add a part written for ROS 2
Expand Down Expand Up @@ -207,6 +241,8 @@ To add an ROS 2 part:
- ros-humble-ros2launch
* - core24
- ros-jazzy-ros2launch
* - core26
- ros-lyrical-ros2launch


Handle build issues
Expand All @@ -225,7 +261,7 @@ false positives. These libraries are build time dependencies only.
Share content between ROS 2 snaps
---------------------------------

The core20, core22 and core24 bases also offer the option to build your ROS snap using
The core20, core22, core24 and core26 bases also offer the option to build your ROS snap using
the `content-sharing interface <https://snapcraft.io/docs/content-interface>`_. It
shares the ROS 2 content packages across multiple snaps, saving space and ensuring
package consistency throughout your snap build environment.
Expand Down Expand Up @@ -284,6 +320,21 @@ difference in the project file when content sharing is enabled:
- extensions: [ros2-jazzy]
+ extensions: [ros2-jazzy-ros-base]

.. tab-item:: core26
:sync: core26

.. code-block:: diff
:caption: snapcraft.yaml

source-subdir: demo_nodes_cpp
- stage-packages: [ros-lyrical-ros2launch]

apps:
ros2-talker-listener:
command: ros2 launch demo_nodes_cpp talker_listener.launch.py
- extensions: [ros2-lyrical]
+ extensions: [ros2-lyrical-ros-base]

To turn on content sharing:

#. Remove the ``stage-packages`` key from the part. The package is already available in
Expand All @@ -302,6 +353,8 @@ To turn on content sharing:
- :ref:`ros2-humble-ros-base <reference-ros-2-content-extensions>`
* - core24
- :ref:`ros2-jazzy-ros-base <reference-ros-2-content-extensions>`
* - core26
- :ref:`ros2-lyrical-ros-base <reference-ros-2-content-extensions>`


Because the snap makes use of the content provided by another snap, you must connect
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Diff between snapcraft.yaml and `snapcraft expand-extensions`, showing the differences
# that the ROS 2 Lyrical extension applies to a project file.
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: core26

parts:
ros-demos:
plugin: colcon
source: https://github.com/ros2/demos.git
source-branch: lyrical
source-subdir: demo_nodes_cpp
stage-packages:
- ros-lyrical-ros2launch
+ build-environment:
+ - ROS_VERSION: "2"
+ - ROS_DISTRO: lyrical
+ ros2-lyrical/ros2-launch:
+ source: /snap/snapcraft/current/share/snapcraft/extensions/ros2
+ plugin: make
+ build-packages:
+ - ros-lyrical-ros-environment
+ - ros-lyrical-ros-workspace
+ - ros-lyrical-ament-index-cpp
+ - ros-lyrical-ament-index-python

apps:
ros2-talker-listener:
command: ros2 launch demo_nodes_cpp talker_listener.launch.py
- extensions:
- - ros2-lyrical
+ environment:
+ ROS_VERSION: "2"
+ ROS_DISTRO: lyrical
+ PYTHONPATH: $SNAP/opt/ros/lyrical/lib/python3.14/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:
+ - resolute
+
+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.14.so*
+ - usr/lib/*libspdlog.so*
+ - usr/lib/*libtinyxml2.so*
6 changes: 6 additions & 0 deletions docs/reference/extensions/ros-2-content-extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ with the format ``ros2-<version>-<metapackage>``. The available extensions are:
- ``ros2-jazzy-ros-base``
- ``ros2-jazzy-desktop``

.. tab-item:: ROS 2 Lyrical

- ``ros2-lyrical-ros-core``
- ``ros2-lyrical-ros-base``
- ``ros2-lyrical-desktop``

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


Expand Down
88 changes: 84 additions & 4 deletions docs/reference/extensions/ros-2-extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ROS 2 extensions
The ROS 2 extensions, helps fill in common settings for software built with the `ROS 2
<https://ros.org>`_ libraries.

There are three extensions in this family, each for a different version of ROS 2.
There are four extensions in this family, each for a different version of ROS 2.

.. list-table::

Expand All @@ -31,9 +31,14 @@ There are three extensions in this family, each for a different version of ROS 2
- :ref:`ROS 2 Jazzy Jalisco <reference-ros-2-content-extensions>`
- core24

* - ROS 2 Lyrical
- ``ros2-lyrical``
- :ref:`ROS 2 Lyrical Luth <reference-ros-2-content-extensions>`
- core26

:ref:`Experimental extensions enabled <how-to-enable-experimental-extensions>`

All three extensions require Snapcraft 7.3 or higher.
All four extensions require Snapcraft 7.3 or higher.


Included parts
Expand Down Expand Up @@ -69,7 +74,7 @@ The extension adds its own part to the project, which pulls in the ROS 2 build p
:caption: snapcraft.yaml

ros2-humble/ros2-launch:
source: /snap/snapcraft/13181/share/snapcraft/extensions/ros2
source: /snap/snapcraft/current/share/snapcraft/extensions/ros2
plugin: make
build-packages:
- ros-humble-ros-environment
Expand All @@ -86,14 +91,31 @@ The extension adds its own part to the project, which pulls in the ROS 2 build p
:caption: snapcraft.yaml

ros2-jazzy/ros2-launch:
source: /snap/snapcraft/13181/share/snapcraft/extensions/ros2
source: /snap/snapcraft/current/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

.. tab-item:: ROS 2 Lyrical
:sync: lyrical

.. dropdown:: Included parts

.. code-block:: yaml
:caption: snapcraft.yaml

ros2-lyrical/ros2-launch:
source: /snap/snapcraft/current/share/snapcraft/extensions/ros2
plugin: make
build-packages:
- ros-lyrical-ros-environment
- ros-lyrical-ros-workspace
- ros-lyrical-ament-index-cpp
- ros-lyrical-ament-index-python


Included build environment variables
------------------------------------
Expand Down Expand Up @@ -139,6 +161,18 @@ variables.
- ROS_VERSION: "2"
- ROS_DISTRO: jazzy

.. tab-item:: ROS 2 Lyrical
:sync: lyrical

.. dropdown:: Included build environment variables

.. code-block:: yaml
:caption: snapcraft.yaml

build-environment:
- ROS_VERSION: "2"
- ROS_DISTRO: lyrical


Included runtime environment settings
-------------------------------------
Expand Down Expand Up @@ -197,6 +231,22 @@ ROS 2 before launching the app, similar to sourcing the typical ROS 2
command-chain:
- snap/command-chain/ros2-launch

.. tab-item:: ROS 2 Lyrical
:sync: lyrical

.. dropdown:: Included runtime environment settings

.. code-block:: yaml
:caption: snapcraft.yaml

environment:
ROS_VERSION: "2"
ROS_DISTRO: lyrical
PYTHONPATH: $SNAP/opt/ros/lyrical/lib/python3.14/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
-----------------------------
Expand Down Expand Up @@ -267,6 +317,26 @@ installs the necessary GPG key.
suites:
- noble

.. tab-item:: ROS 2 Lyrical
:sync: lyrical

.. dropdown:: Included package repositories

.. code-block:: yaml
:caption: snapcraft.yaml

package-repositories:
- type: apt
url: http://packages.ros.org/ros2/ubuntu
components:
- main
formats:
- deb
key-id: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
key-server: keyserver.ubuntu.com
suites:
- resolute


Example expanded project file
-----------------------------
Expand Down Expand Up @@ -313,3 +383,13 @@ The files are based on the :ref:`ros2-talker-listener
:language: diff
:lines: 3-
:emphasize-lines: 18-28, 33-41, 43-53

.. tab-item:: ROS 2 Lyrical
:sync: lyrical

.. dropdown:: Expanded project file for ros2-talker-listener

.. literalinclude:: code/ros-2-lyrical-extension-talker-listener-expanded.diff
:language: diff
:lines: 3-
:emphasize-lines: 18-28, 33-41, 43-53
Loading
Loading