Model-Based Design of Distributed ROS2 Systems Using IEC 61499
Model-Based Design of Distributed ROS2 Systems Using IEC 61499
Abstract—ROS2 systems are distributed applications built language from the domain of industrial distributed control
from strongly isolated components (nodes). Communication is systems, IEC 61499. This language was designed to express
realized through a publish/subscribe mechanism. Despite having application functionality in an event-based model of computa-
these modern software architecture elements, ROS2 has no
canonical modelling language that captures overall application tion. It is based on a component model that is similar to ROS
design and helps in mapping nodes across distributed plat- nodes, and it supports native modelling of publish/subscribe
forms. We propose a model-based design approach based on communication. Using native IEC 61499 elements, higher-
the graphical programming language IEC 61499, mapping ROS2 level node interactions like services and actions can be mod-
constructs to native IEC 61499 model elements. Code generation elled in a clear and concise way.
creates native ROS2 nodes from IEC 61499 code. As an additional
benefit, this approach also eases integration of ROS2 systems with This paper is structured in as follows: The next section
non-ROS components. gives an overview of different activities in the area of ROS
modelling, with or without IEC 61499. Section III gives a short
I. I NTRODUCTION overview of key elements of IEC 61499 that are relevant to our
A popular software environment for robotics systems is proposed modelling approach, which we explain in Section IV.
the Robot Operating System (ROS), of which the newer After that, we discuss opportunities and shortcomings of this
major revision is often just called ROS2. In ROS, applications approach in Section V, and give a summary and outlook on
consist of multiple nodes, which are self-contained software future research in Section VI.
components. Nodes communicate through a publish/subscribe
message bus using strongly-typed messages. ROS is popular II. R ELATED W ORK
due to its rich library of available software components for
robotics tasks, ranging from complex routing and mapping There is little work on applying model-based design meth-
algorithm to low-level hardware drivers. odology to ROS applications. The most obvious approach is
A major shortcoming of the ROS ecosystem is the lack to use SysML as a modelling language, which is presented in
of a canonical model-based design flow. By default, overall [1]. The authors propose a new SysML profile to describe all
application behaviour is not explicitly modelled, it is an details of a ROS system. The main difference to our approach
emerging property of how individual nodes were programmed. is that effectively, the authors create a new domain-specific
This is most noticeable with communication: Despite having language, whereas our proposal maps to an existing language
a rich communication middleware at its heart, ROS nodes and thus reduces the learning curve.
only send and receive individual messages. The orchestration A similar distinction can be made regarding [2], where the
and interaction of nodes is not an integral part of application authors model ROS systems using the Architecture Analysis
design, obscuring the overall control flow created by the and Description Language. However, they only apply their
individual nodes that make up the system. The mapping of idea to a specific use case class and do not strive for feature-
nodes across a distributed system is not addressed at all. completeness regarding arbitrary ROS applications.
For building complex ROS application, this reduces express- The closes work to our proposal is presented in [3],
iveness of developers, self-documenting properties of the code, which also uses IEC 61499 as a host language. Similar to
and maintainability. A popular approach would be to use a the preceding example, however, the authors assume a spe-
Model-Based Design methodology to design complex cyber- cific overall system architecture using a higher-level tool and
physical systems, but there is no canonical way to do so in method, using IEC 61499 only as an intermediate language.
the ROS community. Our approach aims at avoiding the introduction of additional
An obvious approach would be to use UML or SysML. The model/abstraction layers and using IEC 61499 as true origin
main drawback of these is that while they have many different language for arbitrary ROS applications. Our assumption is
model types to design various aspects of the system, they lack that users who need another abstraction layer on top of
clear executable semantics to express the intended control flow IEC 61499 (like SysML) will already have a tool/method of
of the application. choice. By using native IEC 61499 functionality, our approach
For this reason, we propose a model-based design approach can be integrated easily into complex multiple-language scen-
for ROS2 based on a model-based control application design arios.
Authorized licensed use limited to: JILIN UNIVERSITY. Downloaded on December 16,2024 at 12:08:11 UTC from IEEE Xplore. Restrictions apply.
containing portable code written in IEC 61131 Structured
Text (ST) [5].
• Subapplications allow hierarchical modelling by encap-
sulating a function block network just like a top-level
application.
• Service interface function blocks (SIFB) represent device-
specific functionality, usually implemented in native code.
They can create events from external sources, while all
Figure III.1: IEC 61499 System model that is used for all other FBs can only create events as response to an
examples incoming event.
In the graphical representation, FBs have a notch at the
side, which separates connection points (called P INS) for
events (top) from data pins (bottom). Inputs are on the left
side, outputs on the right side. Colours refer to the devices
of the system model and specify where an FB should be
executed. Lines denote communication between FBs, text
Figure III.2: IEC 61499 Application model of a simple applic- denotes constant values in IEC 61131 syntax. Dashed lines
ation. A controller controls a motor in a 100ms loop based on denote non-local communication, i. e. true network communic-
data from a distance sensor. ation, whereas on-device communication uses solid lines. Line
colours represent different data type classes. Beyond simple
event and data connections, there is also the A DAPTER. An
III. BACKGROUND adapter combines multiple bidirectional event and data edges
IEC 61499 (hereafter abbreviated as just 1499) is a graph- in a single connection, which we use heavily to represent ROS
ical programming language for industrial distributed control communications.
systems that is suitable for model-based and model-driven The primitive data type system of 1499 is the type system of
design flows [4]. It is a modern replacement for the standard IEC 61131. It is comparable to the type system of common lan-
IEC 61131 [5], which is still the dominant way to program pro- guages like C++ and has integers of various widths, floating-
grammable logic controllers (PLCs). In order to ease system point values, strings, time and date values, and compositions
upgrades, 1499 reuses much of IEC 61131, most importantly in the form of fixed- or variable-size arrays and structs [5].
the elementary data types. IV. M ODELLING A PPROACH
A 1499 project consists of one S YSTEM model and multiple
A PPLICATION models. Our proposal for modelling ROS2 applications using the
graphical language IEC 61499 stems from the observation
The system model describes the execution devices that are
that all important elements of the ROS2 software ecosystem
available to run the applications. Figure III.1 shows a system
map to 1499 elements in a natural and direct way. We focus
model consisting of four devices and one network segment
exclusively on modelling ROS applications in IEC 61499, not
connecting them, as rendered by the open-source IEC 61499
on mapping arbitrary IEC 61499 applications to ROS.
implementation Eclipse 4diac [6]. System models contain
All examples shown in this section are models created in
some more information that is not relevant to this paper.
the open-source IEC 61499 implementation Eclipse 4diac and
Application models describe functional behaviour. Applic-
use the system model shown in Figure III.1.
ations are independent from each other and can run across
multiple devices. Devices run multiple applications concur- A. Mapping ROS Nodes
rently, under control of an implementation-defined scheduling ROS nodes encapsulate all executable functionality. They
algorithm. primarily react to incoming messages, but they can also create
Applications consist of a network of F UNCTION B LOCKS messages in an asynchronous fashion, not as a causal result of
(FBs) connected by edges representing events and data. FBs an incoming message. In 1499, function blocks have the same
encapsulate executable behaviour, event connections define role and very similar properties.
execution control, and data connections define data flow. The The main difference between both is that communication
execution model is strictly event-based, i. e. FB execution is separates events from data, whereas a ROS message can be
triggered by receiving an event, and FBs can send out new interpreted as a tuple of an event (sending/receiving the mes-
events as part of their execution. Figure III.2 shows a typical sage itself) and multiple data values. In 1499, the Adapter is
example of a simple control application. a model element that can represent this composition naturally.
Function blocks come in different variants. Three of them As a result, a 1499 application that represents a simple ROS
are important for this paper: system could look like Figure IV.1. This example also shows
• Basic function blocks (BFB) encapsulate behaviour as the first benefit that goes beyond ROS2 expressivity: easy
a state machine (called Execution Control Chart, ECC) specification of the distributed nature of the application.
516
Authorized licensed use limited to: JILIN UNIVERSITY. Downloaded on December 16,2024 at 12:08:11 UTC from IEEE Xplore. Restrictions apply.
Figure IV.1: Simple ROS application modelled in IEC 61499 (a) ROS::std_msgs::Header
517
Authorized licensed use limited to: JILIN UNIVERSITY. Downloaded on December 16,2024 at 12:08:11 UTC from IEEE Xplore. Restrictions apply.
Figure IV.7: Single-Publisher Multiple-Subscriber scenario
Figure IV.5: IEC 61499 adapter definition for a ROS action
518
Authorized licensed use limited to: JILIN UNIVERSITY. Downloaded on December 16,2024 at 12:08:11 UTC from IEEE Xplore. Restrictions apply.
b) Template code generation: Instead of using preexist-
ing ROS nodes, 1499 function blocks contain enough inform-
ation to generate a template implementation of a ROS node
including its communication interface. Developers then only
need to fill in the actual behaviour code. This eliminates cre-
ating boilerplate code and ensures consistency in the interface
between multiple nodes across the application.
c) Full code generation: Developers could also exploit
the full expressivity of IEC 61499, most notably the ability
to mix textual (C++) algorithm descriptions with ECC state
machines. In this level, developers would not need to manually
build ROS code at all: The full ROS application can be
generated from the IEC 61499 model.
Figure IV.10: Advanced distributed control scenario d) Code generation with portable algorithms: IEC 61499
includes a standardized, portable programming language for
textual algorithms, Structured Text. It is simple enough to
(SWARM_DriveDecision at the bottom right). Likewise, translate it to native C++ code (as done by Eclipse 4diac).
the local control algorithm receives all swarm member position While it may seem counter-intuitive to force developers to
(SWARM_SensorFusion at the bottom left) as input for its learn a new language, this approach allows heterogeneous
autonomous drive decision. systems that are not restricted to the ROS runtime. In such
The most notable modelling extension is the representation an application, individual nodes can be mapped to a native
of an unspecified number of external devices through function IEC 61499 device, e. g. a PLC that supports 1499 natively.
blocks mapped to a dummy ‘SWARM’ device. These FBs
are not actually part of the application’s behaviour. They only V. D ISCUSSION
serve documentation purposes, clearly marking the topic as Overall, it is easy to see that IEC 61499 and ROS2 are a
having n:m topology, and documenting the intention that the good match. ROS middleware elements map to 1499 model
other swarm members use a very similar, if not the same, elements in a straightforward way. The reverse is not true,
software architecture. however. IEC 61499 allows many more constructs that are not
5) Distributed Control: As a final scenario, Figure IV.10 covered by our proposed modelling approach.
shows another n:m topology, but one with a feedback loop. In The graphical models clearly express developer intent on a
this scenario, drive decisions by the swarm are performed in suitable abstraction level, with a strong focus on application
a truly distributed manner, with each controller updating all composition. We did not present full details on modelling ROS
other controllers about their decisions as their state evolves. node behaviour, but initial experiments show that the ‘full
This would be suitable for coordinated task planning without code generation’ automation level is viable: A prototypical
central controller. It has no new modelling patterns, but it does tool implementation can generate clean and correct C++ ROS2
show that models can get crowded if a lot of feedback is code for simple ECC state machines and communication
involved. Robotic control software engineers should make sure patterns. We have not yet performed a systematic evaluation
to use proper abstractions to avoid spaghetti code (which, in of corner cases and limitations, however. We also did not yet
a graphical language, should be taken quite literally). explore the ’portable algorithms’ automation level.
A big advantage of our approach is the fact that the models
F. Deployment themselves are executable. They have clear semantics (within
Modelling ROS systems in a model-based language is the limits of IEC 61499, which does have some undefined
only half the story. After creating these models, the question areas), which allows early testing of interaction patterns long
remains how robotic software engineers can run the ROS before the final behaviour is implemented or even the commu-
applications they have designed. The intention of our approach nication interfaces are fixed. Tools like the Eclipse 4diac IDE
is heavy use of automatic code generation. There are different built-in simulator [7] can do so without having to generate
levels of automation with different manual and tool effort: ROS code at all.
a) Deployment and composition aid: The IEC 61499 A second notable advantage is the potentially tight integra-
model contains all information required to create .launch tion of industrial control systems with robotics applications.
files for preexisting ROS nodes. Unfortunately, ROS node Given that industrial robotics are a major part of the entire
source code does not allow generalized extraction of the robotics domain, this can make system composition much
communication interface. As a result, FBs representing ROS cleaner, faster, and more maintainable. Eclipse 4diac already
nodes must be manually created in a way that is compatible contains some parts to reach that goal: it has an initial
with their implementation. Message types of ROS are available implementation of the required communication infrastructure
in a format that allows automatic generation of equivalent 1499 so that native 1499 code can talk to ROS2 nodes via their
data type definitions, saving some work. native DDS protocol.
519
Authorized licensed use limited to: JILIN UNIVERSITY. Downloaded on December 16,2024 at 12:08:11 UTC from IEEE Xplore. Restrictions apply.
For the integration goal, it would also be interesting to
be able to migrate existing industrial control system code to
ROS. The presented modelling approach explicitly did not
address this use case. Nevertheless, many common interactions
between function blocks are compatible with ROS message
semantics (see Figure III.2 for a pretty typical example). Since
1499 models are on a high abstraction level, these cases
can be identified statically, opening the potential for seamless
introduction of ROS code into pure 1499 applications.
In general, static analysability is a final advantage of model-
based ROS application design. Methodologies for systematic-
ally ensuring functional and extra-functional system properties
work well with a fully model-based design flow, e. g. Contract-
Based Design [8].
VI. C ONCLUSION & F UTURE W ORK
We have presented a comprehensive modelling approach for
graphical, model-based design of ROS2 applications. We used
IEC 61499 as host language to express all basic ROS2 ele-
ments and showcased a variety of application patterns, clearly
demonstrating its advantage in readability and development
effort.
These models can be used for different levels of automated
code generation, from a simple deployment aid to a fully
model-based software development workflow. While basic
viability can be shown, corner cases and limitations of this
automation need to be explored in future work.
In the long run, our modelling approach allows tight integ-
ration of robotics applications with industrial control applic-
ations in typical factory settings and other systems utilising
industrial control equipment (e. g. maritime, railway).
ACKNOWLEDGEMENT
This research was partially funded by the Ministry of
Science and Culture of the federal state of Lower Saxony,
Germany under research grant number ZN3489.
R EFERENCES
[1] T. Winiarski, “MeROS: SysML-based Metamodel for ROS-based Sys-
tems,” IEEE Access, 2023.
[2] G. Bardaro, A. Semprebon, and M. Matteucci, “A use case in model-
based robot development using AADL and ROS,” in Proceedings of the
1st International Workshop on Robotics Software Engineering, 2018.
[3] M. Wenger, W. Eisenmenger, G. Neugschwandtner, B. Schneider, and
A. Zoitl, “A model based engineering tool for ROS component com-
positioning, configuration and generation of deployment information,” in
2016 IEEE 21st international conference on emerging technologies and
factory automation (ETFA), 2016.
[4] L. H. Yoong, P. S. Roop, Z. E. Bhatti, and M. M. Kuo, Model-Driven
Design Using EC 61499: A Synchronous Approach for Embedded and
Automation Systems. 2014.
[5] P. Neumann, SPS-Standard: IEC 61131: Programmierung in verteilten
Automatisierungssystemen. Oldenbourg Industrieverlag, 2000.
[6] The Eclipse 4diac Project, “Eclipse 4diac - The Open Source Envir-
onment for Distributed Industrial Automation and Control Systems,” in
https://www.eclipse.org/4diac, 2024.
[7] B. Wiesmayr, A. Zoitl, A. Garmendia, and M. Wimmer, “A model-based
execution framework for interpreting control software,” in 2021 26th
IEEE International Conference on Emerging Technologies and Factory
Automation (ETFA), IEEE, 2021.
[8] A. Sangiovanni-Vincentelli, W. Damm, and R. Passerone, “Taming
Dr. Frankenstein: Contract-based design for cyber-physical systems,”
European journal of control, vol. 18, 2012.
520
Authorized licensed use limited to: JILIN UNIVERSITY. Downloaded on December 16,2024 at 12:08:11 UTC from IEEE Xplore. Restrictions apply.