Dynamic Simulation for MAS-Based Data Acquisition and Pre-processing in Manufacturing Using V-REP

. With the advent of the Industry 4.0 movement, smart multiagent-based cyber-physical systems (CPS) are being more and more often proposed as a possible solution to tackle the requirements of intelligence, pluggability, scalability and connectivity of this paradigm. CPS have been suggested for a wide array of applications, including control, monitoring and optimization of manufacturing systems. However, there are several associated challenges in terms of validating and testing these systems due to their innate characteristics, emergent behavior, as well as the availability and cost of physical resources. Therefore, a dynamic simulation model constructed in V-REP is proposed as a way to test, validate and improve such systems, being applied to a data acquisition and pre-processing scenario as one of the key aspects of the interaction between a CPS and the shop-floor.


Introduction
In recent years, the manufacturing field has been undergoing profound changes, in great part due to the developments in the information technologies fields, in regards particularly to Cloud Computing and the Internet of Things.
An evidence of that is the emergence of the Industry 4.0 movement [1], advocating the existence of highly interconnected, intelligent devices and the growth in the amount of data shared between them. This led to the emergence of several new solutions based on smart cyber-physical systems (CPS), focused on translating these characteristics into added value for the manufacturers.
The work detailed in the following sections is motivated by such a case, more specifically whether or not a smart CPS-based predictive maintenance system can improve productivity and reduce operation expenditures in Industry 4.0 systems. Playing a pivotal role in such an approach, the simulation of the data acquisition and pre-processing stage of these systems can be seen as a first step towards validating and measuring the potential impact that these solutions may have in real environments, being thus the focus of the research documented in the subsequent sections.
As such, the work detailed in the remaining sections is organized as follows. Subsections 1.1 and 1.2 contextualize simulation in regards to Smart Systems, and provide an overview of the related work in the current literature. Afterwards, Section 2 describes the simulation model, while Section 3 provides the details on a specific application case. Finally, Section 4 presents the discussion of the results obtained from the simulation environment, followed by some brief conclusions and description of future work in Section 5.

Simulation in Smart Systems
In the last few years the Smart Industrial Cyber-Physical Systems emerged as an important trend in the new manufacturing ecosystem. In this sense, there is a demand to support customization and the capability to learn and adapt the production systems in real time. This stems from the need to deal with disturbances and unpredictability in production, which lead into the development and research of very dynamic systems.
Consequently, the traditional simulation environments need to evolve in the same direction, otherwise the demonstration and validation of the added value presented by these new Smart Systems cannot be done. Hence, the simulation of these systems will allow researchers and developers of such solutions to improve and keep improving their own solutions and will also allow the migration of these solutions to real production environments.

Related Work
Emergent Production Paradigms. That evolution has brought new production paradigms such as evolvable systems [2], reconfigurable distributed processing, among others. In short, adaptive and reconfigurable systems, using optimization strategies to deal with unexpected events and adversities. The strongest branch of research lies on the multi-agent systems, MAS, with several implementations of solutions following these paradigms [3]- [6]. Simulation in Self-Adaptable Manufacturing Systems. In the current market and with the emergent needs faced by the manufacturing companies, such as mass customization, small sized batches, etc. simulation appears as a cost effective and valuable tool. Due to the current trends of distributed, intelligent control systems and/or reconfigurable manufacturing systems [7], [8] and all the associated distributed software or functionalities such as diagnosis [9], monitoring [10], among others, the traditional rigid simulation environments are not up to par to simulate these emergent systems with their inherent requirements.
These new proposed production paradigms [11]- [13] can be simulated and tested in two different stages, during the design and after the development. During the design of the solution it is often important to test and tune the algorithms and the behavior of the logic system. At this stage a software like Netlogo [14], [15] or AnyLogic [16] is capable to mimic the behaviors and results from the logic point of view, where the developers are more focused on the interactions and behaviors of each distributed entity in order to validate and evaluate the overall behavior of the system.
After the development of the logic system, for instance the software responsible for abstracting a production line, it is important to mimic a real industrial line before deploying the technology in a production ready state. This previous assessment using simulation is not only important to validate the solution but also to demonstrate the expected results regarding the usage of these new solutions due to their partially unpredictable and non-deterministic components, based on self-organized and selfadaptable behaviors. Henceforth a new kind of simulation model with intelligent entities in the loop, capable of meeting these new requirements of adaptability and flexibility in run-time is required. With this goal in mind, V-REP [17] appears as an effective possibility to meet these new simulation needs, being based on a modular, distributed architecture and presenting high versatility and flexibility across a wide array of applications.

Simulation Model
Typically, one of the main goals when designing a simulation model is to maintain a balance between making it as close as possible to a real system and managing its complexity, so that it can be easily altered and experimented with. Despite not representing any concrete system, the model described in this section still abides by these principles, being however focused on providing useful data so that acquisition and processing systems can be quickly tested. Furthermore, another critical point in this modelling process was making sure that the model could be easily extendible to accommodate additional data sources (e.g. sensors and parameters), stations or functionalities, as well as dynamically changeable to cope with new conditions or parameters in run-time. The model itself consists in a simple production line, in which a conveyor belt transports parts from a source to a working station shared by two robots, as seen in Fig. 1.

Fig. 1. Overview of the Simulation Model
Once the part has arrived at the station sensor, robot1 performs a welding operation on it (see Fig. 3), followed by robot2 picking it up and moving it to a storage box (Pick and Place operation, or P&P).
Model design entails a series of key steps, including the clear definition of the system boundaries, its actors, input variables and quantitative criteria or performance measures on the basis of which the performance of different configurations can be compared and evaluated [18]. For this model, the input parameters define the velocity for the conveyor belt, as well as for each of the robots. The meaningful data points to be extracted include each robot's state (e.g. picking, welding), part presence information from the source and station sensors, and finally force sensor information from the picking robot's gripper.
Therefore, the Key Performance Indicators (KPI) associated with measuring the performance of the system consist in the overall Production Time, and the Cycle Time of each robot. A summary of these inputs and outputs is provided in Fig. 2.

Fig. 2. Simulation Model -Inputs and Outputs
In this instance the Cycle Time indicates the time it takes each robot to carry out its respective task on the part, while the Production Time represents the interval between the moment the part arrives at the workstation and the instant it is put into storage.
To construct such a model, the Virtual Robot Experimentation Platform (V-REP) was chosen [17], [19]. V-REP is a versatile 3D robot simulator based on a modular and distributed architecture, capable of concurrently simulating control, actuation, sensing and monitoring. Both the simulation environment and a close-up of the welding operation during simulation run-time can be seen in Fig. 3.

Fig. 3. Simulation Environment (a) and Process Close-up (b)
The scene was built using two UR5 flexible robots (one coupled with an RG2 gripper and the other with a welding gun) and a simple conveyor with two partpresence sensors, one at the source and one at the workstation.
The simulation model was programmed using a collection of Lua scripts, each associated to its own scene object. These scripts are responsible for controlling the system execution, with the resources communicating via signals using V-REP's own API. These communications can be observed in Fig. 4.

Fig. 4. Robot interactions within the simulation model
Furthermore, the simulator allows the connection of external clients with relative ease via V-REP's Remote API, which supports several programming languages including Java, C/C++ and Python.
In this context, Section 3 provides a detailed description of an application case in which this API was used in order to connect the simulation environment to an external MAS-based data acquisition and pre-processing CPS implemented in Java. This description is focused on the system modelling and communication aspects of the integration process.

Application Case
Industry 4.0 manufacturing systems typically comprise highly interconnected, modular and flexible intelligent components producing large amounts of data at often astounding rates. This makes data acquisition an essential stage in several applications, such as control, monitoring, preventive maintenance and energy optimization. Moreover, solutions proposed regarding these topics tend to rely on data mining and analysis techniques, which not only make it crucial for raw data to be extracted, but also preprocessed in order for it to be translated into a potential business advantage.
With this in mind, the MAS-based data acquisition and preprocessing CPS described in [10], [20] was instantiated in order to collect data from the simulation model and compute more complex values from the raw data readily available from the simulated shop floor. Subsections 3.1 and 3.2 further specify the system modelling in the CPS and the integration aspects regarding the communication between both tools, respectively.

Modelling the System
The CPS proposed in [10] differentiates between two main types of agents for data acquisition, namely the Component Monitoring Agent (CMA) and the Higher-Level Component Monitoring Agent (HLCMA). The CMA and HLCMA are similar in the sense that both perform data acquisition and handle the preprocessing of raw data to generate more complex knowledge. However, they both operate at different abstraction levels, with the CMA handling a component/resource and the HLCMA being responsible for a subsystem (aggregation of components and/or other subsystems cooperating towards a common goal). As described in Section 2, the simulation model encompasses 3 resources (UR5#1, UR#2 and the Conveyor Belt), hence resulting in the agent topology detailed in Fig. 5.

Fig. 5. Agent Topology
Agents are initially deployed in accordance to an XML blueprint file, which should be modelled in order to provide an accurate description of the system. This description is then interpreted by the MAS to understand not only the system topology in terms of available resources, but also regarding the relevant values to be extracted or calculated.

Communication
As it can be seen in Fig. 5, each agent has a generic hardware communication interface that should be implemented for each application case, thus allowing the actual CPS to be generic and easily integrated into different scenarios independently from the underlying technologies and protocols. For this case the interface was implemented using V-REP's remote Java API, and allows data to be acquired by two different means, more specifically either periodically polling of relevant data, or subscription to data values on value-change events. For this application case, data acquisition follows the latter.
On V-REP's side, an additional script was developed in order to act as a server for the simulation data. On each pass the script polls the simulation data and checks if it has changed compared to the last value. If so, it sets up a signal with the new value so that it can be read by the CPS, acting similarly to what one can find for instance in an OPC-UA client-server subscription model.

Discussion of Results
In order to validate the repeatability of the simulation results, as well as the capability of the MAS to acquire raw data from the simulator and preprocess it accurately, five different runs were executed. Each simulation run was executed until twenty samples of the cycle time for each robot (Welding and P&P) as well as the production time for the line were extracted, thus resulting in a total of one hundred samples across all runs for each KPI. The results can be observed in Fig. 6.  Fig. 6, the standard deviation σ was calculated through: . (1) The application of Equation 1 resulted in standard deviation values of 56.099ms, 49.639ms and 68.977ms for the Welding, P&P and Cycle Time variables, respectively. In order to measure the repeatability of the results, the coefficient of variation Cv of each KPI was calculated using: . ( Through Equation 2 each coefficient of variation was obtained, resulting in 3.07% for Welding, 1.45% for the Production Time and 1.70% for P&P. The coefficient of variation has been shown to be a good indicator of repeatability in non-negative datasets [21], as such these percentages suggest that the repeatability of the simulation results is reliable, with the extracted data presenting relatively low levels of variability.

Conclusion and Future Work
A dynamic and extendable simulation model was proposed for the validation of MAS-based CPS data acquisition and pre-processing solutions to be applied in the context of Industry 4.0.
The model was implemented in V-REP, a versatile and modular 3D robot simulator capable of concurrently handling the simulation of control, actuation, sensing and monitoring. This implementation consisted in a conveyor belt continuously transporting parts from a source to a workstation, where two UR5 robots would weld the part and then move it to a storage box.
An example of an application case was also shown, consisting in the integration of a MAS-based data acquisition and pre-processing CPS with the simulation environment, from which it extracted raw data such as robot states and calculated relevant KPIs, namely cycle times and overall production time. Through the analysis of the results it can be concluded that the simulation model implemented in V-REP presents reliable levels of repeatability with low degrees of variance in the collected data across different runs, hence possibly being a viable solution to validate these kinds of systems in the context of Industry 4.0.
Looking at the application of dynamic simulation for data acquisition and preprocessing as a first step, future work will include the extension of the simulation model to accommodate the testing of plug and produce and reconfiguration functionalities, aiming at providing a flexible environment to validate not only systems tailored for data extraction, but also other contexts such as shop floor control and optimization.