Help us make these docs great!

All rapyuta.io docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Preinstalled Runtime

A ROS publisher is part of a ROS package. It is a public git repository, which is built into a running docker container on the fly when the package is being deployed. A ROS subscriber is also a part of the same ROS package. It is downloaded on a device and is launched when the package is deployed.

Learning objectives

The tutorial will show you how to deploy a basic ROS package with a ROS publisher running on the cloud and a ROS subscriber running on a device such as Raspberry PI.

Prerequisites

  1. Device requirements

    1. You should have access to a device (computer or Raspberry PI 2 or 3) with an internet connection.
    2. Ensure that the Google Chrome browser is installed on the computer.
    3. Ensure that the ROS Melodic Morenia is installed on the device.
  2. You should be familiar with the rapyuta.io platform concept

  3. You should be familiar with the below tools:

    1. Git
    2. UNIX/LINUX command terminal
    3. ROS topics
    4. ROS services

Estimated time

15 minutes

Tutorial Video

ROS publisher and subscriber with Pre-installed Runtime

Preparing your device

The tutorial will use Raspberry PI as the device. Learn how to prepare your Raspberry PI

If you are using the custom rapyuta.io image on the device, the catkin workspace is already created for you, and the io_tutorials repository is already present in the workspace. Moreover, the source code is already built for you.

In this tutorial, the catkin workspace is ~/catkin_ws/, but you may choose to name your catkin workspace as you like and ensure that you replace all occurrences to ~/catkin_ws/ with your workspace name.

If your device is a computer with ROS installed on it or a Raspberry PI without a custom rapyuta.io image, you will create a catkin workspace and get the io_tutorials repository into that workspace.

Hence, to create a catkin workspace, you have to execute the below commands at the device terminal.

cd $HOME
mkdir -p catkin_ws/src
cd catkin_ws/src
git clone https://github.com/rapyuta/io_tutorials
source /opt/ros/melodic/setup.bash
cd ..

For the custom rapyuta.io image to support the build command, catkin build, you will set up the device by executing the following:

cd $HOME && 
mv catkin_ws catkin_old && 
curl https://storage.googleapis.com/artifacts.rapyuta.io/io_tutorials/catkin_ws_arm32v7.tar.gz | tar xz

The argument to the curl command, i.e., the URL address, changes based on the architecture of the device.

To build the source code in the catkin workspace, execute the below command in the root of the workspace:

catkin build listener

If you experience an error catkin:command not found, then the python-catkin-tools package is missing on the device, which is required for executing catkin build command. Install the package by running sudo apt-get install python-catkin-tools at the terminal.

Setting up your device

To onboard a device, click here. Ensure that you do not select the Use docker compose as default runtime checkbox while adding the device.

Creating the build

To create the build, follow the below steps. Skip the following steps if you have already created an io-tutorials build earlier.

  1. On the left navigation bar, click Development>Builds
  2. Click on ADD NEW BUILD
  3. In the Build Name box, enter a name for the build , for example, io-tutorials
  4. In the Git repository box, enter the URL address : https://github.com/rapyuta/io_tutorials and select Build Recipe as Catkin.
  5. Go to the next step and click on next, the build will be created.

The build takes about two to five minutes to build the source code in the io_tutorials repository into a running docker container. You may analyze the corresponding build logs, which helps in debugging failed builds. Please proceed to the creation of the package once the build is complete.

Creating the package

To create a package using the console, follow the steps:

  1. On the left navigation bar, click Development > Packages.
  2. Click ADD NEW PACKAGE.
  3. In the Package Name box, type in a name for the package, for example, ROS publisher subscriber.
  4. In the Package Version box, enter the version of the package you are creating. The default value is 1.0.0
  5. Make sure Is singleton package is not selected.
  6. Ensure Is a bindable package is selected.
  7. In the Description box, provide a summary of the package.
  8. Click NEXT.

The package has two components: the talker running on the cloud and the listener running on the device.

  1. Talker component (aka ROS publisher)
    1. In the Component Name box, enter a name for the component, for example, talker

      The name of a component must consist of alphabets [A-Z, a-z], digits [0-9], hyphen - and an underscore _ character. It must not begin with a digit.

    2. For Component Runtime, click Cloud.

    3. Ensure Is ROS Component is selected.

    4. Set the value of Replicas to run the component number 1 (default value).

    5. In the Executable Name box, enter a name for the executable , for example, talkerExecutable

      The name of an executable must consist of alphabets [A-Z, a-z], digits[0-9], hyphen - and an underscore _ character, and must not start with a digit.

    6. For Executable Type, click on Development>Builds.

    7. In the Choose Build select the Build io-tutorials from the drop-down list.

    8. In the Command to run in the docker container box, enter the command:

      roslaunch talker talker.launch
      

      Ensure you always execute the command roslaunch to explicitly start the ROS Master instead of running the rosrun command, because the ROS Master will fail to start on rosrun, and eventually, the deployment will fail as well. talkerExecutable

    9. The talkerExecutable publishes a ROS topic, /telemetry
      To add a ROS topic, click Add ROS topic. In the Name box, enter the name of the ROS topic. Select Maximum for QoS.

  2. Listener component (aka ROS subscriber)
    1. In the Component Name box, type in a name for the component, , for example, listener

      The name of a component must consist of alphabets [A-Z, a-z], digits [0-9], hyphen - and an underscore _ character, and must not begin with a digit.

    2. For Component Runtime, click Device.

    3. Ensure Is ROS Component is selected.

    4. Ensure the ROS Version is Melodic.

    5. In the Executable Name box, type in a name for the executable , for example, listenerExecutable

      The name of an executable must consist of alphabets [A-Z, a-z], digits [0-9], hyphen - and an underscore _ character, and must not begin with a digit.

    6. Since the ROS subscriber is already installed on the device, select Default as Executable Type.

    7. In the Command to run in the docker container box, enter the command:

      roslaunch listener listener.launch
      

      Ensure you always execute the command roslaunch to explicitly start the ROS Master instead of running the rosrun command, because the ROS Master will fail to start on rosrun, and eventually, the deployment will fail as well. listenerExecutable

    8. Click NEXT > CONFIRM PACKAGE CREATION.

Deploying the package

To deploy a package using the console, follow the steps:

  1. On the left navigation bar, click DEvelopment > Packages.
  2. Select the ROS publisher subscriber package.
  3. Click Deploy package.
  4. In the Name of deployment box, enter a name for the deployment you are creating, for example, ROS Publisher Subscriber Deployment.
  5. Since listener has device runtime, you must select the device you want to deploy the component on. Click Refresh the list of online devices to retrieve an updated list of online devices.
  6. Select the device from the Select device for deploying the component drop-down list.
  7. For the listener component, ensure that ros_workspace and ros_distro are selected.
  8. Click CREATE DEPLOYMENT > Confirm.

You will be redirected to the newly created deployment’s Details page. The ROS Publisher Subscriber Deployment is successfully running only when the green colored bar moves to Succeeded and Status: Running point indicating that the DEPLOYMENT PHASE is Succeeded, and the STATUS is Running.

ROS  Publisher Subscriber Deployment

You may also analyze the corresponding deployment logs to check if everything is working OK by clicking on Logs tab.

The listener-listenerExecutable will be streaming /listener I heard hello_world logs.

ROS Subscriber Logs

while talker-talkerExecutable will be publishing hello_world logs. ROS Publisher Logs