Complex robotic applications involving multi-device communication can be latent when the service is distributed across WAN. This tutorial demonstrates how to have multi-device communication within the same LAN.
This tutorial will show you how to deploy a broker package locally for inter device communication using rapyuta.io console.
If the device has ROS Melodic Morenia installed on it, replace Kinetic with Melodic in all places where a specific version of ROS is asked for. The tutorial should still work the same.
Intermediate
20 minutes
In this tutorial, you will add three devices namely Broker Device, Publisher Device and Subscriber Device. You will also create and deploy ROS Publisher and ROS Subscriber packages.
The Broker Device must be of amd64 CPU architecture.
Broker Device
I am a communication broker
Paste and execute the token (otherwise called the device setup link) in the device’s terminal to set up the rapyuta.io client on the device.
If the device is set up successfully, you should see the following output at the device’s terminal:
Initialising the Rapyuta Platform
############(100%)
Successfully Installed!
Ensure that there’s a green dot next to the Broker Device, which indicates that it is online on rapyuta.io.
In production-like scenarios, ensure the broker device is assigned a static IP address.
The Publisher Device is:
The custom rapyuta.io image comes with Ubuntu Xenial OS and ROS kinetic software installed on them. Moreover, the rapyuta.io tutorials are also installed on these custom images.
Learn how to prepare Raspberry PI
If you are using custom rapyuta.io image on the device, the catkin workspace is already set up for you, the io_tutorials repository is already downloaded in the workspace, and 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 you are using either a computer with ROS Kinetic installed on it, or a Raspberry PI without custom rapyuta.io image, you will create a catkin workspace and get the io_tutorials repository into the workspace.
To create the catkin workspace, you have to execute the below commands at the device’s terminal.
cd $HOME
mkdir -p catkin_ws/src
cd catkin_ws/src
git clone https://github.com/rapyuta/io_tutorials
source /opt/ros/kinetic/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 talker
If you experience the 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 the command sudo apt-get install python-catkin-tools
at the device terminal.
Publisher Device
/home/rapyuta/catkin_ws
.I am a ROS Publisher
Paste and execute the token in the device’s terminal to set up the rapyuta.io client on the device.
If the device is set up successfully, you should see the following output at the device’s terminal:
Initialising the Rapyuta Platform
############(100%)
Successfully Installed!
Ensure that there’s a green dot next to the Publisher Device, which indicates that it is online on rapyuta.io.
The Subscriber Device is a:
The custom rapyuta.io image comes with Ubuntu Xenial OS and ROS Kinetic software installed on them. Moreover, the rapyuta.io tutorials are also installed on these custom images.
Learn how to prepare Raspberry PI
If you are using custom rapyuta.io image on the device, the catkin workspace is set up for you, the io_tutorials repository is downloaded in the workspace, and the source code is 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 you are using either a computer with ROS installed on it or a Raspberry PI without custom rapyuta.io image, you will create a catkin workspace and get the io_tutorials repository into the workspace.
To create the catkin workspace, you have to execute the below commands at the device’s terminal:
cd $HOME
mkdir -p catkin_ws/src
cd catkin_ws/src
git clone https://github.com/rapyuta/io_tutorials
source /opt/ros/kinetic/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 the 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 the command sudo apt-get install python-catkin-tools
at the device terminal.
Subscriber Device
/home/rapyuta/catkin_ws
I am a ROS Subscriber
Paste and execute the token in the device’s terminal to set up the device manager client on the device.
If the device is set up successfully, you should see the following output:
Initialising the Rapyuta Platform
############(100%)
Successfully Installed!
Ensure that there’s a green dot next to the Subscriber Device, which indicates that it is online on rapyuta.io.
ROS Publisher
Publishes ROS topic for a subscriber
Publisher
talker
In the Command to run in the docker container box, copy and paste the command:
roslaunch talker talker.launch
Ensure you always execute roslaunch command for explicitly starting 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.
To add a ROS topic, click Add ROS topic. In the Name box, enter /telemetry
and set QoS to Maximum.
Click NEXT > CONFIRM PACKAGE CREATION.
ROS Subscriber
Subscribes to ROS topic published by a publisher
Subscriber
listener
In the Command to run in the docker container box, copy and paste the command:
roslaunch listener listener.launch
Ensure you always execute roslaunch command for explicitly starting 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.
Click NEXT > CONFIRM PACKAGE CREATION.
Communication Broker Deployment
As the component will be deployed on a device, its restart policy is already set to Always, however, you may override this value at the time of creating a deployment of the package.
You will be redirected to the newly created deployment’s Details tab. The package is successfully deployed when the green colored bar moves from In progress to Succeeded indicating that the DEPLOYMENT PHASE has Succeeded, and the STATUS is Running.
You may analyse the corresponding deployment logs so you may debug if the deployment fails.
ROS Publisher Deployment
You will be redirected to the Details tab of the newly created deployment. The package is successfully deployed when the green coloured bar moves from In progress to Succeeded indicating that the DEPLOYMENT PHASE has Succeeded and the STATUS is Running.
Ensure that the dependent deployment STATUS is Running as well.
You may analyse the corresponding deployment logs so you may debug if the deployment fails.
The corresponding dependency graph of ROS Publisher Deployment looks like:
ROS Subscriber Deployment
You will be redirected to the newly created deployment’s Details tab. The package is successfully deployed when the green colored bar moves from In progress to Succeeded indicating that the DEPLOYMENT PHASE has Succeeded, and the STATUS is Running.
Ensure that the dependent deployment STATUS is Running as well.
You may analyse the corresponding deployment logs so you may debug if the deployment fails.
The corresponding dependency graph of ROS Subscriber Deployment looks like:
If all of the above three deployments are successfully running, the logs of ROS Subscriber Deployment will print hello_world.
Since the communication broker is deployed on the Broker Device locally, and the bindable attribute is not selected (value is set to false) for both the ROS Publisher package and the ROS Subscriber package, the ROS topic (/telemetry) and in general, the data is transferred within the same local network. Thus, the application’s latency is comparatively reduced provided the Broker Device is in the same network as the Publisher Device, and Subscriber Device.