## 3 Cooperative Algorithms for Mobile Sensors
* The _Coordination function_, \(h_{C}(x^{j}(k),x^{i}(k))\) defines the priority of the coordination task (see Figure 5). It is computed online and modified by the vehicle during the evolution of the mission on the basis of the detection and communication performance of its onboard devices: the detection sonar range \(R_{D}\) defines the minimum distance between two vehicles; the maximum communication range \(R_{C}\) achieved at a given spatial and temporal location defines the maximum separation between two vehicles; in addition, we also define the parameter \(R_{M}\) as the maximum distance at which each agent wants to keep its closest neighbor. The parameter \(R_{D}\) can be thought as the maximum detection range at which the detection performance is above a desired threshold \(\overline{TH}\), \(R_{M}\) as the range above which the detection performance is below a minimum level \(\underline{TH}\). The coordination function is defined as: \[h_{C}(x^{j}(k),x^{i}(k))=\left\{ \begin{array}{ll}\frac{q(R_{M}-\|x^{j}(k)-x^ {i}(k)\|^{2})}{2}&\text{if }\|x^{j}(k)-x^{i}(k)\|\leq R_{M}\\ \frac{Q}{R_{M}-\|x^{j}(k)-x^{i}(k)\|}-\frac{\|x^{j}(k)-x^{i}(k)\|}{(R_{C}-R_{M} )^{2}}+C&\text{if }R_{M}\leq\|x^{j}(k)-x^{i}(k)\|\leq R_{C}\\ 0&\text{otherwise}\end{array} \right.\] (3) where \(q\) and \(Q\) are positive constants and \(C=-\frac{2R_{M}-R_{C}}{(R_{M}-R_{C})^{2}}\) is a smoothing constant. The steps of the cooperative algorithm are now summarized. The algorithm, described in what follows for the i-th one, is the same for every vehicle:  
Figure 5: Interest function for task 2: move away from your closest neighbour while maintaining the communication connectivity. The function represents the cohesiveness among the vehicles, as a function of range from the nearest neighbour (move away when the vehicles are close, move closer for values approaching the maximum communication range). 1. Vehicle \(i\) receives from all the connected nodes their locations and their maximum detection sonar range;
2. Vehicle \(i\) selects its closest neighbor;
3. Assign a priority to each task as defined by the corresponding interest function (Equations (2) and (3));
4. Compute the overall velocity control applying (Equation (4)) and move accordingly. Finally, the agent control input \(u(t)\), at each time frame is computed as the vector sum of the gradient of each interest function:  
\[u(t)=u_{A}(t)+u_{C}(t)=\bigtriangledown h_{A}+\bigtriangledown h_{C} \tag{4}\]  
Note that the algorithm makes each vehicle able to move back to the asset it needs to protect even when it loses the communication with the other team members, since each agent can always execute task 1 (move towards the asset). In this way the algorithm becomes intrinsically robust against a DoS attack and even when a vehicle cannot communicate with the rest of the team it can always move to ensure the protection of the asset (e.g., vehicle equipped with appropriate deterrence means). The performance of the cooperation is degraded but the subset of the agents that can still communicate, or in the worst case, each vehicle independently, can continue the mission. In addition, at each step of the mission each agent does not necessarily need to receive information from all other nodes: only information from its closest neighbour is needed for the coordination task. If information is available from more than one vehicle, an additional step is needed to determine the closest neighbour. In any case, the amount of information the vehicles need to exchange is limited, as they only require communicating their own position and maximum detection sonar range. Finally, it is worth pointing out that when a vehicle loses the communication with the remainder of the team, it may still be able to execute task 2 but using only not up-to-date information. In this case, the agent calculates the control input (Equation (4)) on the basis of the last known position of its neighbours.