Example ROS 1 app

This how-to guide covers the steps, decisions, and implementation details that are unique when crafting a ROS 1-based snap. We’ll work through the aspects unique to ROS 1 apps by examining an existing recipe.

There are two supported bases for ROS 1 – core20 and core18.

Tip

Often, ROS developers rely on the devel space of their catkin workspace. As a result, it’s easy to forget the importance of complete install rules, such as rules for installing every component of the package necessary to run, or every component necessary to use a given library.

The catkin 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 necessary binaries, libraries, header files, and launch files.

Example recipe for ROS Talker/Listener

ROS Talker/Listener example

The following code comprises the recipe for the core20 version of ROS Talker/Listener.

Code
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

apps:
ros-talker-listener:
  command: opt/ros/noetic/bin/roslaunch roscpp_tutorials talker_listener.launch
  extensions: [ros1-noetic]

Add an ROS 1 app based on core20

To add an ROS 1 app based on core20:

  1. Declare the general app keys, such as command.

  2. For extensions, list ros1-noetic. See The ROS 1 Noetic Extension for a description of what the extension does during build.

Add a part written for ROS 1

ROS 1 parts are built with the catkin plugin.

To add an ROS 1 part:

  1. Declare the general part keys, such as source, override-build, build-packages, and so on.

  2. Set plugin: catkin.

  3. If the snap is based on core20, for catkin-packages, list any ROS package dependencies.