Robot Interaction Through Smart Contract for Blockchain-Based Coalition Formation

. Nowadays robots are able to perform decisions independent from the operator. Also, they are able to form a various kind of unions, such as swarms, schools, or coalitions to perform joint task solving. The most powerful and flexible type of union is coalitions. Due to each robot acts like an independent agent it is important to provide trusted interaction between them. It is quite hard to do this with existing methods based only on the knowledge representation using ontologies and reasoning techniques. The paper proposes to use smart contracts in blockchain to enrich the knowledge-based system by functions, specific for blockchain such as immutable transaction log, consensus between all participants as well as possibility to automate control on task resolving. The paper describes the new environment framework based on integration of cyberphysical system and blockchain, and interaction model between all framework elements using BPMN 2.0 notation. Smart contracts presented in the paper provide functions for tasks distribution between robots, resource allocation, and monitoring the task execution and reward distribution.


Introduction
Nowadays robots are able to make independent decisions in unknown situations to perform planned actions considering current context.It becomes available by equipping robots with a large number of various sensors to check the physical environment parameters, actuators to make actions in it, microcontrollers that provide high computation power as well as computational algorithms that allow making decisions based on information received from embedded sensors of the robot or external information sources.Also, robots can perform the joint work to solve a common problem under current conditions.There are a large number of various solutions dedicated to the joint work performed by a group of robots.Among them, such models of joint work can be distinguished, like swarms, schooling and collective (coalition) work.The first two models are based on imitating wildlife swarms or schools, such as fish schools or insect swarms.Robots in such models use simple behavior patterns that allow them to make decisions based on a limited amount of information provided by nearest neighbors.
In a coalition model, each robot is viewed as a separate entity also known as agent, which allows the use of approaches developed for multi-agent systems [1,2].Robots can form a coalition when they are faced a problem and plan joint actions to solve it.Each robot in the coalition operates independently from the others, but within the scope of the developed plan and taking into consideration the current context.This approach provides possibility to make maximum use of the capabilities of individual robots to achieve a common goal.However, robot coalition formation with the distribution of tasks among all coalition members is very difficult NP-complete task.To date, many solutions have been proposed that provide an approximate solution to the coalition forming task [2,3,4,5,6].Another important task in the robots coalition formation is the organization of an information interaction environment between them, which allows information exchanging about the current situation and the distribution of tasks among the participants in the coalition.
Tasks distribution and assignment among the coalition participants requires specific functions to be implemented in the interaction environment of cyberphysical system (CPS) formed by physical environment, robots and software [7].The interaction based only on the knowledge representation using ontologies and reasoning techniques to distribute tasks among coalition participants can not provide a full picture of how the tasks were distributed [8].Coalition members can get an approximate idea of this, only by making full reasoning among the knowledge of other members.This behavior is more typical for swarm interaction models and reduces overall efficiency of the coalition.
To enrich existing interaction methods, it is proposed to use a central or distributed ledger, in which results or coalition participants' work are displayed.Such ledger allows to reduce the number of calculations on the coalition formation stage and to distribute tasks taking into account the capabilities and characteristics of all the participants in the coalition.At the same time, each participant at any time will have a view of task distribution as well as when it is expected to receive the result from other participants and what resources are involved in solving the overall problem.The overall view makes it possible to reconfigure the coalition on the fly by adding new or replacing participants which will know what they should do from the very beginning.
The paper presents a usage of blockchain to enrich existing robots coalition formation approach based on context management methodology and publish / subscribebased semantic interoperability mechanism.During the coalition creation, robots are negotiating to spread own knowledge about the task being solved, their current state and parameters of the environment.The negotiation process is carried out in a common information space also known as smart space, and the result of negotiations is the coalition in which the common complex problem is divided to tasks distributed among the coalition members.The separate tasks are bond to the robots, as well as the required resources, and the remuneration for solving the problem.Assignment and binding of tasks, resources and remuneration is proposed to be carried out using a smart contract that is based on the blockchain technology.
The rest of the paper is structured as follows.Section 2 provides description of related works in field of blockchain usage for robots and Internet of Thing components interaction.Section 3 provides a framework structure for robot negotiation during the coalition formation based on the cyberphysical smart space concept and blockchain, and model of the framework's components interaction using the BPMN 2.0 notation.Section 4 describes types of smart contracts used for negotiation and code examples for each type of contract.

Related Work
This section is aimed to provide examples of blockchain usage for organizing interaction between coalition participants in various models.
The paper [8] considers the use of blockchain technology to create a logically centralized system for managing the distribution of tasks among coalition members.The blockchain technology itself is considered as a mechanism for recording and tracking transactions between participants performing control over the distribution of tasks.At the same time, it is possible to create a virtual ledger that contains all distributions of the assets available among the coalition participants.
The paper [9] provides an example of the E-Business model for decentralized autonomous corporations based on IoT and blockchain.The blockchain network is used here to create smart contracts and perform payment transactions using Bitcoin and system's own currency -IoTcoin.The presented approach provides the following advantages that can also be used in robot coalitions: internal resources of the system are presented in the form of payment system tokens; distributed ledger for transactions, built-in mechanism of digital signature; and protection of transactions by linking blocks with a hash function of a given complexity.Interaction between elements is carried out by transactions passing through four phases: preparing a transaction, negotiating, signing a contract, and fulfilling the terms of the contract.
A similar method is considered in relation to a Smart Home scenario in [10].Also, there is an unchanged transaction ledger as an advantage of integrating IoT and Blockchain technologies.The proposed framework provides the following transaction processing functions: transaction storage, access to the transactions history and real-time monitoring.Also, due to the adaptation of the hierarchical structure of the proposed framework (which includes three levels: the smart home, overlay network, and cloud storage), optimization of resource consumption is achieved, and scalability of the network is increased.The functions of the block are focused on the level of interaction of elements in the overlay network.
It is also noted that the combination of the peer-to-peer network and the cryptographic algorithms that are underlying the blockchain technology allow for a negotiation process and consensus building without the presence of any controlling authorities.The distributed nature of the blockchain can be used in swarm robotics to store global knowledge about swarm actions [11].At the same time, due to blockchain, the security of the transmitted data is ensured (garbage data can affect the achievement of a common goal), distributed decision making (creating a distributed voting system for the solution and use of the multi-signature), separation of robots behavior (switching between behavior patterns depending on the robot's role in the swarm), the emergence of new business models using the swarm.In addition, the availability of a distributed transaction ledger allows new robots to join the swarm and gain all the knowledge they have gained prior to the moment of inclusion by downloading and analyzing the transaction history.

3
Robot Interaction Framework

Framework description
Robot interaction for coalition creation and functioning is based on the cyberphysical framework.The proposed framework implements publish/subscribe mechanism to provide real-time information sharing between robots.The conceptual scheme of the framework for the robots interaction is presented on Figure 1.The framework is based on the smart space concept that implements publish/subscribe interaction mechanism using the "blackboard" interaction model.It allows to organize interaction of robots in the physical and cyber (virtual) spaces that includes solo and joint actions of robots with various physical objects into the operation environment, information exchange about the current state of robots, objects, and environment for planning further joint actions during the coalition formation.

Fig. 1. Framework for robot coalition interaction
Large number of different robots and sensors, from different manufacturers and with different software, connected using different data transfer network raises a problem of the great heterogeneity of provided information and function as well as distribution of coalition participants that should be taken into account during their interaction.To provide interoperability between all coalition participants, the information exchange between them is implemented based on the ontologies usage.Such approach allows to expand the context by providing additional information about the semantic meaning of individual context parameters of shared information, for example, robot characteristics or object measurements.Each member of the CPS is presented by a knowledge processor (KP).KP implements functions of processing information from CPS member, as well as interaction (sharing and requesting the information) with other KPs using ontologies.For this purpose the common ontology can be developed for the whole system, or ontologies of individual components can be used, and information exchange between them is carried out using ontology matching methods [12,13] including usage of background knowledge for matching process [14].The concept of cyberphysical smart space in this case allows providing all CPS members a common information space through which they can distribute information.All the members have equal access rights to read and write information in cyberphysical space.
CPS itself cannot be viewed as trusted environment due to the lack of mechanisms to check authorship and correctness of the information shared through the cyber environment.To provide trustiness, information exchange that requires long-term immutable storage and the impossibility of unauthorized access to stored information it is proposed to use blockchain technology.These properties of the blockchain are required to solve several tasks at once, namely: monitoring the implementation of the basic norms of coalition interaction and agreements recorded in the smart contracts, as well as control over the expenditure of resources, including the basic resources of the system, specific to the problem area of the problem being solved.Several independent chains are created in the blockchain to store the distribution state of each of the available resources (Figure 1).A separate chain of blocks is used to share smart contracts that store the basic norms of behavior in the coalition and agreements formed based on the norms for the distribution of tasks among the coalition members.

Interaction model
The interaction between all components of framework for coalition interaction is presented on Figure 2 using BPMN 2.0 notation.Robots interact with each other through the cyberphysical smart space and through the blockchain by using of KP located on the robots' control block.KP provides the functions of processing data from physical components of robots, as well as sharing information through the cyber space.In addition, KP implements functions for robots interaction with each other during the coalition formation and accessing to the blockchain to obtain information about the available resources required to solve the bond subtask as well as to obtain the required amount of resource according to the corresponding smart contract.
Physical and cyber resources are also presented in the framework by corresponding KPs -Sensors KP for control the physical resources and information service KP to control the information resources.They perform control on resources state and timely informing all participants of cyberphysical system about changes in resources state and their characteristics as well as storing large data sets from sensors and robots in the cyber space (Figure 2).Resource characteristics changes are displayed in the smart space, while a changes of available amount of resources are displayed in the corresponding blockchain chain, which allows tracking its consumption and arrival.In order to ensure trust when changing the amount of resource, access to the blockchain is provided for all KPs directly using the private-public key pair from blockchain platform.
Cyber space is connected to the blockchain through blockchain KP.This KP provides consistency between information in cyber space and blockchain.It can be necessary for automatic control over the performance of smart contract conditions based on information located in smart space.

Fig. 2. Robot interaction model
When robot processes collected information required for the task it negotiates with other robots to make an agreement which task have to be solved by it.Conditions of the agreement are fixed into a smart contract that is placed in the blockchain's separate contract-oriented chain.To fox the task distribution new blocks are added to the blockchain that bind robots and subtasks.If robot needs some resource, it should provide request to the blockchain and allocation will be stored into the new transaction.In the subtask was successfully resolved the robot receives a bonus, which is to increase the competence parameter associated with the task being solved or some amount of internal currency.In case of non-fulfillment of the contract, the robot gets a lowering of the relevant competence, and the other participants receive an automatic notification about faults to adjust the plans for performing their tasks.

Smart Contract Examples for Robots Negotiation
Automation of robots interaction for the coalition formation and joint work is carried out through smart contracts.They describe the basic interactions of robots among themselves and during resources consumption.There are three types of contracts in the system, according to the functions provided:  Contract for the tasks distribution between robots;  Contract for resource allocation;  Contract for monitoring the task execution.
A description of each of the contract types is presented below taking into account the platform used for blockchain creation.It is proposed to use the Hyperledger Fabric platform to build the blockchain environment for robots' interaction [15].This choice can be explained in the way that the Fabric provides extensive architecture capabilities for configuring the platform for various tasks, as well as the ability to organize private blockchains.The platform provides a key-value storage for recording transactions, the ability to replace the mechanism for achieving consensus (by default, the Byzantine Fault Tolerance (BFT) mechanism is implemented using the BFT-SMaRt software module [16]), as well as the creation of contracts using the programming languages Go and Java, and contracts are executed in containers based on Docker.The declared speed of the platform satisfies the needs for interaction between robots due to the possibility of processing 3500 transactions per second [15].

Contract for the tasks distribution between robots
The distribution of tasks between robots is based on an analysis of the robot's correspondence to the requirements of the task to solve it, as well as the robot's requirements for rewarding for the task solution.It is believed that the dividing of a complex task into sub-tasks is predetermined and known at the time of the coalition formation.Correspondence of the robot to a certain subtask is determined by analyzing its equipment and comparing the onboard equipment to the one that is required to solve the subtask.At the same time robots, spending their energy and work resource can demand a reward in the form of an internal currency of the system, which can later be used to repair or charge by the owner of the robot.The contract presented here describes the search for robots to solve subtasks and binds the subtask to the robot, which can and is ready to perform it.

Contract for resource allocation
The resources used by robots are represented in the blockchain as tokens.Each resource has its own token, and the total number of tokens for the resource cannot exceed the maximum amount of the resource in the system (for example, for plant fertilizer in case of agriculture task or drugs in case of medicine task this quantity can be limited by the storage capacity of the warehouse), and the token itself is indivisible, corresponding to the minimum available unit of resource.
To account for the distribution of resources in the blockchain, a separate chain is created, which is realized in Hyperledger Fabric through channels.Each channel is accessible only to those participants who have an appropriate smart contract, which makes it possible to isolate the channels from each other.

Contract for monitoring the task execution
The task execution process is also tracked through a smart contract.This approach allows real-time notification of other coalition participants about the fact of the solving ending and automatically verifies the correctness and reliability of the subtask solution by interested coalition participants, for whom the result is important.If they agree with the results, the robot who solved the subtask is paid a reward and the performance of the entire task is progressing further according to the plan.If the robot has not coped with the solution, the contract condition is not met and, accordingly, the robot is not paid a reward, and the robot itself is replaced by another having the required competencies.At the same time, the plan for solving the common task must be recalculated taking into account the change in the composition of the coalition.

Conclusion
The use of blockchain technology and smart contracts has been proposed to provide immutable distributed storage of transactions about robot actions and resource allocation available for all coalition participants.This kind of storage is important on the negotiation stage when the coalition is formed to bind separated tasks with concrete coalition participants as well as on the execution stage to check the tasks execution process.Integration of blockchain and cyberphysical smart space had allowed to reduce the number of calculations on the coalition formation stage and to distribute tasks taking into account the capabilities and characteristics of all the participants in the coalition.Interaction model has been developed for the proposed framework components.It allowed to detect main interaction between components and formalize types of contracts needed for robots negotiation and joint task solving.These types are: tasks distribution between robots; resource allocation; and monitoring of the task execution.For each type of contract the examples had been proposed taking into account the Hyperledger Fabric blockchain platform specific.This platform has been selected for the proposed framework because it provides extensive architecture capabilities for configuring the platform for various tasks, as well as the ability to organize private blockchains and high performance in transaction processing.
As a result of the smart space and blockchain integration each robot is provided a possibility to have a view of task distribution at any time as well as have a view of what is expected time to receive the result from other participants and what resources are involved in solving the overall problem.The overall view makes it possible to reconfigure the coalition on the fly by adding new or replacing participants which will know what they should do from the very beginning.