Edge Robotics with Eclipse fog05

28 July 2020

Edge Robotics is emerging as a new trend and natural evolution of cloud robotics. Its aims is to leverage compute and storage resources are closer to the robots in order to augment their capabilities while keeping latency under control and enabling new use-cases.

Moreover it also introduces the possibility to elaborate data closer to where they are produced and gives the user control on the data shared with third parties like cloud platform.

With Eclipse fog05 plugin for ROS2, it is possible to have an Edge Robotic system that can enable dynamic reconfiguration and offload of robotic tasks to robots and the nearby Edge infrastructure.

ROS2 is a robot operating system that provides a set of abstractions and mechanisms to facilitate the writing of complex robotic applications. Using ROS2 robotic application that can be written to run on different robots. Additionally, all communication and low-level interaction will be managed by ROS2 APIs.

While ROS2 provides great help in writing the application, it provides only basic support to run those applications via the ros2 run and ros2 launch .

While the former provides a way to start a simple robotic application composed by a single component, the second one provides a way to start an application composed by several components and handles all the needed configuration to make it run.

But both need to be executed directly on the robot itself, usually via a remote shell, thus the support of dynamical application deployment is somewhat limited. This is where Eclipse fog05 comes in play, given its application-agnostic and plugin design you can dynamically deploy your application or part of it using Eclipse fog05.

Let's immagine having a factory like the one illustrated the picture below.

In our factory we have Edge servers, in-factory computers and general-purpose robots.

Smart Factory

We would like to be able to dynamically configure this infrastructure to achieve different tasks, like transportation of goods from one point to the other of the production line, reconfiguration of the production line, or teleoperation in case a worker cannot enter the production line.

In such a case we would like to leverage all the computing, storage, and networking resources we have inside the factory plant and not rely on any cloud infrastructure because of security reasons (we do not want to expose our factory data to a third party…)

Thanks to Eclipse fog05 we can achieve this goal.

Installing fog05

First, we need to prepare our infrastructure with Eclipse fog05, so we need to install and configure the fog05 agent in our devices.

Our infrastructure is composed by three devices:

In each device we need to install the Eclipse fog05 agent and relative plugins.

  • LEC-AL: Zenoh router, fog05 agent, Linux, LinuxBridge and LXD Plugin.
  • RPi3: fog05 agent, Linux, LinuxBridge and LXD plugin
  • TurtleBot3: fog05 agent, Linux, LinuxBridge and ROS2 plugin

Install dependencies on on LEC-AL:

$ sudo apt udpdate && sudo apt install libssl-dev libev-dev python3-pip python3-lxml -y
$ sudo pip3 install zenoh==0.3.0 yaks==0.3.0.post1 fog05-sdk==0.2.1 fog05==0.2.1
$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/libzenoh-0.3.0-amd64.deb
$ sudo apt install ./libzenoh-0.3.0-amd64.deb -y

Install LXD on LEC-AL

$ sudo apt remove --purge lxd lxd-client -y
$ sudo snap install lxd
$ sudo lxd init #default answers are ok

Installing Zenoh router on LEC-AL:

$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/zenoh_0.3.0-1_amd64.deb
$ sudo apt install ./zenoh_0.3.0-1_amd64.deb -y

Installing fog05 agent on LEC-AL:

$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05_0.2.1-1_amd64.deb
$ sudo apt install ./fog05_0.2.1-1_amd64.deb -y

Installing and configuring fog05 agent on RPi3 and TurtleBot

$ sudo apt install libev4 libssl.1.1 python3-pip python3-lxml -y
$ sudo pip3 install zenoh==0.3.0 yaks==0.3.0.post1 fog05-sdk==0.2.1 fog05==0.2.1
$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/libzenoh-0.3.0-arm64.deb
$ sudo apt install ./libzenoh-0.3.0-arm64.deb -y
$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05_0.2.1-1_arm64.deb
$ sudo apt install ./fog05_0.2.1-1_arm64.deb -y
$ sudo vim /etc/fos/agent.json

Configure the yaks parameter with the address of the LEC-AL board (192.168.86.250) and the mgmt_interface with the name of the interface connected to the management network

{
    "agent": {
        "system": "0",
        "pid_file": "/var/fos/agent.pid",
        "expose": true,
        "yaks": "tcp/192.168.86.250:7447",
        "path": "/var/fos",
        "enable_lldp": false,
        "enable_spawner": false,
        "mgmt_interface": "eth0",
        "lldp_conf": "/etc/fos/lldpd/lldpd.conf"
    },
    "plugins": {
        "plugin_path": "/etc/fos/plugins",
        "autoload": false,
        "auto": []
    }
}

Then we need to install and configure the plugins.

Install and configure plugins in the LEC-AL:

$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05-plugin-os-linux_0.2.0-1_amd64.deb
$ sudo apt install ./fog05-plugin-os-linux_0.2.0-1_amd64.deb -y
$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05-plugin-net-linuxbridge_0.2.1-1_amd64.deb
$ sudo apt install ./fog05-plugin-net-linuxbridge_0.2.1-1_amd64.deb -y
$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05-plugin-fdu-lxd_0.2.1-1_amd64.deb
$ sudo apt install ./fog05-plugin-fdu-lxd_0.2.1-1_amd64.deb -y

Then configure the field dataplane_interface on the LinuxBridge configuration file (/etc/fos/plugin/plugin-net-linuxbridge/linuxbridge_plugin.json ) with the correct value of the interface to be used for virtual networks.

Install and configure plugins on RPi3:

$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05-plugin-os-linux_0.2.0-1_arm64.deb
$ sudo apt install ./fog05-plugin-os-linux_0.2.0-1_arm64.deb -y
$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05-plugin-net-linuxbridge_0.2.1-1_arm64.deb
$ sudo apt install ./fog05-plugin-net-linuxbridge_0.2.1-1_arm64.deb -y
$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05-plugin-fdu-lxd_0.2.1-1_arm64.deb
$ sudo apt install ./fog05-plugin-fdu-lxd_0.2.1-1_arm64.deb -y

Then configure the Linux, LinuxBridge, and LXD plugin to use the Zenoh server on the LEC-AL, updating the ylocator accordingly in the configuration files, /etc/fos/plugin/plugin-os-linux/linux_plugin.json , /etc/fos/plugin/plugin-net-linuxbridge/linuxbridge_plugin.json and /etc/fos/plugin/plugin-fdu-lxd/LXD_plugin.json.

Then configure the field dataplane_interface on the LinuxBridge configuration file with the correct value of the interface to be used for virtual networks.

Then we install and configure the plugins on the Turtlebot.

$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05-plugin-os-linux_0.2.0-1_arm64.deb
$ sudo apt install ./fog05-plugin-os-linux_0.2.0-1_arm64.deb -y
$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05-plugin-net-linuxbridge_0.2.1-1_arm64.deb
$ sudo apt install ./fog05-plugin-net-linuxbridge_0.2.1-1_arm64.deb -y
$ wget https://github.com/eclipse-fog05/fog05/releases/download/v0.2.1/fog05-plugin-fdu-ros2_0.2.1-1_arm64.deb
$ sudo apt install ./fog05-plugin-fdu-ros2_0.2.1-1_arm64.deb -y

Then configure the Linux, LinuxBridge, and LXD plugin to use the Zenoh server on the LEC-AL, updating the ylocator accordingly in the configuration files, /etc/fos/plugin/plugin-os-linux/linux_plugin.json , /etc/fos/plugin/plugin-net-linuxbridge/linuxbridge_plugin.json and /etc/fos/plugin/plugin-fdu-ros2/ros2_plugin.json.

Then configure the field dataplane_interface on the LinuxBridge configuration file with the correct value of the interface to be used for virtual networks.

Now we can start the services in all nodes:

LEC-AL:


$ sudo systemctl start zenoh
$ sudo systemctl start fos_agent
$ sudo systemctl start fos_linux
$ sudo systemctl start fos_linuxbridge
$ sudo systemctl start fos_lxd

RPi3:

$ sudo systemctl start fos_agent
$ sudo systemctl start fos_linux
$ sudo systemctl start fos_linuxbridge
$ sudo systemctl start fos_lxd

TurtleBot3:

$ sudo systemctl start fos_agent
$ sudo systemctl start fos_linux
$ sudo systemctl start fos_linuxbridge
$ sudo systemctl start fos_ros2

The robotic application

Then, we need to define the components of our application. We selected a teleoperation application, thus it will be composed by the following components:

  • The Robotic Client
  • The Teleoperation Server
  • The Teleoperation WebUI
  • Virutal Networking infrastructure

Each of these component can be packaged as a different kind of virtualization technology, in our case we selected heterogenous virtualization technologies to show how Eclipse fog05 deals with etherogeneity.

  • ROS2: Robotic Sensors and Actuators, Robotic Client
  • LXD: Virtual Access Point, Virtual Gateway, Teleoperation WebUI
  • Docker: Teleoperation Server

For each of these components, we need to define a descriptor that explains to fog05 how to deploy the component.

This repository contains the descriptors for each component, as well as the script to build all the needed images.

Using the following script we can instantiate the whole robotic application using the fog05 APIs

import os
from fog05 import FIMAPI
from fog05_sdk.interfaces.FDU import FDU
import sys
import time
import json

DESC_FOLDER = './descriptors'

descs = {
    'gw':'gw.json',
    'ap':'vap.json',
    'zenoh':'zenoh.json',
    'server':'teleop-server.json',
    'gui':'gui.json',
    'motors':'motors.json',
    'client':'client.json'
}

net_desc = ['vnet.json']

def read_file(filepath):
    with open(filepath, 'r') as f:
        data = f.read()
    return data

def read(fname):
    return open(fname).read()

def main(ip):
    a = FIMAPI(ip)

    fdus = {}
    nets = []

    print('Current Eclipse fog05 Infrastructure:')

    nodes = a.node.list()
    for nid in nodes:
        info = a.node.info(nid)
        print('ID: {} Hostname: {}'.format(nid, info['name']))

    input('Press enter to instantiate the demo')

    for d in net_desc:
        path_d = os.path.join(DESC_FOLDER,d)
        netd = json.loads(read(path_d))
        a.network.add_network(netd)
        nets.append(netd['uuid'])
        time.sleep(1)

    for name in descs:
        d = descs[name]
        print('Instantiating {}'.format(name))
        path_d = os.path.join(DESC_FOLDER,d)
        data = json.loads(read(path_d))
        fdu_d = FDU(data)
        fduinfo = a.fdu.onboard(fdu_d)
        fdu_id = fduinfo.get_uuid()
        print ('fdu_id : {}'.format(fdu_id))
        inst_info = a.fdu.define(fdu_id)
        iid = inst_info.get_uuid()
        a.fdu.configure(iid)
        a.fdu.start(iid)
        print ('iid : {}'.format(iid))
        print('Instantiated: {}'.format(name))
        fdus.update({fdu_id: iid})
        time.sleep(2)

    print('Instantiated:')
    print(json.dumps(fdus, indent=2))
    print('Bye!')

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print("Usage {} <zenoh ip:port>")
        exit(-1)
    main(sys.argv[1])

The deployment is exectuted by launching this script, we are connecting directly with the Zenoh router on the LEC-AL as entry point for the system.

$ python3 deploy.py <LEC-AL ip address>

After deploying we see a new WiFi network Eclipse fog05 Robotic Demo that allows us to connect to the teleoperation of the robot. Once connected we can navigate to the web interface at this address http://172.16.123.50 and we are able to see the command interface.

Robot UI

From this interface we are able to both control the robot movements and monitors its speed.

Conclusions

In this blog we have seen how to use Eclipse fog05 in conjunction with ROS2 to manage a complex robotic application.

But fog05 is not only about robotics, you can use it to manage any sort of application you want to deploy at your own edge or across different locations.