ROS2 foxy stable extension or ROS2 galactic extension

Hi, ros2 foxy is currently an experimental extension. Can anyone tell me when there will a stable release. Also ROS2 foxy has a lot of issues in its rosbag. So everyone is migrating to galactic. So is there any plans for a ros2-galactic extension for snapcraft?

Hi @rahul-tt,

Indeed the Foxy extension has been out for a while and we could reconsider its ‘experimental-ness’ . I’ll look into it.

Concerning Galactic, there is no plan at the moment to formally support it with an extension since Galactic is not an LTS. This being said, you still can build a Galactic-based snap. Please find below an example of such hello-world-like snap based on ROS 2 Galactic with a couple notes. Let me know if you need further info.

#
# This example is based on the online tutorial,
# "How to build a snap using ROS 2 Foxy"
# which can be found at,
# https://snapcraft.io/blog/how-to-build-a-snap-using-ros-2-foxy
#
# We will follow the tutorial and simply edit the 'snapcraft.yaml' file.
# The rest of the tutorial remains valid.
#
# For convenience, snapcraft ships with ROS 'extensions' easing the development of ROS 1&2 snaps.
# Said extensions simply take care of filling up some boiler-plate code in the 'snapcraft.yaml' file.
# Considering the ROS 2 Foxy distro,
# the extension is called 'ros2-foxy' (see e.g. the 'ros2-talker-listener' part of the example).
#
# One can expand an extension as to see what boiler plate code it inject.
# Given a 'snapcraft.yaml' file with an extension, this can be done with the command:
#
# $ snapcraft expand-extensions
#
# The command prints a fully expanded 'snapcraft.yaml' file.
# Note that if several extensions are used, they all are going to be expanded.
# Furthermore, since the 'ros2-foxy' extension is experimental, append the following flag,
#
# $ snapcraft expand-extensions --enable-experimental-extensions
#
# The following 'snapcraft.yaml' content is a copy of the original expanded file.
# The ROS 2 version is changed from foxy to galactic where necessary,
# more specifically in the environment variables, build/stage-package name and absolute paths.
#
# As usual, build the snap with e.g.
#
# $ snapcraft
#
# Mind that the '--enable-experimental-extensions' flag is not required anymore since
# we are not using the 'ros2-foxy' extension anymore.

name: ros2-talker-listener
version: '0.1'
summary: ROS2 Talker/Listener Example
description: |
  This example launches a ROS2 talker and listener.

grade: devel
confinement: strict
base: core20

package-repositories:
- components: [main]
  formats: [deb]
  key-id: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
  key-server: keyserver.ubuntu.com
  suites: [focal]
  type: apt
  url: http://repo.ros2.org/ubuntu/main

parts:
  ros2-galactic-extension:
    build-packages: [ros-galactic-ros-core]
    override-build: install -D -m 0755 launch ${SNAPCRAFT_PART_INSTALL}/snap/command-chain/ros2-launch
    plugin: nil
    source: $SNAPCRAFT_EXTENSIONS_DIR/ros2

  ros-demos:
    after: [ros2-galactic-extension]
    plugin: colcon
    source: https://github.com/ros2/demos.git
    source-branch: galactic
    source-subdir: demo_nodes_cpp
    build-packages: [make, gcc, g++]
    stage-packages: [ros-galactic-ros2launch]
    build-environment:
    - ROS_VERSION: '2'
    - ROS_DISTRO: galactic

apps:
  ros2-talker-listener:
    command: opt/ros/galactic/bin/ros2 launch demo_nodes_cpp talker_listener.launch.py
    plugs: [network, network-bind]
    command-chain: [snap/command-chain/ros2-launch]
    environment:
      PYTHONPATH: $SNAP/opt/ros/galactic/lib/python3.8/site-packages:$SNAP/usr/lib/python3/dist-packages:${PYTHONPATH}
      ROS_DISTRO: galactic
      ROS_VERSION: '2'

Thank you very much. Now i dont have to depend on the extension for future ros2 os

Totally up to you, but note that there will be a Humble extension tho.

I followed along with the above, and the only glitch was this at the end of the snapping:

Priming ros-demos
+ snapcraftctl prime
This part is missing libraries that cannot be satisfied with any available stage-packages known to snapcraft:
- usr/lib/x86_64-linux-gnu/libpsm_infinipath.so.1
These dependencies can be satisfied via additional parts or content sharing. Consider validating configured filesets if this dependency was built.
Snapping |                                                                                                                                              
Snapped ros2-talker-listener_0.1_amd64.snap

so I guess one would add something under “stage-packages:”, yes?

Followup: I examined the final snap and it has the following libpsm-related contents:

./usr/lib/libpsm1/libpsm_infinipath.so.1.16 ./usr/lib/x86_64-linux-gnu/libpsm2.so.2 ./usr/lib/x86_64-linux-gnu/libpsm2.so.2.1

Given that the diagnostic appears to be complaining about a missing usr/lib/x86_64-linux-gnu/libpsm_infinipath.so.1, is the right approach to simply manually create the symlink for that shared lib?

By using the exact snapcraft.yaml file that @artivis gave, I couldn’t reproduce your exact warning.

From this post, it appears that libpsm-infinipath1 uses a mechanism not supported by snapcraft (hence no symlink is created).

If the library is correctly listed in your stage-package, I would recommand writing the symlink yourself then (as suggested here).

Hi @artivis,

when i added ros2 extension , I was not able to build the snap using remote build. “snapcraft remote-build --build-on=arm64”

It gives an error: Failed to pull source: unable to determine source type of ‘$SNAPCRAFT_EXTENSIONS_DIR/ros2’. Check that the URL is correct or consider specifying source-type for this part. See snapcraft help sources for more information.

Do you know how i can solve this issue?