Pairwise Control In Unmanned Aerial Vehicle Swarm Flocking

—Inspired by the natural phenomenon that pair-bonded jackdaws ﬂy together within a ﬂock, a new cooperative model and control method with pairwise structure in the swarm ﬂocking is proposed to perform proximity missions such as air refueling, data exchange and coordinated operations of two unmanned aerial ve- hicles in the swarm. A noval square-law error sliding mode surface and variable structure sliding mode controller are proposed, so that any two unmanned aerial vehicles in the swarm could converge to a speciﬁed relative distance. Based on this, the distributed control protocol is designed that integrates pairwise distance control and ﬂocking control. It enables unmanned aerial vehicles to be paired in the swarm without disrupting the consensus of the entire swarm. Finally, two theorems are proved by Lyapunov stability theorem. The distance between paired unmanned aerial vehicles is exponentially convergent, and the swarm ﬂocking is collision free. Swarm ﬂight simulations based on particle motion model with number from 20 to 100 are respectively presented, as well as 10 unmanned aerial vehicles swarm ﬂight simulations with quadrotor dynamics model. The simulation experiments have sufﬁciently veriﬁed the effectiveness and accuracy of the method. The results show that distance control could still be achieved in the extreme case that the paired unmanned aerial vehicles are at the farthest corners of the swarm.


I. INTRODUCTION
The characteristics of bird flock, such as high coordination, autonomy and robustness, are consistent with the goal of UAV swarm cooperation [1]. It is also the main source of inspiration for the current design of UAV swarm cooperative control protocol. Scientists observe the behavior patterns of biological flock, analyze their internal interaction mechanisms, reconstruct mathematical models, and design distributed cooperative control methods to apply them to the cooperation of UAV swarm. For example, Reynolds summarized the three principles of flocking, coherence, separation and velocity matching of bird flocks, and proposed the Boids model [2], which realized the computer simulation of swarm behavior. Tamás Vicsek proposed a self-organized particle model, or Vicsek model [3]. On the basis of these models, many researchers have conducted a lot of research on related issues of swarm and multi-agent control, and have achieved fruitful theoretical results, including first-order [4], secondorder [5], and high-order models [6], linear and nonlinear models [7], continuous and discrete models [8], directed and undirected graphs [9], fixed and switching topologies [9]- [11]. Considering the communication perception of data transmission between agents, time delay [12], quantization [13], noise [14] and transmission failure are included [15]. Significant progress has been made in protocol design, stability verification and convergence rate analysis [16]. There are also some literature reviews such as [17] summarized the latest progress in consensus, formation, flocking, containment, optimal coverage and mission planning. [18] focused on the perception ability and interactive topology of the agents, and control methods based on position, displacement and distance were classified.
In the field of engineering practice, the Vicsek team realized the autonomous swarm flocking of 10 quadrotor UAVs in 2014 [19], [20], and this work was reported by Nature [21]. In 2018, the Vicsek team further realized the high-speed swarm flocking of 30 quadrotors under realistic constraints such as delay, disturbance, and obstacle of communication in the swarm. This work was published as a cover article in Robotics [21]. The Haibin Duan team of BeiHang University conducted an in-depth study on the cooperative control of UAVs based on swarm intelligence, mapping the behavior mechanisms of bird flock [23], pigeon flock [24], goose flock [25], and wolf flock [26] into the cooperative control of UAV swarm respectively, and good results were achieved.
Most of the current research on UAV swarm control assumes that all individuals follow the same interaction rules or control protocols. However, in recent years, scientists have revealed more interaction methods by observing bird flocks. Advances in technology have allowed scientists to install sensors on birds to collect data. For example, researchers have analyzed large amounts of data collected from jackdaw flocks [27] [28] [29] [30] and found that pairwise substructures are in the jackdaw flocks as Fig.1. That is, paired jackdaws always maintain a relatively close distance through the spring-like interaction force [27], [31]- [34]. Through further analysis of the flapping wings of jackdaws in the video, it is found that the interaction between paired jackdaws and their neighbors is less than that of unpaired birds in the flock, and the flapping speed is also slower, which is more conducive to energy saving [35].
Large amounts of jackdaw flock data provided inspiration for designing the flight mode of UAV swarm. Although whether pairwise flight is conducive to energy saving remains to be further verified, there are a large number of mission scenarios in real applications that require two UAVs to maintain a relatively fixed distance, such as air refueling, close exchange of data and cooperative task execution. At present, many UAVs could only mount a single weapone and quipment. For example, one is equipped with detection equipment and the other is equipped with offensive weapons. Therefore, it is more urgent for the two UAVs to cooperate closely to carry out attacks. In addition, the dual-aircraft formation is also a very effective air combat mode formed after a long period of air combat and training [36].
In terms of mathematical models, most of the current researches are based on the Boids model [2] and the swarm control framework proposed by Olfati-Saber [37]. A relatively stable grid structure will be formed in Olfati-Saber swarm control, as shown in Fig.3. If pairwise flight is conducted with swarm flocking, many difficulties will be encountered. First, the attraction-repulsion force between UAVs will hinder the paired UAVs from approaching. In the simulation experiments, it is found difficult to achieve precise control of the paired UAVs by using only the spring-like force, as shown in [42]. The first reason is that the disturbance is increased due to the mutual influence of the neighboring UAVs. The second is that the UAVs need to maintain a certain distance. Especially when the distance is too close, a large repulsion force must be generated. The attraction-repulsion force function is usually nonlinear, which also increases the difficulty of controller design. In response to the above problems, this paper researches on pairwise control in a swarm. A power-law tracking error function and corresponding sliding mode controller are proposed, by which the paired UAVs could break through the constraint force of lattice structure and converge to the specified relative distance. Through the Lyapunov stability proof, the theorems are obtained. The distance between paired UAVs is exponentially convergent, and the swarm flocking is collision free. Finally, the effectiveness and accuracy of the method are verified by simulation experiments where the number of UAVs is set to 50 and 100 respectively. The results show that the distance control can still be achieved in the extreme case that the paired UAVs are at the farthest corners of the swarm.
The major contributions are as follows: A bio-inspired pairwise control protocol of UAV swarm is proposed in this paper, where a noval square-law error sliding mode surface is specifically designed to achieve the precise distance control of paired UAVs. It is theoretically proved that the sliding mode of the pairwise control system is stable and the sliding point converge to the switching surface in finite time. The distance between paired UAVs is exponentially convergent, and the swarm flocking is collision free. The simulation experiments show that the steady-state error is less than 0.1m, which is better than the traditional method (the steadystate error is about 2.5 m).
The structure of this paper is as follows: In section 2, the second-order dynamics model of swarm is established, and relative definitions and mathematical lemmas are given. In section 3, the protocol of swarm flocking with leaders and pairwise control are proposed. Section 4 focuses on the design of sliding mode controller for pairwise control to solve the problem of pairwise convergence difficulty, including error model, sliding mode surface design and corresponding sliding mode controller. In section 5, the convergence of sliding mode surface, the convergence of distance between paired UAVs and the stability of the entire swarm are proved. In section 6, the computer simulation is carried out.

II. DYNAMICS MODEL OF UAV SWARM
Considering the dynamics equations of N UAVs are as follows: where q i , p i , u i ∈ R n are position vector, velocity vector and acceleration vector of UAV i respectively.
At time t, the undirected graph G (t) of the UAV swarm is shown in Figure 3. It is composed of UAV node set V and UAV communication link E, where the UAV node set is expressed as V = {1, · · · , N }, and the UAV communication link set is expressed as Let r represent the perception radius of multiple UAVs and the expected distance is d, and then the neighborhood of UAV i is defined as follows: The interactive relationship between the entire UAV swarm can be expressed by Laplacian matrix. Laplacian matrix L is defined as follows: In order to avoid collisions between individuals, the expected evolution goal of relative position of UAV swarm is specified as follows: However, due to the interaction of attraction and repulsion between individuals, it will be difficult to reach the ideal α -lattices system [37] and eventually evolve into α -lattices-like system as Formula (5) is named as α -lattices-like system. The two systems are shown in Fig.3. Pinning node:In order to guide the UAV swarm to move in the expected direction, an external controllable virtual leader is added [37]. The UAV that can receive the information from the virtual leader directly in the swarm is called the pinning node [37].
The mathematical expression of h i (t) at time t is defined as follows: 1, node i is pinning node 0, node i is NOT pinning node (6) Diagonal matrix H and augmented Laplacian matrix A are defined as follows: Proof: Because L and B are positive semidefinite matrices, for any nonzero column vector x and y, we have And then for any non-zero column vector u, we have if k = 0, H = 0, C = L+B, and then C is a positive semidefinite matrix.
Given that C is a positive semidefinite matrix, we will prove that C is a positive definite matrix by reduction to absurdity as follows: Assume that C is not a positive definite matrix, and then there exists z = 0 such that zCz T = 0.
And because L is a Laplacian matrix, zLz T = 0, if and only if zCz T = z (L + B) z T = 0, which contradict the assumption. Therefore, C is a positive definite matrix.

III. CONTROL PROTOCOL OF SWARM FLOCKING
The control protocol of each UAV u i (t) is designed to achieve the following goals: a) Distance between neighboring UAVs satisfies formula (5). b) Speed of neighboring UAVs remains consistent. c) All UAVs follow the virtual leader. d) Distance between the paired UAVs A B is equal to an expected value dm, namely q B (t) − q A (t) 2 = dm.
Suppose the control input of each UAV at time t is as follows: f g i is called the relative distance control term, which is used for the separation or aggregation of the flocking positions. f v i is called the speed consistency control term, which is used for speed alignment. f γ i is called the pinning feedback term, which is used for the pinning of the nodes to follow the virtual leader. f χ i is the proposed pairwise control. h i is the pinning node option term of the virtual leader, and h χ i is the pairwise option term. The mathematical expression of h χ i (t) is as follows: 1, node i is pairwise node 0, node i is NOT pairwise node (12) A predefined distance should be kept between neighboring UAVs in the UAV swarm flocking. A continuous attraction-repulsion function is designed in [37]. Although it is of good mathematical properties, the form is too complicated to implement. In order to facilitate analysis and calculation, the distance control term in this paper adopts the potential energy function proposed in [38]. The expression of the function is as follows: where g : R n → R n is a function which represents the attraction and repulsion force between individuals [23]: Let g a and g r satisfy formula (15), (16), (17): Suppose the speed consistency control term f v i is as follows: Suppose the pinning feedback term f γ i is as follows: where qγ , pγ ∈ R n are the position and velocity vector of the virtual leader at time t, and c γ 1 and c γ 2 are two regulation constants. In general, the following assumptions about the initial conditions of the swarm are made: Assumption 1: The initial state of UAV swarm is connected, that is, the initial state G (0) of the undirected graph is connected.
Assumption 2: There is no collision in initial state of the UAV swarm.

IV. DESIGN OF THE PAIRWISE CONVERGENT SLIDING MODE CONTROLLER
The sliding mode control has the advantages of fast response, insensitive to parameter changes and disturbances, no online system identification, and simple physical implementation [39]. In order to achieve precise distance control between paired UAVs, the method of variable structure sliding mode control is adopted in this paper.
The basic idea of variable structure sliding mode control is to divide the motion of the system into two parts. The first part is the motion stage from the initial state to the switching surface, which is called the arrival stage. The second part is the motion stage of the system on the switching surface, that is, the sliding mode stage. The design of sliding mode controller could also be divided into two parts. The first part is the design of sliding mode surface, and the second is the design of switching control, so that the system state could enter the sliding mode surface designed in the first part under any initial conditions [40].
Next, the system model is established, and the sliding mode surface and sliding mode controller are designed according to the above steps.

A. Mathmatics model of paired motion system
For paired UAVs A, B, in addition to the swarm flocking, another important control goal is to make the distance between A and B converge to an expected value: Suppose the state variable y is as follows: From formula (1) and (11), we have Since h χ A = h χ B = 1, and from formula (11) and (22), we havë

B. Design of sliding mode surface
In order to achieve the control goal of formula (20), the error model is modified accordingly. New square-law tracking error e,ė and sliding mode surface s are designed as follows: s = ce +ė = cy T y − cd 2 m + 2y Tẏ = y T (cy + 2ẏ) − cd 2 m (26) The sliding surface uses the square form as (24), so we can make the control target dependent only on the absolute distance and not on the relative position. Another form is y 2 − d m . The control objectives of the two are equivalent, but the two problems are different. In contrast, the sliding surface (24) is differentiable everywhere, and has better mathematical properties.

C. Design of controller
The corresponding reaching lawṡ and controller u are designed to make the system move according to the predetermined state track of "sliding mode".
Let E = y T y, F =ẏ Tẏ , and the reaching law is designed as follows:ṡ = k sign(s) The algorithm of pairwise distance regulation is designed as follows: where sign(y) =

V. THEORETICAL RESULTS
In this section, Lyapunov's second method is mainly used to prove the stability of the pairwise system and the swarm system. The proof of sliding mode control is given, and the following Theorem 1 and Theorem 2 are proved. On this basis, Theorem 3 is proved. Finally Theorem 4 is proved namely the entire swarm will get into flocking state.
(Theorem 1) The sliding mode of the control system tends to be stable on the switching surface s = 0.
(Theorem 2) The variable structure control law u makes the sliding points move to the switching surface s = 0 in a finite time.
(Theorem 3) The distance between paired UAVs converges to an expected value.
(Theorem 4) The UAV swarm will get into flocking state without collision.
The mathematical statements and proofs of the theorems are as follows.
Proof: If s = 0, we have From (29), we could get the first order nonlinear differential system: Thus, the stability of the stationary solutions is proved. So, if t → ∞, e 2 → d m , we have es ∈ Ω = e : e 2 = d m . Theorem 2: The sliding mode surface shown in (26) and the pairwise regulation function shown in (28) are used to make the moving points out of the switching surface s = 0 move to it in a finite time under the controller (11).
From Assumption 1 and Assumption 2, we can get the following theorems: Theorem 3: For the two UAVs in the swarm that need to be paired, the sliding mode surface adopts (26) and the pairwise regulation function adopts (28). By the controller (11), the distance between paired UAVs converges exponentially to an expected value dm.
Theorem 4: The UAV swarm system, with UAV motion equation as formula (1), and the control protocol as formula (6). Then one or multiple UAVs are selected as the pinning nodes, and we have: (1)The relative positions of all UAVs will eventually tend to lattices.
(2)The speed of all UAVs will tend to the speed of the virtual leader pγ (t).
(3)There will be no collision between UAVs.
(4)The positions of the pinning nodes will tend to the position of the virtual leader qγ (t).
Proof: Suppose the tracking error between UAVs and the virtual leader is as follows: Suppose the distance between UAVs is as follows: We have Let the potential energy function of a single UAV be If there is no overlap between UAVs, q i = q j , that is ,q i (t) = q j (t), and we have Let the total system energy of the UAV swarm be Q (t), including the total kinetic energy and potential energy of all UAVs, expressed as follows: Differentiate Q (t) with time t, and substitutes it into the control protocol (11). We havė From Theorem 1, c α 2 L (t) + c γ 2 H (t) ⊗ I A is a positive definite matrix.
Q < 0, and the total energy of the system will decay continuously.
According to the definition of potential energy function U (q), N i=1 U i ( r α) < Q(0) < Qmax. However, the distance between two neighboring nodes at time t should be less than r, that is, the existing edge in the network will not break. Suppose that after △ t time, A edges are added to the network, and we have This indicates that the existing edges in the system will not break over time. The initial network is connected, so the system will always remain connected.
Without loss of generality, suppose in the period of ts ∈ [t 0 , t 1 ] , two UAVs i,j collided in ts ∈ [t 0 , t 1 ]. The Φ i (t) will increase, so the total energy Q(t) will increase, This conflicts withQ(t) 0, so the two drones will not collide. In the same way, there will be no collisions between the UAVs of the swarm on [t k , t k+1 ] at each time period.
In addition, from [26], the theorem is proved.

VI. SIMULATION
A. UAV swarm flight simulation with particle motion model In the simulation, the UAV swarm is set to move in the twodimensional space, and the number of UAVs is set to n = 50 and n = 100 respectively to in different to verify the performance of the algorithm in different numbers. In order to verify the effect of pairwise control, the two UAVs, No.1 and No.2, to be paired are placed on two corners: q 1 = (−90, −90) , q 2 = (90, 90). The expected distance is dm = 5, and the initial positions of all other individuals are randomly distributed in the 100 × 100 region. The virtual leader has a fixed speed, the initial position of the virtual leader is (25, 25, ) and the speed keeps constant (0.5, 0.5).
In the figures, each small triangle represents a UAV, and the acute angle of the triangle represents the heading of the UAV. The triangles in the circle are the UAVs to be paired, and the radius of the circle is r = dm = 5. The virtual leader is represented by a pentagram.
The four sub-graphs in Fig.4 respectively show the positions and directions of the UAVs at different times. The distances between paired UAVs gradually approaches to the ideal distance over time, and Theorem 3 is verified. The speeds of all UAVs tend to be the same and gradually approaches the speed of the virtual leader, so Theorem 4 is verified. Fig.5 shows the situation when the swarm is stable, and the length of the arrow indicates the velocity magnitude. Fig.6 shows the convergence of the sliding mode surface in the distance regulation algorithm, and it converges to 0 after about 2 seconds. Fig.7 shows the distance between UAV No.1 and UAV No.2 to be paired, and the expected distance is achieved after about 4 seconds.
In this simulation, even the initial condition is set to be the extreme case that the paired UAVs are at the farthest corners of the swarm, and the distance control could still be achieved. However, due to the long distance, there will be a certain amount of disturbance between the neighborhood UAVs, as shown in Fig.4, and inevitably there will be some influences on the convergence rate of the whole swarm.
As a comparative simulation, based on 50 UAVs, the pairwise distance control term is replaced with the distance control method proposed follow the proportion control method [44] which referred to as normal method, as shown in formula (44). And other control terms remain unchanged. The four sub-graphs in Fig.8 respectively show the positions and directions of the UAVs at different times with the normal control method. Fig.9 shows the situation when the swarm is stable, and the length of the arrow indicates the velocity magnitude. The comparison effect of the distance error between normal method and the sliding mode method is shown in Fig.10. The steady-state error of normal method is still about 1.7m, while that of the sliding mode method of this paper is about 0.3m. The main problem of the normal control method is that the steady-state error cannot be eliminated and the When the number of UAVs reaches 100, the simulation results are as follows. The four sub-graphs in Fig.11 respectively show the positions and directions of the UAVs at different times with the normal control method. Fig.12 shows the situation when the swarm is stable, and the length of the arrow indicates the velocity magnitude. Fig.13 shows the convergence of the sliding mode surface in the distance regulation algorithm. Fig.14 shows the distance between UAV No.1 and UAV No.2 to be paired. It is proved that the   The quadrotor flight control systemm adopts continuous high-order sliding mode position controller [43] and SO (3) attitude controlle [44] which developed in our early work.
Suppose the rotational inertia matrix of the target UAV is the mass is mass = 0.455kg. The virtual leader was set to move in a straight line at a speed of 5m/s and the simulation duration was set as 65s. The virtual leader climbed at 0-20s, smoothly rotated 90°at 20-22s 50-52s and 70-72s respectively, and flew in a straight line at other times.
The position of the UAV at different moments is shown in Fig.15. The arrow points to the direction of the velocity, and the length represents the magnitude of the velocity. The triangle inside a circle is the uav that needs to be paired. The radius of the circle is equal to the expected distance between the paired UAVs. Simulation shows that the quadrotor UAV swarm can realize swarm flight and better tracking effect. The flight trajectory of the quadrotor UAV swarm following the virtual leader is shown in Fig.16.
The convergence of the sliding mode surface is shown as Fig.17. The distance between the paired UAV will converge and the tracking error is shown in Fig.18.
The following is to observe the attitude tracking response of the No.1 paired UAV. For the sake of intuition, we convert the output instructions of the position controller into euler angle command to the attitude controller, as shown in Fig.19. The actual attitude angle responses of the UAV is shown in Fig.20. The UAV can track the euler angle commands, but due to the inertia of the UAV itself, there will be a certain delay, which is also the reason why the quadrotor UAV has a little delay and oscillation in flight compared to the ideal particle motion model, but it can still achieve paired tracking and swarm flight.

VII. CONCLUSION
In this paper, the pairwise control in UAV swarm flocking is first proposed, which provides a new idea for the cooperative control mode of UAV swarm, especially for the UAVs with limited load that need to perform tasks cooperatively. In the design of control protocol, the sliding mode surface of square-law error and the pairwise sliding mode controller are proposed, and theorems are proved. The sliding mode of the pairwise control system is stable and the moving points converge to the switching surface in finite time. The distance between paired UAVs will converge, and collision free flocking is achieved. Finally, the simulation experiments of swarm flocking are completed with 50 and 100 UAVs respectively. In order to verify the effect of pairwise control in the extreme case, the two UAVs that need to be paired are placed on two corners, and precise distance control of the paired UAVs can be achieved. Based on the quadrotor UAV dynamics model, the swarm flight simulation of 10 UAVs was carried out to verify the effectiveness of paired control. However, due to the inertia of UAV, the tracking accuracy of uAVs will be affected. The next step is to pair more UAVs on the basis of this article. On the one hand, the number of interactive neighboring UAVs can be reduced by pairwise control, and on the other hand, a more complex cooperative mode can be realized. How to design the control protocol to ensure the consistency and flocking of the swarm with accurate and fast pairwise control is a problem that needs further research.

STATEMENTS
Data Availability Statements: The datasets generated during and/or analysed during the current study are available from the corresponding author on reasonable request.
Conflict of Interest: The authors declare that they have no conflict of interest.