A Generic Synchronous Dataflow Architecture to Rapidly Prototype and Deploy Robot Controllers

The paper presents a software architecture to optimize the process of prototyping and deploying robot controllers that are synthesized using model-based design methodologies. The architecture is composed of a framework and a pipeline. Therefore, the contribution of the paper is twofold. First, we introduce an open-source actor-oriented framework that abstracts the common robotic uses of middlewares, optimizers, and simulators. Using this framework, we then present a pipeline that implements the model-based design methodology. The components of the proposed framework are generic, and they can be interfaced with any tool supporting model-based design. We demonstrate the effectiveness of the approach describing the application of the resulting synchronous dataflow architecture to the design of a balancing controller for the YARP-based humanoid robot iCub. This example exploits the interfacing with Simulink and Simulink Coder.


Introduction
In the past few decades, robotics has experienced a continuous shift from applications in constrained industrial environments to those involving autonomy, interaction, and collaboration with external agents. The adaptation of the robotic devices to new tasks often presents big challenges in both cost and time. Thus, the capability of prototyping a new controller and rapidly deploying it to the target robotic device is becoming more and more paramount. The canonical approach to develop a robotic controller can be summarized in two distinct phases. 1 In the first phase, the robotic controller is synthesized, tuned, analyzed, and possibly tested in a simulated environment. Arbitrarily complex models of the controlled system are typically exploited. In the second phase, the controller is ported to the real device, tuned again and executed. Each minor change to the controller requires iterating this entire process from start, and a lot of effort is spent to minimize manual operations.
Model-based design 2 (MBD) is a methodology that emerged to deal with the challenges introduced by the need to continuously improve complex systems. MBD aims to simplify the development by providing a common environment shared by people of different disciplines involved in the the different design phases. 3 Later changes of the original design either due to early mistakes or requirements modifications are easier to propagate, therefore time and cost of the development can be reduced. 4 A characteristic of the model-based design is that the iterative process of the continuous improvement is performed with unified visual tools, typically based on dataflow programming languages and frameworks. The dataflow naming originates from the view of programs as directed graphs of computations, where The application of MBD to robotic controllers development can narrow the gap between control engineers, used to approach systems with block diagrams, and software engineers, used to procedural and object-oriented programming. However, this approach is not exempt from the complications introduced by system integration, which often introduces time-consuming obstacles. Particularly for what concern robotics, actor-oriented programming languages by themselves are not the final solution. In fact, object-oriented programming still has a central role in the development of low-level algorithms. The aim of these actor-oriented languages is not substituting OOP, but complementing it. In fact AOP is more suitable to target the creation of applications that belong to higher abstraction layers, implementing a design principle compatible with the separation of concerns. 13,14 It represents a valid choice to ease the interconnection of self-contained black-box functionalities, which represent the building blocks of any robotic controller.
In this work, we propose a software architecture composed of a framework inspired by AOP and a pipeline for its application to robot controllers design. The framework intends to reduce the effort spent on system integration while minimizing both code and functionality duplication. The pipeline implements all the MBD stages and it aims to minimize the controllers lead time while automatizing as much as possible the prototyping and deployment processes. Rapid prototyping and continuous deployment are achieved interfacing the framework respectively with Simulink and Simulink ® Coder™. 15 Simulink provides out-of-the-box a wide library of black-box functionality exposed as blocks and also allows to be extended and integrated with external algorithms. Its status of visual programming and debugging is very mature and well documented. Simulink Coder provides the automatic code generation capability that aid the implementation of the deployment stage of MBD, removing the need to port or adapt the controller to another domain before being executed in the target platform. 16 Despite our tools selection, the framework has been designed in such a way to simplify the integration with other existing actor-oriented frameworks. The logic of the presented black-box functions (developed in OOP) is independent of them. This design allows to effectively separate the two programming domains while exploiting the best features from both.
More specifically, the work presented in this paper is based on a previously introduced framework. 17 From the status described in that work, the underlying software architecture considerably changed, but a big effort was spent to maintain as much as possible the same user experience. The whole-body interface layer proposed in the original work has been entirely removed, moving the responsibility of the robot abstraction to the middleware layer. Moreover, most of the improvements detailed in the same study have been adapted to the new architecture and implemented. Beyond a radical architectural advancement, the main extension presented in this work is the fulfillment of the automatic code generation support, fundamental to complete the implementation of model-based design.
The paper is structured as follows. First, we list tools and frameworks belonging to actor-oriented programming and implementing the model-based design pattern, and define a common terminology used throughout the paper. Then, we present the architecture of the proposed software framework and outline how we implemented AOP for robotic controllers design. Successively, we describe how the proposed framework can be exploited to obtain a pipeline that implements the typical stages of model-based design. We present a development cycle example for a balancing controller that targets a humanoid robot. We proceed by discussing the current limitations of this workflow and future improvements. Finally, we draw conclusions.

Related Software
Model-based design is a methodology that covers many software layers. Following a top-down view, the conventional unified tools typical of MBD usually share the following features: • Support to automatically generate real-time code from a model Providing a complete taxonomy of the existing tools and frameworks is not a trivial task. To simplify the analysis, we limit the overview to frameworks that use the synchronous dataflow model of computation, ignoring those that also support concurrent actors. Considering the scope of the current work, we separate the existing solutions in two categories: hybrid and discrete-only.
Hybrid tools are the most generic and complete, they typically allow performing both continuous and discrete simulations. Since they provide solvers for each of the two domains, hybrid tools can execute both offline simulations of continuous ODE systems and their discrete equivalent which is compatible with real-time usage.
Discrete-only tools, instead, target only discrete-time systems, and their execution is limited to call an equivalent step function. Given their discrete nature, this second category is compatible by design with real-time usage.
Given these definitions, engines that belong to the hybrid group are Drake, 18 OpenModelica, 19 and the commercial software Simulink, Dymola ®20 and LABVIEW. 12 Excluding Drake, all the others are unified visual tools which fully enter into the model-based design framework. Simulink, in particular, is the engine that became the de-facto standard for model-based design. It implements all the MBD stages providing great flexibility and very simple user experience.
Other available engines are represented by those that emerged in the context of software engineering for robotics, all belonging to the category of the discrete-only tools. These type of engines are typically designed to support the development of software that runs in real-time on a robotic platform, and so they do not support simulation-specific features such as continuous time system modeling. Examples of this software are Stack of Task's Dynamic Graph, 21 Genom3, 22 OpenRTM 23 and Orocos. 24 A features comparison of the tools listed in this section is shown in Table 1.
For what concerns the deployment stage of MBD, we can identify few suitable frameworks that provide support of automatically generate code. The scope of this process is to convert a model prototyped as a directed graph to a low-level procedural representation. Nowadays, automatic code generation is a standard feature of the MATLAB system. The Simulink Coder toolbox allows generating optimized C and C ++ code from a Simulink model, and it provides support to customize the sources injecting custom code during the generation process. Other frameworks that are worth mentioning are most of the software suites based on the Modelica 11 language, which typically support generating low-level code from their models.
The Functional Mock-up Interface 25 (FMI), despite being outside the categorization described above, is still relevant to this overview. FMI is a standardized interface widely used in industry for model-based development. It is a feature-rich and production-grade tool with a clear standard, constantly improving at each release but, as most of the tools listed in this section, it was not available when we started the development of our software stack. In any case, its adoption in its current form would not be possible due to the lack of the support of vector messages between actors, shortcoming that will be removed in the upcoming version of the standard.

Software
Hybrid Visual Tool Code Generation Real-time Native Open Source  Figure 1: Visualization of the implementation of an actor: the block.
Other interesting frameworks for controllers design which are related to the cited engines are the Robotic Toolbox 26 and the Robotic System Toolbox. 27 The latter, particularly, is one of the few unified framework that fully implements MBD specifically for robotic controllers. It is based on the ROS 28 middleware and it implements many of its features. However, the support of kinematics and dynamics has been added only recently and it lacks the possibility to be extended to interfacing with third-party robotic libraries.

Terminology
The majority of the hybrid and discrete-only software listed in the previous section share a software architecture composed of similar components. In view of the AOP architecture used in this work, we will make use of the following terminology, illustrated in Figure 1: Blocks are elements that provide self-contained functionality. They wrap algorithms exposing a black-box interface composed of inputs, outputs, and parameters.
Ports are virtual elements associated to block inputs and outputs. They store information to identify which kind of data is supported by the block (typically size and type).
Signals are the elements that connect ports of different blocks. When two ports are connected, the share their data.
Engines control the channel through which the blocks communicate. Engines typically create the computational graph and assign the blocks execution order. They also collect the block outputs and propagate them to the handled channel. They usually provide graphical tools to visualize blocks and help their interconnection by creating signals between them.
These terms naturally translate to the definitions of the AOP framework: blocks map to actors, signals map to channels, and ports represent the interface between actors and channels.  Figure 2: Software architecture outline. BLOCKFACTORY provides the Block and BlockInformation API along with the necessary tools to interface with the supported engines. The BLOCKFACTORY plugins contain the logic of the blocks, and they are loaded during runtime from the implementation of the engine API. This figure illustrates well the abstraction of the components of the architecture. The engine is only aware of its own API, which represent the entry-point that allow interfacing with it. The implementation of the engine API, once blocks are loaded, can call their functionality only through the Block API. Finally, the blocks contained in the plugins can communicate with the engine only through the abstraction provided by the BlockInformation API.

Framework Software Architecture
This section describes the software architecture of the proposed framework. Firstly, the factory pattern and the plugins concepts are introduced. Their combined usage has direct applicability within an AOP context. Secondly, we describe in details the two components that form the framework: BLOCKFACTORY 29 and WHOLE-BODY TOOLBOX. 30 BLOCKFACTORY provides the support to actor-oriented programming and the interfacing with third-party frameworks. WHOLE-BODY TOOLBOX provides a plugin library containing the actors that expose the robotic stack used for controllers design: robotic middlewares, rigid-body dynamics libraries, and robotic simulators. An overview of the main classes of these two projects is shown in Figure 3. In other terms, WHOLE-BODY TOOLBOX provides the algorithms, BLOCKFACTORY provides the back-end of the software infrastructure that abstracts blocks and engines. The solvers and the front-end are instead provided by the selected engine.

Factory pattern and plugin libraries
Third-party engines typically offer a set of APIs that can be used to integrate external software inside their framework. In order to detach effectively the block implementations from the third-party engine, the combination of the factory pattern and dynamically loaded plugins represents one of the canonical solution. 31 With the factory pattern, objects are created from a factory function without the need to specify their class. Typically a label or identifier is associated with this kind of objects, and only this information is required during their instantiation. Unfortunately, this is not enough to achieve the separation between engines and blocks, because the factory function only hides their allocation and the engine still needs to link against their implementation. This shortcoming can be overcome with plugin libraries dynamically loaded during runtime. In this case, the engine needs to have two information: the label associated with the implementation of the block and the name of the shared library that contains it. Once the plugin is dynamically loaded, the engine can instantiate block objects using a factory function without knowing anything about the class that implements them. Then, it can call their functionality through the common interface. The implementation of block classes is not constrained to any model of computation of AOP. In the most general form they can be asynchronous and concurrent.
The combined architecture of factory and plugins represents a natural implementation of actor-oriented programming.
In fact, the limitation of the engine to access the functionality of the blocks through their exposed abstraction layer enforces one of the key characteristic of actors: the exposure of a well-defined interface.
For what concerns robotic controllers, the separation layer introduced by the plugin-based factory pattern provides a great help in system integration. In fact, since the plugin libraries containing the blocks are engine-agnostic, they can be loaded from each engine without the need to recompile them. This means that a controller prototyped with one engine can load the same library of the deployed controller. The code duplication is hence minimized and the robustness of the system is improved because the logic of the blocks is shared. Another benefit of this architecture to the system integration is about dependencies. The standalone plugins can link against any third-party library without the need to operate on the layer specific to the engine.

BlockFactory
The concepts defined by actor-oriented programming are implemented in a tool called BLOCKFACTORY. It allows creating blocks (the actors) that exchange data between each other through the signals connected to their exposed ports, as illustrated in Figure 1. The entities of AOP are mapped to C ++ classes and interfaces, reported in Figure 3. BLOCKFACTORY also implements the factory pattern and provides support to dynamically load during runtime plugins that contain block objects.
In order to obtain engine-agnostic blocks, the information exchanged between blocks and engines needs to be abstracted. For this scope, BLOCKFACTORY provides an abstraction layer called BlockInformation placed between blocks and engines. As shown in Figure 2, blocks can query information from the engine only through the BlockInformation interface, and engines can only call block functionalities through the Block interface.
The interfacing with third-part engines can be achieved in two steps. Firstly, their own API or callbacks need to be implemented for loading during runtime the plugins containing the block logic. Secondly, in order to provide blocks the information from the engine they need, the BlockInformation interface needs to be implemented for the selected engine. In the current version of BLOCKFACTORY, we provide support of the Simulink and Simulink Coder engines. In this case, the implementation of their API corresponds in developing respectively a C MEX S-function and a Target Language Compiler (TLC). BLOCKFACTORY provides these two files that are independent from the block implementation, and can load generic objects implementing the Block interface.
The actor-oriented applications that can be built with BLOCKFACTORY are universal, and not related by any means to robotic controllers. BLOCKFACTORY is engine-agnostic, and can be interfaced with engines specific to the target application. System integration is simplified since it contains only a small number of classes and it has no dependencies.
Beyond the scope of the presented work, BLOCKFACTORY can find applicability in fields such as electrical drives, communication systems, power converters, etc. Generally, it can cover all use-cases that need exposing to the engines custom logic (either inlined in the block or wrapping external libraries) or interfacing with external devices while exposing only a simple and unified interface.

Whole-Body Toolbox
WHOLE-BODY TOOLBOX is a C ++ plugin library that exposes canonical algorithms and utilities commonly used to develop robotic controllers, such as rigid-body dynamics algorithms and communication capabilities with robotic devices mediated by middlewares. These functionalities are wrapped as block entities and they can be loaded independently by all the third-party engines supported by BLOCKFACTORY. In order to use the blocks in a Simulink model, the toolbox also provides a Simulink library that exposes the C ++ classes as visual blocks, which can be imported by drag-and-drop and configured through text boxes and drop-down menus.
For historical reasons the middleware we actively support is YARP. 32 Our main target platform is the iCub humanoid robot, 33 even though all YARP-compatible real and simulated robots are supported out-of-the-box. As an example, a previous work 17 showed a simulated whole-body controller running on both iCub and Walkman 34 robots.
Historically WHOLE-BODY TOOLBOX was developed for whole-body control, 35 hence the name. In its last revisions, it became a generic robotic toolbox that can be used for any type of controller. The blocks implementing dynamics and kinematics algorithms are mainly based on iDynTree 36 and do not depend on any middleware. They can be used also with robots which are not YARP-based, outsourcing, in this case, the interfacing with the target platform to third-party plugin libraries. The only requirement for using the provided algorithms is the availability of an URDF 3 description of the robot to control.
A complete software stack for robotic controllers typically involves the interaction with a physic simulator. The robotic simulator we chose to support is Gazebo. 37 The interaction between Simulink and Gazebo follows a co-simulation pattern, where the former is the master that issues forward step commands to the physic engine at each simulation step. The controller transparency between the real and the simulated robot is achieved by exposing the same network interface exploiting the abstraction layers provided by the YARP middleware. In the case of the simulated robot, the implementation of these interfaces are provided by Gazebo Yarp Plugins. 38 The toolbox also provides generic utilities for robotic applications, such as discrete filters, cartesian trajectory controllers, 39 and quadratic programming solvers based on QpOASES. 40

The Pipeline
In the previous section, we introduced the proposed framework, described its architecture, and discussed how its components interact with each other. In this section, we will describe the pipeline that implements MBD from the point of view of the control engineer, detailing how the it is practically used and how the components of the framework relate to each step of the development.
The proposed pipeline implements all the four stages on which the model-based design pattern is derived. We will demonstrate a practical usage showing the steps to rapidly prototype and deploy a balancing controller, 41, 42 executed on the humanoid robot iCub. 33 A simplified overview of the theory behind the controller is reported in the preceding work. 17 Since we managed to maintain the compatibility of the controllers designed with the previous architecture, the experimental results of that study that use Simulink correspond to the prototyping phase of this pipeline. As explained more in detail below, thanks to the abstraction between the controller and the robot provided by the YARP interfaces, the pipeline includes few intermediate steps in addition to the stages defined by MBD.
The first stage of MBD is plant modeling. For controllers applications, the plant is typically composed by the robot and the environment where it operates. In our case, the model of iCub is represented by an URDF file, which stores its kinematic and dynamic properties. The model of the robot is generated semi-automatically from its CAD design,  Figure 4: Overview of the pipeline implementing model-based-design. The prototyping phase, in the first row, assumes the availability of a model of the robot. In step 1, a Simulink model of the controller is created. In step 2, the controller is tested in the Gazebo simulator using the robot model. In step 3, the same controller used in simulation is tested on the real robot, leveraging the robot transparency provided by exploiting the same YARP interfaces. All the computations of this phase are executed from an external machine running Simulink. The communication with the real robot is achieved through the YARP middleware. The second row illustrates the deploying phase. Exploiting Simulink Coder, in step 4, C ++ code is automatically generated from the Simulink controller.
Step 5 and 6 perform the same tests of the previous phase from the same external machine, respectively on the simulated and real robot. This time, though, the autogenerated controller is executed. Eventually, in step 7, the controller is deployed to the computer in the robot head and runs standalone.
solution that allows obtaining a very detailed description of the robot. For what concern the environment, we use the default empty world provided by the physic engine running inside the simulator. The same applies to the interaction between the robot and the environment.
The implementation of the remaining stages of MBD is illustrated in Figure 4. The first row shows the prototyping phase of the pipeline and the second one shows the deploying phase. Referring to the figure, the depicted steps serve as follows: 1. This first step implements the controller prototyping stage of MBD. The controller is designed in Simulink using the default system blocks and the blocks provided by WHOLE-BODY TOOLBOX. In this case, when the user drops a block in the model, the S-function contained in BLOCKFACTORY loads the plugin library and, using the factory method, it allocates the object that implements its logic.
2. When the controller is ready, it can be executed on the simulated robot model. WHOLE-BODY TOOLBOX provides a block for interfacing with Gazebo, synchronizing it with the simulation loop running in Simulink. This step provides the means of the system simulation stage.
3. In this additional third step, the control designer has the possibility to connect the controller, still running in Simulink from an external machine, to the real robot. Since the controller now needs to run in a real-time setting, the block used to interface with the simulator is substituted with a block that enforces the simulation loop to be synchronized with the real clock. Measurements and reference signals are gathered and streamed in real-time. 4. Reached this point, the controller is already functional on both the simulated and real robot. The last controller deployment stage starts with step 4. Exploiting the capabilities of Simulink Coder, the oriented graph visually created in Simulink is translated to an automatically generated C ++ class. In our software architecture, Simulink Coder is handled as another engine (as reported in Figure 3), and a different implementation of the BLOCKFACTORY interface that abstracts the engine is used. A very important detail of this process is that the logic implemented by the WHOLE-BODY TOOLBOX blocks is not inlined in the autogenerated class. In fact, analogously to the behavior of any engine supported by BLOCKFACTORY, the plugin-based factory pattern is used. This means that the autogenerated C ++ class loads the same plugin containing the logic of the robotic blocks that was used in the Simulink engine. Firstly, this helps to keep the behavior of the controllers running in different engines aligned. Secondly, assuming a constant controller graph, it simplifies the delivery of updates and fixes of the logic of the WHOLE-BODY TOOLBOX blocks. In fact, updated blocks can be deployed to the target platform by only distributing an updated plugin library, removing the need to regenerate the sources and rebuild the application. As last comment, it is worth noting that once the class has been generated and compiled, the presence of Simulink is no longer necessary. 5. This step corresponds to step 2. In this case, though, the automatically generated controller is executed on the simulated robot. 6. Similarly, this step corresponds to step 3 with the automatically generated controller. 7. The real deployment to the target platform is represented by this last step. Until now, the controller always ran from the external machine, communicating to the real robot through the network, exploiting the YARP observer pattern. 31 The automatically generated class of the controller and the BLOCKFACTORY plugin are now compiled (or cross-compiled) for the on-board machine of the robot and, lastly, deployed. The comments about the choice of the plugin-based factory pattern of step 4 are even more central reached this last stage.
In this example, the controlled robots -simulated and real-refer to the same kinematic structure. One may wonder which modifications are necessary in this new architecture in order to run the controller on a robot endowed with a different number of degrees-of-freedom. One of the new features of WHOLE-BODY TOOLBOX is the presence of a configuration block, where it is possible to specify runtime information such as the name of the URDF model, the names of the controlled joints, and the name of the robot used to set up the YARP context. Excluding edge cases, this is enough to make controllers independent from the robot.

Blockfactory
The dataflow framework BLOCKFACTORY represents, as described in the previous sections, the abstraction layers between engines and black-box functions, supplied e.g. by plugins such as WHOLE-BODY TOOLBOX. This means that BLOCKFACTORY is responsible for exposing blocks in such a way that they can be properly configured by the solvers included in the engines. Currently, it only supports engines that provide discrete solvers with fixed-step. This is the only requirement for models that have to be executed on a real-time system. However, BLOCKFACTORY was born as a generic dataflow framework and, when the deployment is not the final target, it should provide compatibility with continuous solvers which typically need to operate on the derivatives of the block state.
At its current state, the block interface is modeled to be a stateless system. The engine can only trigger the evolution of a block state by calling its output method since they are akin to instantaneous functions. However, stateful blocks can be extremely convenient in some use cases. Indeed, WHOLE-BODY TOOLBOX already contains blocks that hold an internal state, but it is hidden inside the implementation. One of the consequences of the presence of this hidden state is that blocks that need to know the step size cannot gather it directly from the engine, and this information must be passed as a parameter. This behavior can be not very intuitive for the end user. Furthermore, is it more error prone since every time the user changes the step size, also the parameters of all blocks requiring it must be updated accordingly. This would not be necessary if the blocks would be modeled in such a way to expose their hidden state and rely on the engine features to address this shortcoming.
The Functional Mock-up Interface 25 represents a common standard as an alternative to the provided interfaces. Instead of a complete substitution, though, being able to expose blocks in their counterparts called Functional Mock-up Units can be a valuable addition. This would open the interoperability with a plethora of tools that already support FMI, improving the integration of the models designed with BLOCKFACTORY in complex co-simulation environments.

Whole-Body Toolbox
WHOLE-BODY TOOLBOX currently grounds the interfacing with robots on the YARP middleware, and we are aware that there are not many existing YARP-based robots. Despite implementing the YARP interfaces for a new platform is not an insuperable task, it might limit the applicability of this pipeline. Going in this direction, a native implementation of the more common ROS middleware would enlarge the adoption of the proposed tools. A proof-of-concept of a ROS plugin implementing its publisher-subscriber pattern is already available. 43 On the same line, allowing to install the WHOLE-BODY TOOLBOX without its YARP component would be another possible improvement. In fact, the majority of the blocks are middleware-agnostic, and they could be already used in systems without any middleware installed. For instance, many use-cases might benefit from the included algorithms for rigid body dynamics.
The current support of simulating a kinematic structure consists of a co-simulation setup between Simulink and Gazebo that communicate through YARP messages thanks to the Gazebo Yarp Plugins. This entire system worked well for us in the past, however, its use is not as straightforward as it could be. In fact, in order to obtain a correct synchronization between the two simulators, all the components of this system should be started passing extra options. In order to simplify this process, it would be beneficial embedding the physic simulator inside a new block, treating it as a regular node of the graph. In this way, the synchronization could be greatly simplified taking advantage of the information available from being executed as part of the computational graph. This would also enable to execute headless simulations and allow to open the graphical user interface only if visual feedback is required.
A limitation of WHOLE-BODY TOOLBOX that might restrict its applicability to generic tasks is the lack of maturity of the robotic perception stack. The main scope of our applications are balancing and locomotion, therefore we always ignored perception and focused mainly on dynamics. Our controllers currently operate only on flat terrain, where perception is not required. However, creating new specific blocks to retrieve sensory data would be straightforward. An improved perception can then allow controllers to handle more structured scenarios, that can be already simulated in Gazebo inserting the robot model into a structured world.
In the long run, we would like to add the support of existing machine-learning frameworks in order to embed networks and function approximators into our robotic controllers. Furthermore, we are planning to introduce the possibility to export controllers with an interface that exposes a set of parameters which would allow applying reinforcement learning algorithms.

Pipeline
The description of the pipeline reported in the previous section offers a general overview of its functionalities. However, it hides few caveats which might not be straightforward. In step 2, obtaining a model that can be effectively actuated in Gazebo requires tuning its PID gains. Finding a proper configuration is not straightforward and many iterations are necessary. Furthermore, this process has to be repeated again in step 3, when the controller is executed on the real robot. Once the right gains have been properly found, they can be reused in steps 5 and 6. However, these low-level configurations are not strictly specific to this pipeline. In fact, they are related to the YARP implementation of the robot and these parameters are meant to be abstracted by YARP interfaces.
Similarly, it is interesting to analyze the factors that might differ between running the autogenerated controller from the external machine and from the on-board device of the robot. The communication between the controller and the robot -typically consisting of sensor measurements and references-are mediated in both cases by the transport layer handled by YARP. In the first case, since the controller is running in an external machine, the exchange of data occurs through the network transport layer. This type of data transfer introduces overhead and delays that might affect the performance of the controller. Deploying the controller to the on-board machine provides a great opportunity to mitigate this problem. However, this is not exempt to side effects. In fact, controllers are very sensitive to time delays and dealing with them is yet an open problem in many applications. Assuming that the same gains can be applied might hold surprises. In our experience though, controllers did not need any tuning. In any case, moving the computation of fundamental tasks such as motion control as close as possible to the actuators offers a tremendous possibility to enhance system robustness. Furthermore, the deployed controller is an optimized version of the one executed in Simulink. If the rate of the controller is slower than the rate of the robot measurements and the actuation bandwidth, the gain of speed might allow increasing the controller frequency, which is typically related to better performances.
A current limitation of the autogeneration process is how controller parameters stored in Simulink are handled. With the current BLOCKFACTORY version, due to how the code is generated, accessing them from the code is not very intuitive. As a consequence, it is not yet possible to obtain an autogenerated controller that, without the need of regenerating the sources, can be used on different YARP-based robots.

Conclusions
In this paper, we presented a rapid prototyping and deployment architecture for robotic controllers based on the principles of model-based design. The architecture is composed of a framework and a pipeline.
Developing and maintaining a controller in pure C ++ is typically extremely demanding, and even minor architectural changes might require a considerable effort. In light of the fast prototyping aims, developing controllers using visual tools and then automatically generate optimized C ++ code represents a great speedup.
As first component of the framework, we presented the actor-oriented tool BLOCKFACTORY. It abstracts generic algorithms and allows embedding them in generic applications modeled as directed graphs. The black-box functions that BLOCKFACTORY exposes are modeled as blocks with a predefined interface, and are stored in collections as shared libraries. These libraries can then be loaded from third-party software that implement the model-based design pattern.
Among all the available possibilities, BLOCKFACTORY allows interfacing with Simulink and Simulink Coder. However, it streamlines the extension to other frameworks by providing a second interface that abstracts the engines from the block implementations.
Different kind of robotic controllers are typically based on a limited set of elemental functionalities, and complex logic can be achieved by their composition. In this work, as second component of the framework, we presented WHOLE-BODY TOOLBOX, a collection of black-box functions for robotics representing the building elements of generic robotic controllers. This toolbox wraps a number of existing open-source projects belonging to the categories of robotic middlewares, rigid-body dynamic libraries, and mathematical optimization tools.
These two projects serve as the primary components of the proposed pipeline to rapidly prototype and deploy robotic controllers. In particular, the presented pipeline implements the rapid prototyping capability -idiomatic feature of model-based design-by interfacing with the Simulink engine. The rapid deployment, instead, is achieved exploiting the automatic code generation support provided by Simulink Coder. We explained step by step how the entire process works, detailing how the stages of model-based design have been implemented.
Ultimately, we explained the shortcomings of the current status of both the components of the presented framework and the resulting pipeline, and our plans to address them. The present condition of these projects is the outcome of many years of development, during which the architecture often changed and gave us the possibility to learn from our mistakes. Despite these continuous changes, a big effort has been spent to keep the experience of the control engineers that use this framework as consistent as possible. As attempted in the previous papers, we tried to be as critic as possible to our choices, being aware that the presented pipeline still has a big room of improvements.
To conclude, we would like to remark that the development of all the presented tools followed from their beginning an open-source and community-driven approach. From one hand, we could have never achieved the current development status and our results if we couldn't interface with existing open-source software such as middlewares, simulators, and libraries. We are grateful to the entire robotic community to provide and maintain them over time. From the other hand, collaborations with other research institutes -mainly belonging to the community built around the iCub humanoid robot -helped us to improve the robustness of the entire framework by using it within different contexts. A great contribution, as an example, regards the interfacing with MATLAB. In fact, due to licensing limitation, we cannot test the pipeline thoroughly with many versions, and also the application of continuous integration pipelines presents many restrictions. A wider user-base with diverse setup helped us debugging problems we would probably have never encountered.