D1.4 Overall Architecture Definition –...

42
D1.4 Overall Architecture Definition – Initial June 2018 1

Transcript of D1.4 Overall Architecture Definition –...

Page 1: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

June 2018

1

Page 2: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Grant agreement no. 780785Project acronym OFERAProject full title Open Framework for Embedded Robotic

ApplicationsType ReportDissemination level PublicDate of Delivery 30/06/18Deliverable Number 1.4Deliverable Name Overall Architecture Definition – InitialTask related 1.4Authors (eProsima) Borja Outerelo GamarraContributors (PIAP) Adam Dąbrowski

(Bosch) Ingo Luetkebohle, Ralph Lange(eProsima) Jaime Martin Losa, Ricardo GonzalezMoreno, Borja Outerelo Gamarra(ALR) Inigo Muguruza Goenaga, Victor MayoralVilches

Keywords Architecture, IoT, Robotics, ROS, microcontrollers,middleware

Abstract This document presents the proposed approach to thearchitecture of micro-ROS.

2

Page 3: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Contents1 Acronyms 5

2 Introduction 52.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Purpose of document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.3 Partners involved . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Overview of existing approaches 63.1 Approach 1: Re-use ROS/ROS2 to a large extent . . . . . . . . . . . . . . . . . . . . . . 6

3.1.1 ROS2 on RIOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.2 Approach 2: Custom embedded architecture with network-level interoperability . . . . . 7

3.2.1 rosserial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2.2 mROS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4 micro-ROS architecture 114.1 Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4.1.1 Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.1.2 External Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

4.2 Functional Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2.1 Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2.2 Topic and messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2.3 Publisher and Subscription . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.2.4 Service Client and Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.2.5 Timers and Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.2.6 Lifecycle, System Modes and parameters . . . . . . . . . . . . . . . . . . . . . . . 144.2.7 Node Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.2.8 Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.2.9 Graph introspection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.2.10 nodes discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.2.11 micro-ROS profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.3 Quality Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.3.1 Availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.3.2 Extensibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.3.3 Monitoring and management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.3.4 Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.4 Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.4.1 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.4.2 Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.4.3 Protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.4.4 Target deployment platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.4.5 Real Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.4.6 Memory usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.4.7 ROS2 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.4.8 Development methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4.5 Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.5.1 Package Components and layers . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.5.2 Modularity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4.6 Software Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.6.1 Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.6.2 Components - micro-ROS Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3

Page 4: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

4.6.3 Components - micro-ROS Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.7 External Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

4.7.1 Node interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.7.2 Publisher and subscribers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.7.3 Service, server and client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.7.4 Parameters manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.7.5 Graph manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.7.6 Timers and Clocks interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.7.7 Executor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344.7.8 Lifecycle and system modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344.7.9 Logging utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354.7.10 Agent core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354.7.11 Parameter server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354.7.12 Graph server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

4.8 Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364.8.1 micro-ROS Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364.8.2 micro-ROS Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

4.9 Infrastructure Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384.9.1 infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.10 Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384.10.1 Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384.10.2 Build system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404.10.3 Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404.10.4 Test system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

5 Appendix 415.1 A1 Related documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

References 42

4

Page 5: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

1 Acronyms

Acronym ExplanationCDR Common Data RepresentationDDS Data Distribution ServiceFSM Finite-State MachineHW HardwareIDL Interface Definition LanguageIRQ Interrupt RequestMCU Microcontroller UnitMPU Microprocessor UnitMTU Maximum Transmission UnitNTP Network Time ProtocolOMG Object Management GroupOS Operating SystemOSS Open Source SoftwareQoS Quality of ServicePTP Precision Time ProtocolROS Robot Operating SystemRPC Remote Procedure CallRTOS Real Time Operating SystemRTPS Real-Time Publish-SubscribeXRCE Extremely Resource ConstrainedYAML YAML Ain’t Markup Language

2 Introduction

2.1 Summary

In this initial version of the overall architecture definition document, we propose the first approach tothe architecture for the micro-ROS platform.

This document’s starting point is the previous document: D1.7 Reference Scenarios and TechnicalSystem Requirements Definition. We continue from that point with a quick review of the related work,from an architectural point of view. On this review, we analyse three relevant open source projects:riot-ROS2[3], rosserial[4] and mROS[5].

The next part is the core of the document, the micro-ROS architecture definition. For architecturedefinition, we follow the approach taken in Simon Brown publications[1][2] and his C4 model[6]. In thisarchitecture definition, we introduce functional behaviour along with the system specified at differentlevels of abstraction (“zoom levels”). The architecture definition starts with a context section wherewe set the scene for this architecture specification. Following the context, we present the primaryfunctions of micro-ROS and what they do. Them we summarise quality attributes of micro-ROS andthe constraints imposed to its development. To continue we introduce the principles driving the designand development of micro-ROS.

As the central part of the architecture document, is the software architecture section where we showthe whole picture and complete it with an explanation of the interfaces of the system. Next follows acode section where we explain our layered code structure and roles of each one regarding the proposedarchitecture. As final parts of this core section, we present the infrastructure and the deployment of

5

Page 6: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

the micro-ROS platform. Part of the deployment is a table defining profiles and a set of scenarios usingthose profiles.

2.2 Purpose of document

Architecture is the result of a number of choices to satisfy goals and constraints. In this document,we introduce goals and constraints we identified, and explain the rationale behind our decisions, asinformation for future developers and users of micro-ROS.

This document is intended to be a living document, evolving with the OFERA project, to reflect theexperiences other contributors and we make.

At least two such revisions are already planned: * Overall Architecture Definition - Revised - 30.06.2019* Overall Architecture Definition - Final - 30.06.2020

2.3 Partners involved

Short name Full Name RoleeProsima Proyectos y Sistemas de Mantenimiento SL Task leadBosch Robert Bosch GmbH ContributorALR Acutronic Link Robotics AG ContributorPIAP Przemyslowy Instytut Automatyki i Pomiarow PIAP Verification

3 Overview of existing approaches

There have been some quite different attempts to bring ROS and/or ROS2 to micro-controllers.

3.1 Approach 1: Re-use ROS/ROS2 to a large extent

In this class of approaches, the basic plan is to take some or all of the core ROS2 layers, in particular,the rmw, and rcl layer and use them with as little modification as possible, ideally feeding back anymodifications into the standard ROS2 implementation.

This approach thus provides API-level compatibility with the chosen ROS2 layers. The implicitassumption appears to be that this would also provide re-usability of ROS2 nodes built on top of thelibraries, though it must be said that most ROS2 nodes depend on much more than just ROS2 APIs.It is, as of this moment, not entirely clear how much else would be required to enable “just recompiling”typical ROS nodes.

3.1.1 ROS2 on RIOT

RIOT-ROS2 is a project that tries to enable full ROS2 stack to run on microcontrollers, using theRIOT operating system.

It has ported the rmw and rcl layers, as well as a novel client library written in ‘C’ (rclc).

For the middleware layer, they did not use DDS as in standard ROS but provide an MQTT and anNDN layer.

6

Page 7: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Discussion

The current ‘C’-based client library does not implement all concepts from the regular C++-clientlibrary (rclcpp). In particular, the lifecycle, the node graph, and parameters are missing. Therefore, itis difficult to judge the applicability of the concept.

Since existing ROS2 nodes are using either the C++ or the Python interface, recompiling them onRIOT-ROS2 is also not possible.

Moreover, as they are using different middlewares, network-level interoperability is not present.

Conclusion

While RIOT-ROS2 is a very interesting proof of concept, it only brings a tiny subset of standard ROS2to micro-controller and thus does not, at this moment, allow a judgement of the general feasibility ofthe “re-use as much as possible” approach.

That said, the underlying RTOS RIOT has a POSIX-API that would, in principle, be useful for portingexisting nodes written for a POSIX OS.

3.2 Approach 2: Custom embedded architecture with network-level inter-operability

This class of approaches explicitly targets embedded systems, with a dedicated implementation that is,however, interoperable on the network level (either directly, or through an agent).

3.2.1 rosserial

ROSSerial connects a computer running regular ROS to a resource-constrained device, typically over aserial link. The “rosserial_server” component acts as a proxy, representing the MCU to the rest of theROS system.

On the constrained device, a conceptual layering into a tiny hardware abstraction (Hardware) and auser API (NodeHandle) is used. Note that the NodeHandle is templated on the Hardware class, so theimplementation is not hidden from the user. The Platform part may be either an RTOS, some otherframework, or the bare metal libraries provided by the board support package. A popular non-RTOSplatform in this space is the Arduino framework.

7

Page 8: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Protocol

ROSSserial uses a single serial link and sends plain ROS-serialized messages, with a header givingthe topic, and a footer containing a checksum. This is a custom protocol that is not compatible withanything else, and it cannot share the serial line with other data.

API

The ROSSerial API basically puts all methods into the NodeHandle class, including some which areglobal in standard ROS (logging) or have their own class (like Time). Moreover, all processing, includingtopic data processing, is also concentrated in the NodeHandle class, instead of being distributed.

The Hardware class provides an abstraction of the serial port and the hardware time. Note that itstime method is not intended to be called by users, it is only used for internal offset calculations.

8

Page 9: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Figure 1: rosserial structure9

Page 10: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Discussion

• ROSSerial in many ways appears to be the most simple and straightforward implementation ofROS for embedded uses imaginable. While some more optimisations appear possible, in general, itis about as small at it gets, has been used on even the tiniest Arduinos, with only a few kilobytesof RAM, and does not consume any CPU when not invoked. As such, it represents a good lowerend of comparison for embedded micro-ROS.

• A notable omission is a support for timers. This may be because, in older Arduino’s, all hardwaretimers are already taken by the Arduino framework. In any case, timers are of course crucial andneed to be added.

• ROSSerial assumes that UARTs are real UARTs. In reality, many UARTs are connected on atleast one end to USB-to-serial converters. Such converters are often optimized for bulk datatransfer, and introduce delays (e.g., the common Linux-driver for the FTDI232 USB-to-serialconverter uses USB bulk transfers, and additionally has a 16ms delay for small amounts of data).Optimal performance can only be achieved by taking this into account, and using USB-specificdrivers.

• One architecturally notable aspect regarding the implementation is that a number of internalattributes are declared in the public section of their C++ class and can thus be changed at run-time.An example of this is the NodeHandle-pointer of the Publisher class. Obviously, this negatessome of the encapsulation usually afforded by C++. Moreover, because these attributes areinitialised after creation, they can also not be declared const and thus additional error checkingcode is necessary. This implementation is an odd choice because it deviates from standard ROS.Normally, the Publisher object is created by the NodeHandle and returned as a shared pointer.I surmise the underlying reason for this is that objects are allocated statically and initialisedafterwards. Nevertheless, even when static allocation is used, this approach seems unnecessary(e.g., the object could simply be returned by-value), and should be re-visited for micro-ROS.

Conclusion

rosserial is a proven approach, popular particularly in the Arduino community. In particular, it is ableto target very tiny MCUs.

However, it deviates from standard ROS/ROS2 in many ways. Compared to ROS2, lacks basiccapabilities, such as the lifecycle, independent nodes, timers, etc. It will remain to be seen how tinythis approach still is when more advanced features are added.

rosserial uses a C++ API, and thus porting the ROS-calls of an existing node is probably fairly easy.However, since it does not integrate with an RTOS, porting existing nodes written for a POSIX OSwill require much more work than just porting the ROS interface.

3.2.2 mROS

mROS [5] is a ROS stack for MCUs based on the RTOS TOPPERS [7]. mROS aims at larger MCUsthat are capable of running a lightweight IP stack. There are two major differences compared torosserial. First, mROS provides basic ROS concepts - particularly including nodes and topics - on theMCU, i.e. application components on the MCU are implemented as nodes and communicate via topicsusing the same interface as defined in the rclcpp of standard ROS. Second, the agent connecting themROS-based subsystem with the remaining ROS system runs directly on the MCU, which requiresEthernet on the MCU platform. As a consequence, a mROS-based MCU can be connected to a standardROS system transparently.

While mROS provides the normal ROS interface for topics (even in a header file named ROS.h), itprovides an efficient shared memory implementation for all MCU-internal communication.

10

Page 11: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Architecture diagrams on mROS can be found at https://de.slideshare.net/takasehideki/mrosros inJapanese.

4 micro-ROS architecture

4.1 Context

Nowadays robotic systems are composed by a heterogeneous set of microcontroller-based sensors andactuators attached to a general propose computer, take a UAV as an example, which is composed by amicrocontroller-based Autopilot connected to multiple sensors, or the Bosch Indego lawnmower mixingsafety-rated microcontroller with non-safety-rated microcontrollers.

Currently, the Robot Operating System, ROS2, provides high flexibility to the users for extendingrobotic applications. This extension focuses on the integration of high-power/high-resources computers.Due to ROS2 design, this solution is not suitable for microcontroller-based devices. The followinglimitations are rooted in the ROS2 design:

• Usage of DDS communications infrastructure. Traditionally, DDS implementations have highresource requirements, do not support sleep cycles and requires considerable large MTUs.

• Implementation details on higher layers. As examples we can take Node and Executors from ROS.Those ROS concepts highly depend on the ROS client library used. The existing ROS Clientlibraries are not the best suited for microcontrollers.

Due to these core design decisions, the current ROS2 implementation is not capable of running nativelyon microcontrollers. This situation push developers to use their custom solutions losing the benefitsof a robust, highly adopted platform, ROS2. micro-ROS address this lack of a common platform forintegrating microcontrollers in a robotic system. micro-ROS design extends existing ROS2 towardsmicro-controllers. micro-ROS uses the same ROS2 concepts and interoperates with it. Integration ofexisting ROS2 concepts eases micro-ROS inclusion in the ROS2 ecosystem and the adoption of it byexisting community.

The following context diagram shows how micro-ROS is related to other software systems and thedifferent users of that ROS2 ecosystem. micro-ROS allows the communication between microcontrollerbased solutions (micro-ROS applications) and general ROS2 solutions (ROS2 applications). In anutshell, micro-ROS allows microcontrollers applications to communicate with ROS2 applications usinga client-server architecture, where the clients are in microcontroller based systems and the servers onthe ROS2 side.

11

Page 12: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Figure 2: micro-ROS Context

4.1.1 Users

micro-ROS main target users are Robotic system developers and embedded systems developers. micro-ROS developers could use the provided libraries and tools to develop micro-ROS applications. Developerscould deliver those micro-ROS applications on a Robotic platform extending it with microcontroller-based applications.

The other kind of user is not using micro-ROS directly, but using systems developed with the help ofmicro-ROS technologies. This user interacts with both ends of the system, ROS2 applications, andmicro-ROS applications.

12

Page 13: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

4.1.2 External Systems

There are external systems integrated with micro-ROS. They are the systems represented by grey boxeson the micro-ROS context diagram.

1. micro-ROS application: User application developed using micro-ROS and deployed on top of areal-time operative system running on a microcontroller. These applications are Low resourceconsumers, and capable of performing sleep periods. These applications act as decoupled ROScomponents thanks to the communication provided by micro-ROS technologies.

2. ROS2 application: User application developed using ROS2 concepts and technologies and deployedon regular computers with no resource restrictions. These ROS2 applications interact with micro-ROS applications thanks to micro-ROS technologies.

3. OS: micro-ROS target platforms are microcontrollers which are operated by an RTOS and providesan abstraction over the RTOS used. micro-ROS use underlying RTOS functionality and exposethem to the user.

The usage of the micro-ROS platform allows the communication between the two kinds of applications.Regular ROS2 uses DDS as the standard communication mechanism between ROS2 applications. Thesecommunications standards are also used on Robotic applications using micro-ROS.

4.2 Functional Overview

The micro-ROS platform takes most of the ROS2 existing functionality into a microcontroller system.This section provides a summary of the micro-ROS exposed functionality.

4.2.1 Node

Nodes, as in ROS2, are the core concept of the micro-ROS platform. micro-ROS applications arecompositions of nodes that run orchestrated by micro-ROS scheduling.

The nodes are the entry point to users of the platform, and they offer them essential features:

• communicates with other micro-ROS nodes and ROS2 nodes using Micro RTPS middleware.• are capable of publishing and subscribe to Topics.• can expose and consume services.• provides timers and timing facilities.• have associated configuration parameters.• include logging capabilities.

Some nodes could have states observable from others. These nodes with states are managed bymicro-ROS and notify their observers on state changes and status. These states and their transitionsfollow the same ROS2 defined FSM.

4.2.2 Topic and messages

Topics are the data that nodes interchange. The different topics consist of a name and an associatedType.

micro-ROS topics are defined analogous to the ROS2 ones, using rosidl files. These topic definitionfiles need to be processed to generate code supporting the type they define. From these rosidl files,the build system generates type support consisting of the in-memory representation of the topic type.Apart from in-memory representation, the topic need code supporting middleware required serialise/

13

Page 14: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

deserialise operations. Code generation took rosidl files and outputted middleware vendor-specifictype support code, so this type support generation is a process tied to the underlying middlewarevendor. In case of micro-ROS, it generates DDS-XRCE static type support. In case of micro-ROS,based on DDS-XRCE middleware, the generation of this type support require a previous step ofgenerating DDS-XRCE specific definition files as DDS-XRCE uses OMG IDL files. rosidl_dds, anexisting ROS2 package generates these IDL files from the ROS2 definition files and them from thegenerated IDL an implementation specific package produces the final code that the implementationuses for serialisation/deserialisation of the type.

4.2.3 Publisher and Subscription

Nodes data is interchanged using publishing and subscribe interface provided by the underlyingmiddleware. A node can create and hold multiple publisher and subscriptions. A node is capable ofpublishing user content as long as the topic is defined in micro-ROS platform using previous mentionedmicro-ROS tools. Node users can create subscriptions to Topics and them they receive up to date dataon callbacks they provide on subscription creation. Publications and subscriptions have a series ofconfigurable middleware QoS to fit with micro-ROS applications requirements.

4.2.4 Service Client and Server

Nodes can expose services to be called by other nodes. This user created services receive a request anddispatch them making use of a user provided callback. At the other end of this operation are nodesthat consume services and receive responses from the services attended by user callbacks.

4.2.5 Timers and Clocks

micro-ROS provides the user with time-based functionality: timers and clocks.

For timers, micro-ROS nodes provide callback based timers to the user. Due to real-time constraints,these timers follow real-time principles. To comply with these real-time requirement maintainingdeterminism on timer calls, low-level timer implementations, OS level or hardware timers are desirable.

Apart from timers, micro-ROS allows the user to provide different clocks, so micro-ROS time is measuredbased on different principles. Clock synchronisation between nodes is possible using custom time sourcesfor clocks and adjust them using different synchronisation algorithms as could be NTP or PTP.

4.2.6 Lifecycle, System Modes and parameters

Modern robotic software architectures follow a layered approach. The layer with the core algorithmsfor SLAM, vision-based object recognition, motion planning, etc. is often referred to as skill layer orfunctional layer. To perform a complex task, these skills are orchestrated by one or more upper layersnamed executive layer and planning layer. Other common names are task layer and mission layer ordeliberation layer(s). In the following, we used the last term.

We observed three different but closely interwoven aspects to be handled on the deliberation layer:

1. Task Handling: Orchestration of the actual task, the straight-forward, error-free flow2. Contingency Handling: Handling of task-specific contingencies, e.g., expectable retries and

failed attempts, obstacles, low battery.3. System Error Handling: Handling of exceptions, e.g., sensor/actuator failures.

14

Page 15: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

The mechanisms being used to orchestrate the skills are service and action calls, re-parameterisations,set values, activating/deactivating of components, etc. We distinguish between function-oriented callsto a running skill component (e.g., set values, action queries) and system-oriented calls to individual ormultiple components (e.g., switching between component modes, restart, shutdown).

Analogously, we distinguish between function-oriented notifications from the skill layer in form afeedback on long-running service calls, messages on relevant events in the environment, etc. andsystem-oriented notifications about component failures, hardware errors, etc.

Our observation is that interweaving of task, contingency and system error handling generally leads toa high complexity of the control flow on the deliberation layer. Yet, we hypothesise that this complexitycan be reduced by introducing abstractions for system-oriented calls and notifications.

Therefore, micro-ROS shall provide suitable abstractions and framework functions for (1.) systemruntime configuration and (2.) system error and contingency diagnosis, to reduce the effort for theapplication developer of designing and implementing the task, contingency and error handling.

15

Page 16: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Figure 3: System modes architecture

The envisioned key elements are illustrated in the above diagram:

1. Extensible concept to specify the runtime states of components. This concept will be based onthe node lifecycle FSM as defined in ROS2 [8].

2. Modelling approach for specifying system modes based on these component states.3. Diagnosis module for deriving relevant information from the operating systems, the hardware

and the functional components.4. Mode manager module for system runtime configuration.

The corresponding functionality shall not only be provided for micro-ROS but also for standard ROS2since system mode management involves all computing platforms of a robotic system. Moreover, themode manager will be a distributed component.

The lifecycle and system modes management shall support four different flavours (expansion stages):

1. Basic Mode Management

• purely relying on ROS2 standards/diagnostics

2. Extended Mode Management

• introduces (sub-)systems• extensions to ROS diagnostics• introduced system mode manager

3. Mode Management and Error Handling

• modelling of system errors and error propagation• extensions to ROS diagnostics• extensions to mode manager

4. Mode Verification and Validation

16

Page 17: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

• Verification and validation capabilities based on (1.) - (3.)

In detail, the Basic Mode Management shall cover the following aspects and concepts: * Basedon ROS nodes and their lifecycle (mainly active/inactive) * Nodes can be passed parameter sets toreconfigure * Nodes have their own rules to check feasibility of parameters * Re-configuration of nodestakes the following steps: 1. Node is set to inactive 1. New parameter set is passed 1. Node checksparameters for their applicability, either applies or rejects them 1. Node is set to active (resp. themode that it had before reconfiguration)

The basic mode management shall purely rely on ROS2 techniques so that it does not require anyadditional packages. It is rather a collection of conventions of ROS2 nodes and lifecycle that allows aconsistent handling.

The Extended Mode Management shall introduce the following concepts compared to the basicmode management: 1. Component models * ROS nodes with a leaflet that specifies: * Parameters of thenodes, optionally with default values * Additional modes (see below) * The component leaflet may bemodel-mined from the corresponding ROS nodes 1. (Sub-)Systems models * Collections of sub-systemsand/or components * Leaflet specifies: * Contained sub-systems and components * Parameters of this(sub-)system * Additional modes of this (sub-)system (see below) * Startup order 1. Additional Modes* Additional modes specialise the generic active mode, e.g., active.fast, active.safe. * A mode specifiesa configuration set, i.e. a set of concrete values for all parameters. Value can be: * Concrete value *Specified to be inherited from a parent mode, e.g., default active mode * given by template value (hasto be set by parent (sub-)system in hierarchy) * Modes of (sub-)systems (as opposed to components)additionally specify mode switches of contained sub-systems and components 1. Introduces a modemanager * Operates on the system model (see above) * Orchestrates modes for (sub-)systems andcomponents in its scope (some nodes might not be under control of the mode manager for legacyreasons, which is fine) * Subscribes to lifecycle topic of the components in its scope to register whenthey are (re-)configured externally (as this may lead to undesired behaviour).

4.2.7 Node Scheduling

Nodes are the primary interface with the user, but they need to execute to receive and send communic-ations data, update timers or perform logging operations. micro-ROS node scheduling handles thisnode update operation and allows the users to group and update nodes according to their needs.

4.2.8 Logging

Nodes provide named logger utilities where the user define their custom log writers controlling logsdestinations.

4.2.9 Graph introspection

micro-ROS and ROS2 nodes form a so-called system graph which is accessible with introspection tools.Introspection provides the user with services to query on the current system graph.

4.2.10 nodes discovery

There are to ways to made Node discovery: statically or dynamically.

• Static discovery is achieved by middleware configuration. In this discovery, micro-ROS nodes areconfigured, so they know the existence of micro-ROS Agent beforehand.

17

Page 18: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

• Dynamic discovery is a mechanism provided by middleware. The middleware used allow nodes tobe added on the fly to the system as they find and connect automatically with an existing Agent.

All discovery methods have the peculiarity that micro-ROS applications discover micro-ROS Agents,no the other way round. The discovery is a mechanism provided by the underlying middleware used, inthis case, Micro RTPS.

4.2.11 micro-ROS profiles

Along with the configuration mechanism mentioned, micro-ROS adds a profile system. This profilesystem allows the user to select how micro-ROS platform behave, so they are capable to configure theplatform accordingly with their needs and requirements. Multiple profiles exists, and they could becombined as the user wants on build time. These micro-ROS profiles reduce or extend the functionalityof the platform.

4.3 Quality Attributes

This section provides information about the desired quality attributes of the micro-ROS platform.

4.3.1 Availability

micro-ROS should support systems composed by nodes with aggressive sleep cycles where nodes shouldwake up and be able to communicate with other nodes without the need of reconfiguration of micro-ROSAgent.

4.3.2 Extensibility

micro-ROS should be extensible with new packages the same fashion as ROS2 does.

Users should be able to add new topic types.

4.3.3 Monitoring and management

micro-ROS should provide tools for monitoring and manage the system. One of those tools shouldmanage middleware configurations and profiles also monitoring packages should be available to controlnodes behaviour.

4.3.4 Interoperability

micro-ROS nodes should be interoperable with other ROS2 nodes, with nodes running on differenthardware and different RTOS and with nodes using micro-ROS platform with different underlyingmiddleware (As long as they use the same standard, DDS-XRCE).

4.4 Constraints

This section provides information about the constraints imposed on the development of the micro-ROSplatform.

18

Page 19: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

4.4.1 License

Since micro-ROS platform release is an OSS, under a commercially friendly license, it imposes aconstraint. So, the consortium needs to make sure they hold all the necessary rights to license micro-ROS with such OSS license and to satisfy the license requirements of possible existing dependencies.

4.4.2 Time

As there are already scheduled three software deliverables, there is a time constraint to finish thedevelopment of the platform. These three deliverables dates are 31.12.2018, 31.12.2019 and 31.12.2020.Consequently, The final date constraint is 31.12.2020.

4.4.3 Protocols

The ROS community adopted DDS, as communication standard since ROS2 thus if micro-ROS providea method to use same DDS protocol in microcontrollers it will achieve ROS2 native interoperability.

micro-ROS can provide DDS communication to low resources devices despite the fact that they do notuse DDS protocol directly; it use a recently approved standard, DDS-XRCE for that task. DDS-XRCEstandard provides means to use DDS communications from within low resources devices; this protocolfollows client-server architecture where the server acts as a bridge between its clients and DDS. Theprotocol works with client and server interchanging DDS-XRCE messages. In micro-ROS we use MicroRTPS as default DDS-XRCE implementation and core part of micro-ROS communications and ROS2interoperability enabler.

4.4.4 Target deployment platform

micro-ROS deployment targets are systems based on microcontrollers where a RTOS is operating. Forthis project, the document D2.1 Report on the reference hardware development platforms. defines thetarget platforms. A common characteristic of the kind of platforms we target is that they are platformswith relatively low resources and mainly low power consumption.

4.4.5 Real Time

micro-ROS main target platforms are microcontrollers operated by an RTOS. This means that micro-ROS should not break real-time principles:

• Determinism.• Responsiveness.• User control.• Reliability• Fail safe.

4.4.6 Memory usage

Real-time constraint indirectly imposes a memory usage constraint as it is usually a source of failureson following real-time principles.

19

Page 20: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

One of the main concerns and source of issues is dynamic memory usage, so dynamic memory isdiscouraged on real-time systems due to the indeterminism added by allocation methods and memoryavailable on the constrained environments micro-ROS is used.

4.4.7 ROS2 Integration

micro-ROS main target is to bring ROS2 capabilities to microcontrollers imposing an integrationconstrain where micro-ROS works integrated with an existing ROS2 system. ROS2 integration isachieved using same standard messages over DDS and DDS-XRCE also, and integration of tools isdesirable, meaning that micro-ROS should integrate with current existing ROS2 packages ecosystem.

4.4.8 Development methodology

micro-ROS development should follow a development methodology defined by the Consortium. Thismethodology defines coding standards, tests methodologies, software integration and release models tofollow. Also, code reviews and documentation standardisation should be addressed.

4.5 Principles

This section provides information about the principles adopted for the development of the micro-ROSplatform.

4.5.1 Package Components and layers

This architecture provides a “package by component” view of the micro-ROS platform. We choose thisview as explaining components grouped by functionality is more straightforward and offers a more clearpicture than arranging them by layers. Even though, the code follows a layering layout where eachof the functional components spam over multiple abstraction layers, these are later explained in thisdocument.

The micro-ROS components have:

• Concrete functional target.• Cover, at some extent, an original ROS2 abstraction concepts.• User interface (micro-ROS application developer interface).• Could be isolated for modular deployment and testing.

4.5.2 Modularity

To facilitate application in diverse scenarios, we emphasise a modular approach. Modularity should gobeyond layering because this enables gradual and partial adoption into existing products.

For example, a middle layer such as serialisation should be usable without a particular lower transportlayer. Similarly, functionalities such as the embedded transform library or the FIWARE context brokerintegration might be interesting, and furthering the goals of micro-ROS, even without the rest ofmicro-ROS.

20

Page 21: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

4.6 Software Architecture

4.6.1 Containers

Figure 4: micro-ROS Containers

As stated before, micro-ROS follows a server-client architecture where a general purpose computercontains a server and the microcontroller based systems contain the client applications. On that line,we have two essential parts of the architecture, a micro-ROS Agent and the micro-ROS Stack.

In the diagram:

• micro-ROS Agent: It is a C++11 server acting as the single point of access for the micro-ROSapplication to the DDS network shared with ROS2 applications.

• micro-ROS Stack: a group of C99 implemented packages that provide ROS2 concepts to its clientmicro-ROS application. This group of packages organise in a layered architecture. Each layerhas particular functions, one layer deals with high-level concepts as nodes and executors andprovides developer API, other layer deals with the communications with micro-ROS Agent, and athird one provides enough OS and hardware abstractions to avoid library clients to worry aboutplatform details. These layers are defined later in this document.

The interface between a micro-ROS Stack and micro-ROS server uses the standard DDS-XRCE

21

Page 22: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

communication protocol, one of the many OMG specifications, which provides DDS similar interfaceto the micro-ROS Stack. It provides DDS object management interfaces as well as publish/subscribe;these interfaces are available to micro-ROS thanks to the middleware implementation used here, MicroRTPS which architecture is out of the scope of this document.

micro-ROS Stack, a part of hiding the middleware implementation, hides its users from details on OSinterfaces and hardware. The micro-ROS Stack is intended to run over an RTOS on limited resourcesdevices.

4.6.2 Components - micro-ROS Stack

The following diagram shows the micro-ROS Stack components from a functional point of view.

Figure 5: micro-ROS Stack all components

22

Page 23: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Figure 6: micro-ROS Stack node components

These are each component:

Node: The central concept of micro-ROS platform and the entry point of the micro-ROS Stack,constituting the basic building block for micro-ROS applications allowing the users to have access to allthe other components. The users can associate components with the nodes, so when the executor runsthe node, its contained components get updated. For communicate with other nodes in the system,micro-ROS nodes or ROS2 nodes, this component uses communication components. Nodes expose andconsume services and could have configuration parameters associated with it.

Executor: Node execution triggers nodes and pushes components updates. In a micro-ROS environ-ment, there is only one kind of executor, single thread sequential executor. The executor runs all itsnodes updating all its timers, publications, subscriptions, attending to services calls and triggering the

23

Page 24: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

needed events.

Figure 7: micro-ROS Stack services components

publisher: One of the core functionality of micro-ROS is to provide communication with existingnodes, this is achieved, in part, using publishers. Publisher allows writing data to DDS global dataspace. This data is exposed in DDS, by the micro-ROS Agent on behalf of the publishing micro-ROSnode which handles the data to micro-ROS Agent using DDS-XRCE protocol. Once in DDS space,all other nodes have access to the published data. This component is the, along with subscriber, theonly one with direct communication with micro-ROS Agent and constitute the basis for all the othercomponents functionality. Publishers could communicate with other nodes within local space as couldbe nodes within same process or same MCU and also can communicate directly with other micro-ROSnodes without the need to reach DDS space; this will consist on peer to peer communication which isprovided by the middleware underneath.

subscriber: This component is the other part of the core functionality of micro-ROS, allowing thereception of data coming from publishers from other nodes. This data is exposed in DDS, by ROS2nodes or by a micro-ROS Agent on behalf of other micro-ROS nodes and it is read through micro-ROSAgent using DDS-XRCE protocol which ends passing it to the subscriber. Again almost all the othercomponents build on top of this one. Subscribers could communicate with other nodes within localspace as nodes within same process or same MCU. Subscribers could communicate with other nodeswithin local space as could be nodes within the same process or same MCU and also can communicatedirectly with other micro-ROS nodes without the need to reach DDS space; this will consist on peer to

24

Page 25: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

peer communication which is provided by the middleware underneath.

service_server: micro-ROS nodes can create services servers which exposes a service callback toother nodes. This service implementation is a composition of a subscription and a publisher, receivingrequests and sending responses respectively.

service_client: on the other end of a service it is always a service client. micro-ROS nodes use othernodes services thorough service clients who are composed by, a publisher sending user requests, and asubscription receiving service call responses.

25

Page 26: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Figure 8: micro-ROS Stack parameters components

Parameters Manager: This component has the responsibility of the storage and handle of nodesspecific parameters connecting directly with the parameter server residing on the micro-ROS Agent.Parameter manager acts as a cache to that parameter server on micro-ROS Agent performing transparentuser synchronisation between them. Users can use parameter manager interface to add, change andquery node parameters.

26

Page 27: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Figure 9: micro-ROS Stack graph components

Graph Manager: This component is responsible for providing needed tools for the introspection ofthe node graph which reflects current nodes and entities available on the whole system, including ROS2nodes and ROS2 created objects. Graph manager as parameters manager uses the same client-serverarchitecture where graph manager queries on micro-ROS Agent graph server. Users of graph managercan subscribe to graph changes updates which the graph server triggers on micro-ROS Agent once achange in node graph is detected.

Lifecycle and system modes: This component provides nodes with states and transitions followingthe ROS2 node lifecycle FSM [8]. Furthermore, it allows handling node-specific sub-modes of the activemode and the corresponding transitions. State changes are published on a standard topic and servicesto request possible states, transitions and to request state changes are provided.

The mode manager is a distributed component. At start-up, it reads a formal specification of thesystem, possible sub-systems and their modes composed of the individual nodes, their states and theirparametrisations.

27

Page 28: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Figure 10: micro-ROS Stack time components

Timers: micro-ROS provides a different kind of timer abstractions to be chosen by the user accordinglyto their requirements.

Among these timers, there are OS and HW timers and also a micro-ROS specific timer. This micro-ROStimer is implemented based on a time difference, calculated according to a micro-ROS provided clock.As almost all timers do, when a timer expires, it calls the user-provided callback.

Clocks: micro-ROS provides a way to set how nodes measure time. This time measure is done based

28

Page 29: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

on a time source. Different time sources are available: system clock, steady clock or micro-ROS clock.The micro-ROS clock takes the time read from a time server that could be running on a different node.This micro-ROS clock allows to have full control over the time, pause, stop, go forward, go back, speedup. However, the use of micro-ROS clock could break real-time deadlines and determinism. This clockand time source system allow node clock synchronisation between nodes, and it is done using a definedtime server and a custom time source.

Figure 11: micro-ROS Stack log components

Logging utilities: There is a logger per each node which writes logging info thanks to the use oflogger writers. This logger writer allows logging using different mechanisms. For example, a DDStopic publication could be the target of a micro-ROS logging writer. The application defines the loggerwriters depending on its purpose and requirements.

29

Page 30: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

4.6.3 Components - micro-ROS Agent

The following diagram shows the micro-ROS Agent components.

Figure 12: micro-ROS Agent components

Agent core: this component provides micro-ROS Agent main functionality providing the mechanismto communicate DDS with micro-ROS Stack. An agent core could hold any number of micro-ROSStack connections keeping the state of micro-ROS clients, freeing them of that duty, allowing them to,for example, follow sleep cycles.

Parameter server: micro-ROS nodes use parameters for configurations in a client-server architecture.This parameter server provides those nodes of their configurations storing parameters per node andproviding interfaces to access and modify them. This parameter server is as wholly decoupled part frommicro-ROS Agent core which provides high deployment flexibility, for example allowing the parameterserver to be on a wholly separated node.

30

Page 31: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Graph server: micro-ROS Agent graph server provides introspection tools to micro-ROS Clients. Asa client-server architecture, these introspection tools allow clients to query the system graph. Part ofthe system graph this server provides is queries on topic names and types, services names and types,node names, and publishers and subscribers counts.

4.7 External Interfaces

4.7.1 Node interface

Node provides the entry point to the users and interfaces over the other components:

• Node with micro-ROS application: Nodes are the building blocks for micro-ROS applications.These applications can create nodes. The application can create other kinds of micro-ROS entitiesusing this created nodes:

* Publishers.* Subscriptions.* Service clients.* Service servers.* Parameters manager.* Graph manager.* Timing Services and clocks.* Logger.

Along with creation, micro-ROS Node interface allows the use of other components. When themicro-ROS scheduler run node update, nodes process all communications and components thenodes have updating them. During this update, nodes call registered user callbacks if needed.

• Node with publisher and subscriptions: Node allows the creation of publishers and sub-scriptions storing and handling them. Nodes trigger publications and subscriptions callbackswhen they are updated by executors.

• Node with parameter manager: Nodes provide the user with an interface to its parametermanager to be able to query and modify specific node parameters.

• Node with services: Node provides creation of services servers and clients. Nodes exposeuser-created services and use user callbacks when services request are detected and also handleservice consumption for the user, and it sends user requests.

• Node with timing services: Nodes provide an interface to create timers associated with them.Nodes updates micro-ROS controlled timers (no HW or OS) and triggered their callbacks ifneeded.

• Node with logging utility: Nodes have an associated logger providing an interface with themallowing the use of different log levels and destinations.

• Node with graph manager: Nodes provide the user with introspection tools which queryservices and subscriptions with the graph manager.

4.7.2 Publisher and subscribers

We group this two components interface under the same category. Publishers and subscribers interfacewith micro-ROS agents and on the other end with user code.

31

Page 32: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

• publisher with micro-ROS Agent: Publishers send user messages over topics; this publicationis achieved using DDS-XRCE protocol between micro-ROS Stack and micro-ROS Agent. Thisway a publisher can send a message over a DDS topic using micro-ROS Agent as a bridge betweenmicro-ROS Stack inbound message using XRCE-DSS and DDS world. In this communicationdata is serialised using DDS-XRCE defined serialisation protocol, CDR. Publishers, using MicroRTPS middleware, send CDR serialised DDS-XRCE to micro-ROS Agent, who publish CDRserialised DDS message for the rest of system nodes.

• subscription with micro-ROS Agent: Subscribers receive up to date data from the micro-ROS Agent in the same fashion publishers send data, using DDS-XRCE. micro-ROS Agentsends data back to subscribers if they previously have requested that data, this send back istriggered during subscription owner node update. micro-ROS Agent sends DDS-XRCE messagecontaining the user relevant topic message which is CDR serialised, so micro-ROS deserialise itupon reception.

• subscription with micro-ROS Application: Once the micro-ROS scheduler executes a nodesubscription, if any new message is there, the subscription notify the user, making use of apreviously configured callback.

4.7.3 Service, server and client

micro-ROS offers an RPC interface. Service servers and clients interfaces this mechanism followingtraditional RPC request/response pattern.

• server with subscriber: The user can create micro-ROS service servers which generate asubscription to the service request topic.

• server with micro-ROS application: Upon reception of a message in a service subscription,micro-ROS trigger the user service implementation. This user implementation processes all theinput and generates a response for the client.

• server with publisher: Along with a subscriber, a micro-ROS service server creates a ded-icated publisher. This dedicated publisher pushes all the responses generated on user serviceimplementation back to the service client.

• client with micro-ROS application: The interface between this to elements is a two waysinterface. Server-client users send requests to a service server, and they receive the responses.Users receive server responses by calls to callbacks they previously provided.

• client with publisher: micro-ROS clients integrate a publisher of service requests internally.Users trigger this publication by a user call in which they provide a callback. Such callbackhandles the response once it arrives.

• client with subscriber: service requests receive responses on a service responses topic. A clientof a service subscribe to this topic and handle the responses calling to user callbacks.

Service client interface with the micro-ROS application could is either asynchronous or synchronous.Upon asynchronous implementation, the application should decide and configure the number of requestswaiting for responses. Synchronous responses handling should be made trying to adjust as max aspossible to the real-time requirements of the application.

4.7.4 Parameters manager

Parameters manager interfaces with multiple components:

32

Page 33: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

• Parameter manager with micro-ROS application: micro-ROS users can subscribe toparameters changes triggered from external changes on parameters. These changes are changes onthe node parameter manager or alterations propagated from parameter server on the micro-ROSAgent. Whatever the source of the change, the user gets noticed of these changes by a call totheir callback. Parameter manager also provides users interface to add, remove, edit or queryparameters.

• Parameter manager with publisher: Parameter manager uses publishers to send notificationson parameters changes. A change of parameters triggers an event publication.

• parameters with service client: Parameter manager provides the user methods to callparameters services from other nodes. This interface allows parameter manager to consume otherparameter managers or parameter server services. This interface, as a regular micro-ROS serviceclient, ends up using a publication and a subscription to services topics.

• parameters with service server: Parameters manager expose different methods to access,modify and query parameters from other nodes. The interface to access parameters from othernodes uses micro-ROS services.

4.7.5 Graph manager

Graph manager interfaces with node and with graph server stored in micro-ROS Agent.

• Graph manager with Micro-ROS application: micro-ROS users can query on the statusof the system node graph. Graph manager provides the users with information on the differentgraph actors: nodes, publisher/subscribers, services and topics.

• Graph manager with service_client: The graph manager uses services provided by micro-ROS Agent. The graph server exposes these services on micro-ROS Agent.

• Graph manager with subscriptions: The user can subscribe to graph changes on the graphserver. This subscription is provided locally by graph manager, and it uses callbacks to notifyusers of graph events.

4.7.6 Timers and Clocks interfaces

Timers and clocks interfaces with mainly external software and hardware systems.

• Timers with micro-ROS application: The user can create timers and provide them with acallback method to be called once the timer expires. Timers could be different depending on theneeds. There are micro-ROS timers, RTOS timers or hardware timers.

• Timers with OS: By default, timers try to use OS provided timers. Doing so makes sure timersfollow the real-time scheduling of each OS.

• Timers with Hardware: Timers implementation could be done directly with hardware tech-nologies, hardware timers. Implementing hardware timer is only done when the OS does notsupport timers. This implementation is dependent on the hardware platform using IRQ to handlethese timers.

• Clock with Subscriber: Clock main functionality is to provide time provided by a time source.When the time source is chosen to be a micro-ROS clock, time source is a based on a time serverfrom another node which publishes time updates over DDS. Nodes subscribed to the time topicuse it as the time source.

• clock with OS: Clock abstractions could use this interface to access to OS clocks.

33

Page 34: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

4.7.7 Executor

Executor unique interfaces are with the micro-ROS application and with node. The interface withmicro-ROS application allows the user to add, remove and query nodes within the executor. Once theuser has added all the desired nodes, they can trigger spin method to update all the containing nodes.Spin methods use the interface with nodes. This node side interface allows the executor to updatecommunications, trigger callbacks and update node timers.

RTOS abstraction

In commonly used software stacks, like microRTPS, the middleware accesses functions of the operatingsystem directly. Such functions typically include scheduling, memory management and communication.This dependability is hindering porting micro-ROS to different hardware platforms which usually comewith their own real-time operating system. To improve the portability and usability of micro-ROS, anRTOS abstraction layer is introduced, as shown in section #micro-ros-client-library.

RTOS Syntax Encapsulation

The RTOS abstraction shall encapsulate the RTOS functions and shall provide generic access methodsfor the higher application layer for * scheduling (create task, set priority, stop task, define timer) *memory management (memory allocation) * communication (e.g. TCP/IP, serial other protocols)

This could be implemented by two different approaches a) a code generator or by b) an API. In thecode generator approach, low-level RTOS calls will be generated for a middleware access. RTOS specificsyntax is hidden in the code generator. No changes or extensions of the RTOS is necessary.

In the API approach, a POSIX-like API is expected by the middleware and needs to be provided bythe RTOS. For POSIX-like OS, this may be simple, however, the effort might be larger for non-POSIXlike OS, like micrium-OS.

Smart Scheduling

The usability on application level is enhanced through such RTOS abstractions, not only becauseRTOS-specific syntax is hidden, but most importantly by separating requirements from implementationdetail. The user shall define performance application requirements, such as criticality, deadline andrate. The RTOS abstraction layer shall analyse these requirements and shall assign the appropriatescheduling parameters offered by the operating system. For example, based on criticality level of anapplication and all other application requirements, an appropriate task priority shall be selected.

4.7.8 Lifecycle and system modes

The interfaces exposed by nodes with regard to the node lifecycle are:

• Lifecycle sub-states input: When using extended mode management or more advanced flavours(cf. Section 3.2), a list of sub-states of the standard active state is read from a node leaflet atstart-up.

• Lifecycle publisher Changes of the lifecycle state of a node are published on a standard topic.• Lifecycle query services This service interface allows to query available states, current state

and available transitions.• Lifecycle transition service Also, each node provides a service to trigger a transition changing

the node state.

The interfaces exposed by the mode manager (only in extended mode management flavour and above)are:

34

Page 35: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

• System model input At start-up, a model of the application-specific system hierarchy in formof sub-systems and nodes and modes on the system and sub-systems level is read from the systemleaflet.

• System mode publisher Mode changes are published on a standard topic.• Mode query services This service interface allows to query available (sub-)system modes and

available transitions.• Mode change services Nodes (in particular from the executive/deliberation layer) may request

mode changes via this interface.

4.7.9 Logging utilities

Logging interfaces depend highly on logging writer implementation.

• Logging utilities with micro-ROS application: Logger triggers a call to the user definedlog writer callback.

4.7.10 Agent core

Agent core is the central piece of the micro-ROS Agent. It has multiple interfaces:

• Agent core with micro-ROS stack: Agent core sends and receives data from micro-ROSStack using DDS-XRCE protocol.

• Agent core with ROS2 application: Agent core sends and receives data from other ROS2nodes using DDS protocol.

• Agent core with parameters server: Agent core sends and receives data from parametersservers using DDS protocol. External ROS2 applications could act as parameter server.

• Agent core with graph server: Agent core sends and receives data from graph servers usingDDS protocol. Same as the parameter server, an external ROS2 applications could act asparameter server.

4.7.11 Parameter server

Parameter server provides services and events interfaces:

• parameter server with agent_core: Parameter server uses DDS to provide access to para-meters to the micro-ROS client using Agent core as an enabler.

4.7.12 Graph server

This component provides interfaces that make introspection possible:

• graph server with agent core Graph server provides introspection service. This service server,upon reception of an introspection operation, queries the graph maintained in the agent core andthen it sends the response using agent core communications.

35

Page 36: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

4.8 Code

4.8.1 micro-ROS Stack

micro-ROS Stack code is structured in a layered fashion, as shown in the following diagram.

Figure 13: micro-ROS client

4.8.1.1 RTOS layer

A micro-ROS client runs on top of a real-time operative system. In this project, we use NuttX. NuttXmainly provides a POSIX-like interface. micro-ROS delivers and RTOS abstraction layer over thisplatform specific interface. This abstraction layer provides the upper layers with the functionality theyneed.

The RMW implementation layer uses this layer.

4.8.1.2 Middleware layer

36

Page 37: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

RMW layer is composed of an abstract API (RMW) and its implementation (RMW implementation).

This layer provides basic middleware functionality: publish/subscribe, services (request-reply) andserialisation of message types. The upper layers use this middleware API on the micro-ROS librarystack. This API abstraction allows hiding implementation and vendor specific details to the user.

This abstract API has a default implementation using eProsimas’s XRCE protocol implementation, MicroRTPS. This implementation resides on the rmw_implementation layer. This rmw_implementationlayer is responsible for providing discovery as well as inter-process communication optimisation avoidingunnecessary wire interactions.

The middleware API provided by RMW layer to the upper layers should be similar to the one producedby its analogous to ROS2.

4.8.1.3 Library layer

This layer provides micro-ROS API to the user application. This layer is composed of a pair of libs,RCL and a C implementation of high-level ROS2 concepts, RCLC.

RCL library provides primary and shared services. This library implements logging, the handle ofparameters, time functionality, names and namespaces handling. These services are the same servicesthis layer provides in ROS2.

RCLC extends RCL layer with ROS2 specific concepts as nodes, executors and graph handlers. ThisRCLC is the end-user interface. Thus it provides access to lower layers concepts as timers, logging.

4.8.1.4 Layers and components

As a link between components and layers, the following diagram shows micro-ROS Stack componentsover the layers with they are related.

Figure 14: micro-ROS layered components

4.8.2 micro-ROS Agent

micro-ROS Agent is a ROS2 package. As the essential part of the package, there is micro-ROS AgentCore which provides a Micro RTPS Agent allowing communication between DDS and DDS-XRCE.Optionally and depending on the profiles and configuration required, along with micro-ROS Agent core

37

Page 38: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

users could use a parameter server and/or a graph server. Both servers provide ROS2 server interfaceto query parameters and node graphs respectively.

4.9 Infrastructure Architecture

This section provides information about the infrastructure architecture of the micro-ROS platform.

4.9.1 infrastructure

micro-ROS platform main purpose is to connect ROS2 applications with applications running onmicrocontrollers. Following this crucial principle, we based the infrastructure on microcontrollers. Thisproject already define reference platforms in the D2.1 Report on the reference hardware developmentplatforms. Document.

A sample of infrastructure is:

• Reference board: Olimex E407.– Real-time Operating System: NuttX.– I/O: Serial or radio based. (UART, 6LowPAN)

• Main computer: General purpose computer.– Operating System: Linux or Windows.– I/O: Serial or radio based. (UART, 6LowPAN)

This infrastructure is a sample, as the micro-ROS platform is mainly a generic framework, the finalinfrastructure depends on the user application.

4.10 Deployment

This section provides information about the mapping between the software and the infrastructure.

4.10.1 Deployment

This diagram represents schematically how is a micro-ROS platform deploy.

38

Page 39: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

Figure 15: micro-ROS Deployment

39

Page 40: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

The diagram represents a sample of deployment. In this sample, we show a single microcontroller addedto a ROS2 system. Multiple microcontrollers deployment is possible.

4.10.2 Build system

The micro-ROS platform uses same build system as ROS2. Using ament as build system allow to sharepackages with ROS2 implementation. micro-ROS adds multiple packages to existing ROS2 packagecollection. These micro-ROS dedicated packages have the same configuration options as the ROS2.

Build system provides configuration methods for fix the statical memory used by the system. Alongwith providing static memory configuration, the build system incorporates the selection of micro-ROSprofiles.

4.10.3 Profiles

4.10.3.1 micro-ROS profiles

Users could select the profiles they want at build time. This lead to a modular build which only buildsthose system parts needed by profile configuration.

The following table shows a possible list of the profiles and the components.

puresender

purereader

configurablesenderwithdiagnostics

ad-hocdiscover-ablesender

static con-figuredsender

managedservice

simulationnode

nodes x x x x x x xlifecycle xpublish x x x xsubscribe xservices xtimersclocklogging xparameters xexecutordiscovery x

new profiles could be defined by the user to adjust to their applications needs.

4.10.3.2 Middleware profiles

Apart from micro-ROS profiles, DDS-XRCE standard defines a set of profiles modularising the mid-dleware capabilities. In the micro-ROS platform, these profiles are also configurable per middlewareimplementation.

• Read Access profile. Provides the clients with the ability to read data on pre-configured Topicswith pre-configured QoS policies.

• Write Access profile. Provides the clients with the ability to write data on pre-configured Topicswith pre-configured QoS policies.

40

Page 41: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

• Configure Entities profile. Provides the clients the ability define DomainParticipant, Topic,Publisher, Subscriber, DataWriter, and DataReader entities using pre-configured QoS policiesand data-types.

• Configure QoS profile. Provides client with the ability to define QoS profiles to be used by DDSentities.

• Configure types profile. Includes middleware client the ability to set data types to be used forDDS topics.

• Discovery access profile. Provides the middleware clients to discover entities.• File-based configuration profile. micro-ROS Agent core could be configured using a file system.• UDP Transport profile. It provides UDP transport.• TCP Transport profile. It provides TCP transport.• Complete profile. It allows the complete functionality of the middleware.

Micro-ROS profiles require some of the specific middleware profiles. This profile dependencies areresolved automatically at build time selecting those middleware profiles required by micro-ROS profiles.

This table represents dependencies between micro-ROS components and Micro RTPS profiles.

micro-ROS/MicroRTPS

readaccess

writeaccess

configureentities

configureQoS

configuretypes discovery

fileconfiguration udp tcp complete

nodeslifecycle x xpublish xsubscribe xservices x xtimersclockloggingparameters x xexecutordiscovery x

4.10.4 Test system

The intended modularity of micro-ROS, apart of helping with deployment configurations, it greatlyhelps to the testability of the whole system. micro-ROS should provide test per each component.components interfaces are tested to verify the correctness of the functionality provided by it. Unit testsare recommended but not mandatory. The micro-ROS packages also have test so that the users canverify the correctness of the package interfaces.

5 Appendix

5.1 A1 Related documents

Scenarios and requirements definition: D1.7 Reference Scenarios and Technical System RequirementsDefinition.

Hardware platform: D2.1 Report on the reference hardware development platforms.

41

Page 42: D1.4 Overall Architecture Definition – Initialofera.eu/storage/deliverables/OFERA_D1.4_Overall... · D1.4OverallArchitectureDefinition–Initial Grantagreementno. 780785 Projectacronym

D1.4 Overall Architecture Definition – Initial

References

[1] S. Brown, Software architecture for developers: Volume 1 - technical leadership and the balance withagility. Leanpub, 2018.

[2] S. Brown, Software architecture for developers: Volume 2 - visualise, document and explore yoursoftware architecture. Leanpub, 2018.

[3] astralien3000, ‘Riot-ros2’. 2018 [Online]. Available: https://github.com/astralien3000/riot-ros2

[4] M. Ferguson, ‘Rosserial’. 2018 [Online]. Available: https://github.com/ros-drivers/rosserial

[5] T. Lab., ‘Mros’. Kyoto University, kyoto, 2018 [Online]. Available: https://github.com/tlk-emb/mROS

[6] S. Brown, ‘The c4 model for software architecture context, containers, components and code’. 2018[Online]. Available: https://c4model.com/

[7] I. TOPPERS Project, ‘TOPPERS’. [Online]. Available: https://www.toppers.jp/en/project.html

[8] ‘ROS2 design’. Open Source Robotics Foundation, Inc. [Online]. Available: http://design.ros2.org/

42