Specification of a robotic system requires the determination of its architecture, i.e. structure and style . Structure pertains to the decomposition of the robotic system into subsystems and presents interconnections between them. Style determines the computational and communication concepts utilised to design the system. In many cases the definition of the structure and style of the developed systems is not obvious , as often they were created without a clear architectural pattern.
The control system together with the devices it controls can be composed of one or more communicating agents [3, 8]. An agent is a separate system that has an internal imperative that rationally affects its surroundings based on the information collected from the environment. If the environment is physical in nature, then such an agent is called an embodied agent. An embodied agent affects the environment with its effectors and obtains data from it utilising its receptors [20, 3, 9, 22]. An embodied agent is decomposed into a set of communicating subsystems. The activity of each subsystem in our previous work was defined using hierarchical finite state machines (HFSM) [18, 5, 19]. Each state of the upper layer HFSM has a subFSM associated with it. Such subFSM specifies a single behaviour of the subsystem. Those HFSMs facilitate the specification of computational concepts associated with individual subsystems operating in parallel, however treated their communication as an implementation issue.
Alternatively architectural style can be described by a Petri net (PN) with conditions [13, 6, 7]. In that case system compliance with the requirements can be verified [12, 1], as Petri net verification tools exist, and above all, their ability to generate code automatically can be utilised. This paper presents a hierarchical Petri net (HPN) modelling the activities of a robotic system decomposed into five layers: 1) multi-agent robot system layer composed of agents, 2) agent layer composed of subsystems, 3) subsystem layer assigning bahaviours to subsystem , 4) behaviour layer representing behaviours in terms of elementary activities and 5) communication layer defining the communication model utilised within a behaviour. Out of this HPN model, robot controller code is automatically generated and verified by simulation.
The structure of the paper is as follows. HPNs are presented in Sec. II. Sec. III briefly reveals the concept of an embodied agent. It presents a robotic system architecture in terms of its structure and activities. Sec. V introduces an example of a robotic system specified utilising the presented modelling method. It also discloses the method of automatic generation of robot controller code out of a HPN. Sec. VI presents the related work and the conclusions are drawn in Sec. VII.
Ii Hpn With Conditions
A Petri net is a bipartite graph containing transitions and places alternatively connected by directed arcs . In a HPN some places can be substituted by pages . A page is a HPN with a distinguished single input place and single output place . In this paper we use a HPN with conditions. In such nets with each transition a condition is associated. When tokens are assigned to places the net becomes a marked HPN with conditions . With each place a single operation is associated. Places from different nets can be fused with each other. Fused places are in principle the same place appearing in two or more nets . These places are indistinguishable from each other and thus contain the same tokens. Fusing places of different nets combines those nets into a single net of a more complex structure.
This article uses a graphical representation of the net in which places are represented by single circles, pages by double circles, transitions by rectangles, directed arcs by arrows and tokens by black filled circles. Conditions associated with transitions are placed within square brackets. If a condition is always fulfilled (i.e. is True) then it may be omitted. Association of two places: and , belonging respectively to nets: 1 and 2 is represented by a single place . The definition of a safe HPN requires that in each of its places at the most one marker resides.
Iii Embodied Agent Architecture
The internal structure of an embodied agent j ( – name of the agent) is presented in Fig. 1. An agent consists of the control subsystem j receiving the aggregated data about the environment from the virtual receptors j,k ( – name of a specific virtual receptor) and based on the received data and its internal imperative it formulates the control commands for its virtual effectors j,n ( – name of a specific virtual effector). Virtual effectors transform the commands received from j into a form acceptable to the real effectors j,h ( – name of real effector), whereas virtual receptors aggregate data from the real receptors j,l ( – name of a real receptor) into a form acceptable to j. The agent’s subsystems communicate with each other through buffers (as presented in Fig. 1). A systematic method of naming buffers is used [9, 22]. The letter in the center indicates the type of the subsystem , where . The right subscript determines the names of: the agent, the subsystem and if it is necessary, the buffer component. While, the left subscript determines, whether the buffer is an input buffer (), output buffer () or internal memory (in this case this subscript is omitted). The right superscript determines the discrete time stamp, e.g. , whereas the left superscript, determines the type of the subsystem, from which the data is obtained or to which the data is directed. For example: 1) ij,v is the content of the input buffer receiving data from the virtual receptor output buffer at a discrete time ; this input buffer is a part of the control subsystem j of the agent j, 2) ij is the internal memory of j at time . It should be noted that each subsystem can run at a different sampling rate, thus for each of those subsystems is different (context distinguishes them).
A HPN determining the activities of a multi-agent robot system consists of five layers (Fig. 2):
multi-agent robot system layer composed of a single net defining individual pages j for each agent j within the multi-agent robot system,
agent layer composed of nets j responsible for the activation of pages j,vs, which in turn determine the activities of individual subsystems j,v ( is the subsystem designator), ,
subsystem layer defining nets j,vs represented by pages j,vs; each net j,vs contains pages j,v, ωs defining particular behaviours j, v, ω of j,v ( is the behaviour designator),
behaviour layer defining behaviours j, v, ω represented by pages j,v,ωs,
communication layer determining the communication models used by behaviours j, v, ω, i.e. defining pages j, v, ω, snds (net describing behaviour of j,v when data is sent to other subsystems) and j, v, ω, rcvs (description of how j,v behaves when it receives data from other subsystems); example is in Fig. 3; It should be noted that the communication models used both for sending and receiving data pertain to the same subsystem j,v, and not to the system j,h with which j,v communicates.
Out of the five layers of three have user defined structure, the behaviour layer has a fixed structure, and the communication layer is composed of predefined blocks. The first two layers trigger parallel execution of nets representing the activities of agents and subsystems respectively. Subsystem j,v executes its behaviours j, v, ω. Any behaviour j, v, ω calculates the transition function j,v,ω associated with it producing:
sends the produced output data (from the output buffer j,v) to the associated subsystems, updates the discrete time , receives data from the associated subsystems (this data appears in the input buffer j,v) and finally checks the error condition j,v,β and terminal condition j,v,ξ, where and are the designators of the error and the terminal conditions respectively. The behaviour iterates until one of the above-mentioned conditions is fulfilled. Once a behaviour is terminated, the choice of the next one is based on a predicate called an initial condition j,v,α( – predicate designator) . Initial conditions of next behaviours are associated with the transitions pointed at by the arcs emerging from the place with which the just terminated behaviour is associated.
The communication model must define whether communicating subsystems activities are blocked during the data transfer or not. Both the producer and the consumer may operate either in blocking or non-blocking mode. The blocking mode causes the producer to wait for the consumer to confirm that data has been received. In the non-blocking mode the producer does not wait for this confirmation and instantaneously resumes its other activities. In the blocking mode the consumer waits until it receives the data, while in the non-blocking mode it resumes its other operations if data is unavailable. A non-blocking mode used by both the producer and consumer is called a fully asynchronous communication model.
Iv Construction of System Layers
Construction of a HPN of consecutive system layers is performed as described below (Fig. 2).
Iv-a Hpn of the multi-agent robot system layer
Add to a page j for each agent j within the multi-agent robot system,
Add to two transitions in and out,
Connect by directed arcs in to each j and each j to out.
Iv-B Hpn j of the agent layer
Create a page j,vs for each subsystem j,v within j. For create page j,cs,
Create two transitions j,in and j,out,
Connect j,in to each page by a directed arc,
Connect each page to j,out by a directed arc,
Create a place j,in and connect it to j,in by a directed arc,
Create a place j,out; connect j,out to j,out by a directed arc.
Iv-C Hpn j,vs of the subsystem layer
Create a page j,v,ωs for each behaviour j, v, ω exhibited by the subsystem j,v,
For each behaviour j, v, ω (i.e. j,v,ωs) determine the initial conditions j,v,α that will be associated with transitions j,v,α leading to successor behaviours j, v, δ (i.e. j,v,δs). Connect j,v,ωs to all successor pages in the following way: connect j,v,ωs to j,v,α and j,v,α to j,v,δs by directed arcs for all successor pages j,v,δs.
Add to j,vs two places: j,v,ins – input place and j,v,outs – output place, and two transitions j,v,ins and j,v,outs. Place j,v,ins is connected through j,v,ins to a page that represents the initial behaviour of the subsystem. The page representing the terminal behaviour of the subsystem is connected by a directed arc to j,v,outs, which in turn is connected by another arc to the place j,v,outs. The places j,v,ins and j,v,outs are the input and output places of j,vs (i.e. j,vs).
Iv-D Hpn j,v,ωs of the behaviour layer
The structures of all HPNs j,v,ωs represented by j,v,ωs follow a single pattern, thus they do not have to be created. Only the parameters of their activities have to be delivered, i.e.: transition function j,v,ω, error condition j,v,β and terminal condition j,v,ξ, as well as the communication models utilised within pages j,v,ω,snds and j,v,ω,rcvs. Behaviour j, v,ω is executed by j,v,ωs in the following way.
The execution of behaviour j, v, ω starts when a token appears in the place j,v,ω,ins. This initiates the operation j,v,ω,1s which consists in calculation of the transition function j,v,ω by using (1). Transition j,v,ω,1s will not fire until the calculation is complete.
Firing the transition j,v,ω,1s places a single token in the page j,v,ω,snds, initiating its execution. Page j,v,ω,snds represents a net j, v,ω,snds determining the communication model used to send the contents of the output buffers ij,v to the connected subsystems. When the page j,v,ω,snds finishes its execution, the transition j,v,ω,2s is ready to fire,
The operation j,v,ω,2s is associated with the place j,v,ω,2s that receives the token. It increments the discrete time of the subsystem j,v,
Firing the transition j,v,ω,3s activates the page j,v,ω,rcvs, which represents the net j, v,ω,rcvs determining in what mode is the data received from the associated subsystems,
When the page j,v,ω,rcvs completes its activity, the error condition j,v,β and the terminal condition j,v,ξ are checked. If none of them is fulfilled, the next iteration of behaviour j, v,ω starts. Otherwise a single token is placed in the output place j,v,ω,outs. This terminates the behaviour j, v,ω execution, and thus completes the activities of the page j, v,ωs. The control returns then to the net j,vs.
Iv-E Communication layer – determination of communication model utilised within behaviour j,v,ωs
The nets composing the communication layer again do not have to be created. As the number of communication patterns is limited, only the selection of the required pattern has to be made. The communication layer is composed of two pages j,v,ω,snds and j,v,ω,rcvs. The first one defines how j,v sends the data to other subsystems and the second one determines how it receives the data from other subsystems. Those two pages interact with similar pages of the subsystems that j,v communicates with. Those pages are created in the following way.
Select the communication model between subsystem j,v and other subsystems j,h,
Express this model in the form of a Petri net (selection of an appropriate net for the two subsystems j,v and j,h),
Divide this Petri net into two Petri nets with fused places: a) presenting how the data is sent, b) presenting how the data is received,
This procedure has to be repeated twice. Once to define how subsystem j,v sends the data and once to define how it receives data.
Out of several communication models the fully asynchronous one was selected to exemplify the design procedure. It functions in the following way. The two communicating subsystems are: j,v and j,h. The former executes the behaviour j,v,ωs and sends data to the latter, which executes the behaviour j,h,ω’s (Fig. 3a). Both subsystems, i.e. j,v and j,h, in this mode of communication, compete for access to the communication channel, which contains shared memory. Only a single subsystem may access the shared memory at a time. When subsystem j,v gains access to the memory, it removes the token from the place j,(v,h),(ω,ω’),(snd,rcv)fusions, starts the activity associated with place j,v,ω,snd,2s (inserts the data in the shared memory) and then inserts tokens in places j,(v,h),(ω,ω’),(snd, rcv)fusions and j,v,ω,snd,outs, thus terminating the communication episode. The system receiving the data acts similarly. The subscripts of the fusion place j,(v,h),(ω,ω’),(snd,rcv)fusions specify the direction of data transmission, i.e. from the subsystem j,v (executing behaviour j,v,ωs) to the subsystem j,h (executing behaviour j,h,ω’s), emphasizing that this place belongs to both nets j,v,ωs and j,h,ω’s. The net presented in Fig. 3a can then be decomposed into two nets that are respectively pages: j,v,ω,snds (Fig. 3 b) and j,h,ω’,rcvs (Fig. 3c). Places j,v,ω,sndfusions and j,h,ω’,rcvfusions are associated with each other creating a single place j,(v,h),(ω,ω’),(snd,rcv)fusions. Page j,v,ω,rcvs representing behaviour j,v,ωs is determined analogically.
If the subsystem j,v sends or receives data to or from two or more subsystems, the pages of subsystem j,v have to be adequately connected. For instance, let subsystem j,v send data to j,h and . Pages are defined for each pair of communicating subsystems. The pages j,v,ω,snd, hs and j,v,ω,snd,h’s, specifying the communication of j,v with j,h and , are connected with each other by association of output place of page j,v,ω,snd, hs with the input place of page j,v,ω,snd, h’s. This results in the creation of a single page j,v,ω,snds describing sequential data transfer, first from j,v to j,h, and then from j,v to . Alternatively, those pages can be connected in such a way that the data will be sent in parallel to the subsystems j,h and . Other communication models mentioned in section III-B require different Petri nets than the one presented in Fig. 3a. They are not presented here due to lack of space.
The presented design methodology is currently tested by specifying robot systems and automatically generating their control code. The example presented here is purposefully kept simple to explicate the methodology and not to obscure it by overly complex robot and its task. Thus the control system of a rudimentary simulated robot executing the follow the line task is presented.
The task of a two-wheeled robot is to follow a black curve painted on a plane contrasting surface (Fig. 4(a)).
Robot system structure
The designed robot system is composed of a single embodied agent 1. The agent 1 contains: control subsystem 1, virtual receptor 1,sensor, virtual effector 1,motor, two real effectors 1,motor_1, 1,motor_2, being the two motors actuating two wheels, and three real receptors 1,sensor_1, 1,sensor_2 and 1,sensor_3 detecting the intensity of the light reflected from the floor surface. The virtual receptor 1,sensor aggregates data from the real receptors and then forwards the result to 1. The control subsystem, uses the data received from 1,sensor and sends appropriate commands to 1,motor, which computes the inverse kinematics to control the real effectors.
Robot system activities
The designed robot system consists only of a single agent 1 thus HPN consists of a single page 1. Petri net 1 determining the agent layer is presented in Fig. 4(b), subsystem layer in Fig. 5(a), behaviour layer in Fig. 5(b) and communication layer in Fig. 3a. For the sake of briefness this paper presents only the control subsystem 1 HPN 1c, which exhibits two behaviours: 1,initc, which initiates the connection with the simulated robot, and 1, controlc, which calculates the transition function 1,control (Fig. 4), i.e. calculates the robot linear and angular velocities using the data received from 1,sensor, and sends them to 1,motor, where the wheel speeds are produced. The specification of 1,control (Fig. 4) must be transformed manually into C++ code, which is subsequently inserted into the robot controller code by the development tool. 1,control is evaluated as an operation associated with the place 1,c,control,inc in Fig. 5(b).
V-B Petri net generation and execution
The generation of a robot controller code requires the creation of the HPN and its subnets. For that purpose a tool has been developed by the authors. The designed Petri net is automatically transformed into C++ code, forming the robot controller. The generated controller representing the HPN with an initial marking is then merged with the library executing the HPN. The resulting C++ code is compiled and the outcome is loaded into the control computer. The code invokes the scheduler, which searches for active transitions (enabled transition with fulfilled condition). One of such transitions is fired, i.e. a token is removed from each input place (place directly connected to the fired transition by a directed arc pointing at the transition) and inserts tokens into each output place (place directly connected to the transition by a directed arc pointing at the place). The operations associated with the output places are executed in separate threads. When the directed arc connects the firing transition with an output page, the input place of that page receives a new token and the associated operation of that input place starts its execution in a new thread. The scheduler repeats the above-mentioned steps either endlessly or until a behaviour commands it to terminate its activities.
The robot following a line was simulated utilising the VREP simulator . The simulator utilises a model of the robot (two-wheeled mobile robot from the VREP model library), exemplary environment (the floor with a black line on it) and the automatically generated robot controller, specified by the HPN. The generated controller is a C++ code which controls the execution of subsystems working in parallel: 1, 1,sensor, 1,motor. Real subsystems 1,motor_1, 1,motor_2, 1,sensor_1, 1,sensor_2 and 1,sensor_3 are a part of the VREP simulator.
Vi Related Works
Non-hierarchical PNs have been used for robot control, e.g. . Construction of HPNs by substituting transitions by PNs or places by PNs, and place or transition fusion is described in [7, 14]. Substitution of a PN for a place  requires the determination of the input transitions and the output transitions in the parent PN. As the number of input places and output places in the substituted net is not limited, this unnecessarily complicates the structure of the net for our case. In [15, 23, 2, 10] a HPN is created by substituting transitions or places, however place or transition fussion is not considered, thus those nets do not meet the requirements imposed on nets modeling a robot system. In  three types of place fusion are distinguished: instance fusion set, page fusion set and global fusion set. The fusion set is a set of places which can be fused into a single place. The instance fusion set merges only places which are in the same page instance, the page fusion set merges places which occur within all instances of the same page, while the global fusion merges all places in the fusion set within the PN. The proposed place fusion types are excessive for our purposes.
As the above mentioned nets are too complex a version tailored to our purposes was developed for the description of the multi-agent robot system activities. Our HPN is created using only two constructs: substitution of a place by a net and global fusion of places. Moreover, unlike in [7, 15, 2, 10], where the substituting net could have any structure, a page in our approach can have only a single input place and a single output place. This causes that the definition of the page does not require reference to the transitions located in the parent net (because it is known with which transitions the place is connected). As a result, the page is much simpler to analyze. Moreover, in contrast to the above nets, the HPN we propose, associates operations with places and predicates with transitions.
The paper presents a systematic methodology of designing multi-layer HPNs defining the activities of multi-agent robot systems. Our previous approach was based on HFSM. It treated the communication model used between subsystems as an implementation detail. The communicating subsystems acted independently of each other. Since embodied agents contain communicating subsystems and the communication model between those subsystems was not revealed during system specification, it was difficult to verify the correctness of the developed robotic system. The interactions between subsystems using single HFSMs, assuming sequential execution of subsystem activities, was presented in [18, 5, 19].
A natural inclusion of the communication model into the system specification is possible by using HPNs with conditions. The proposed approach, follows the primary principle of structured programming, stating that the programmer must keep at all times the produced code within his or her intellectual grasp . It structures a robotic system into layers of PNs describing the activities of ever smaller modules. The presented approach enables automatic code generation of the robotic controller. The resulting specification is a single HPN describing the activities of the concurrently executed activities of subsystems, also describing their interactions. The proposed specification method can be used to describe the activities of any robotic system. For a multi-robot system the developer defines separate HPNs for each robot (being itself a multi-agent system). Those HPNs communicate with each other using communication models implemented as interprocess communication.
The purpose of the example presented in this paper has been the exemplification of the proposed specification and implementation method by focusing the reader’s attention only on the methodology, treating the specified robotic system as of secondary importance, thus its rudimentary character. More complicated systems require the development of more complex HPNs. Any addition of a place to a net requires 6 extra lines of code, a new transition generates 6 additional lines, an extra directed arc only a single line, while a page 48 lines. Thus it can be shown that the size of the generated code grows linearly with the size of the designed Petri net, hence the presented approach based on HPNs is scalable.
-  D. Billington et al. Requirements Engineering via Non-monotonic Logics and State Diagrams. Berlin, Heidelberg, Springer Berlin Heidelberg 2011, pp. 121–135.
-  I. Bluemke. Structural modelling with Petri nets. IFAC Proceedings Volumes, 1997, vol. 30, nr 1, pp. 63 – 68. IFAC Workshop on Manufacturing Systems: Modelling, Management and Control, Vienna, Austria, 3-5 February.
-  R. A. Brooks. Intelligence without reason. Artificial intelligence: critical concepts, 1991, vol. 3, pp. 107–163.
-  E. W. Dijkstra. A discipline of programming. (Prentice-Hall series in automatic computation). Englewood Cliffs: Prentice-Hall.
-  M. Figat, C. Zieliński, R. Hexel. FSM based specification of robot control system activities. In: 2017 11th International Workshop on Robot Motion and Control (RoMoCo). Proceedings, July, 2017, pp. 193–198.
-  C. Girault, V. Rudiger. Petri Nets for Systems Engineering. Springer-Verlag Berlin Heidelberg New York 2003.
-  P. Huber, K. Jensen, R. M. Shapiro. Hierarchies in Coloured Petri Nets. Lecture Notes in Computer Science; Advances in Petri Nets 1990, Proceedings Ed. G. Rozenberg, Berlin, Heidelberg, Springer Berlin Heidelberg, 1991, vol. 483, pp. 313–341.
-  N. R. Jennings, K. Sycara, M. Wooldridge. A roadmap of agent research and development. Autonomous Agents and Multi-Agent Systems, Jan, 1998, vol. 1, nr 1, pp. 7–38.
-  T. Kornuta, C. Zieliński. Robot control system design exemplified by multi-camera visual servoing. Journal of Intelligent & Robotic Systems, 2013, Vol. 77, No. 3–4, pp. 499–524.
-  J. Luo, H. Ni, M. Zhou. Control Program Design for Automated Guided Vehicle Systems via Petri Nets. IEEE Trans. on Systems, Man, and Cybernetics: Systems, 45(1), pp. 44-55, Jan 2015.
-  D. Kortenkamp, R. Simmons. Robotic systems architectures and programming. In: Springer Handbook of Robotics Ed. O. Khatib, B. Siciliano, pp. 187–206. Springer 2008.
-  L. Montano, F. J. García, J. L. Villarroel. Using the time Petri net formalism for specification, validation, and code generation in robot-control applications. The International Journal of Robotics Research, 2000, vol. 19, nr 1, pp. 59–76.
-  J. L. Peterson. Petri Net Theory and the Modeling of Systems. Prentice Hall 1981.
-  R. Valk. Essential Features of Petri Nets. Berlin, Heidelberg, Springer Berlin Heidelberg 2003, pp. 9–28.
-  W. Vogler. Modular construction and partial order semantics of Petri nets. 1992.
-  The robot simulator VREP, http://www.coppeliarobotics.com/ accessed: 2018-09-12.
-  M. C. Zhou, F. Dicesare, D. L. Rudolph. Design and Implementation of a Petri Net Based Supervisor for a Flexible Manufacturing System. Automatica, 28(6), pp. 1199-1208, 1992.
-  C. Zieliński, M. Figat, R. Hexel. Communication Within Multi-FSM Based Robotic Systems. Journal of Intelligent & Robotic Systems, Jun, 2018.
-  C. Zieliński, M. Figat, R. Hexel. Robotic Systems Implementation Based on FSMs. In: Automation 2018. Proceedings Ed. R. Szewczyk, C. Zieliński, M. Kaliczyńska. Springer International Publishing, 2018, pp. 441–452.
-  C. Zieliński, T. Winiarski. General specification of multi-robot control system structures. Bulletin of the Polish Academy of Sciences – Technical Sciences, 2010, Vol. 58, No. 1, pp. 15–28.
-  C. Zieliński, M. Figat. Robot System Design Procedure Based on a Formal Specification. In: Recent Advances in Automation, Robotics and Measuring Techniques. Proceedings Ed. R. Szewczyk, C. Zieliński, M. Kaliczyńska. Springer, 2016. vol. 440, series Advances in Intelligent Systems and Computing (AISC), pp. 511–522.
-  C. Zieliński, T. Kornuta, T. Winiarski. A systematic method of designing control systems for service and field robots. In: 19-th IEEE International Conference on Methods and Models in Automation and Robotics, MMAR. Proceedings. IEEE, 2014, pp. 1–14.
-  W. M. Zuberek, I. Bluemke. Hierarchies of place/transition refinements in Petri nets. In: Emerging Technologies and Factory Automation, 1996. EFTA ’96. Proceedings., 1996 IEEE Conference on. Proceedings, Nov, 1996. vol. 1, pp. 355–360.