UAV Formation Obstacle Avoidance Control Algorithm Based on Improved Artificial Potential Field and Consensus

Aiming at the problem of UAV formation's obstacle avoidance and the consensus of position and velocity in a 3D obstacle environment, a novel distributed obstacle avoidance control algorithm for cooperative formation based on the improved artificial potential field (IAPF) and consensus theory is proposed in this paper. First, the particle model of the UAV and the dynamic model of the second-order system are established, and the topological structure of the communication network of the system is described with the knowledge of graph theory. Second, the attractive potential field function containing the coordination gains factor, the repulsive potential field function containing the influence factor of the repulsive force and the planning angle, and the potential field function between the UAVs containing the communication weight are defined. Then, the variables of position and velocity in the consensus protocol are improved by the reference vector of the formation center and the expected velocity, respectively, and a new formation obstacle avoidance control protocol is designed by combining the IAPF and the theory of consensus. Finally, the Lyapunov function is used to prove the stable convergence of the algorithm. The simulation results show that this method can not only prevent the UAV from colliding with each other while avoiding static and dynamic obstacles but also enable the UAV to quickly restore the expected formation and achieve the consensus of the relative distance, relative height, and velocity.


Introduction
In recent years, the cooperative control of multi-UAV systems has become a research hotspot in the field of aviation control [1][2][3]. Among them, cooperative formation control is also one of the important research contents in the field of cooperative control [4][5][6], and it is widely used in the military and civilian fields. However, with the increasing complexity of the modern battlefield environments and combat task requirements, it has become particularly urgent to complete certain combat tasks by multi-UAV, which will make UAVs face greater challenges when performing complex tasks. For example, UAVs can not only prevent selfcollision but can also safely evade various obstacles during flight. The UAV can restore the expected formation after avoiding obstacles, reach the target position stably, and finally achieve the consensus of the position and velocity, to ensure that the UAV completes various tasks through cooperation [7,8]. Therefore, it is of great significance to study the problem of cooperative formation avoidance and consensus control of multi-UAV systems. This can not only enrich the cooperative control theory of multi-UAV systems but also provide a more theoretical basis for the autonomous control technology of UAVs.
Formation obstacle avoidance refers to the formation control behavior in which multiple UAVs can autonomously and safely avoid various obstacles on the route to meet the requirements of the battlefield environment constraints, and finally reach the target point smoothly [9]. Commonly used obstacle avoidance control algorithms include optimization method [10,11], neural network method [12,13], genetic algorithm [14,15] and so on. This paper will not go into details because there are already detailed discussions about these methods in the references. In recent years, the wide application of artificial potential field (APF) [16] and consensus-based control algorithm [17] in cooperative formation obstacle avoidance and consensus control has also aroused the extremely high research interest of scholars. Among them, the APF is a typical obstacle avoidance control algorithm. For example, Zhao et al. used an IAPF and formation division method to combine to make highspeed UAVs more flexible to avoid obstacles [18]. Seyyed et al. added an adjustment agent to the artificial potential field function to improve the efficiency of avoiding fixed obstacles and reach the target position with the best path [19]. Hu et al. proposed a distributed collision avoidance and obstacle avoidance control method based on IAPF and Voronoi constraints to enable UAVs to avoid collisions while avoiding obstacles smoothly [20]. Chang et al. proposed an IAPF based on the rotation vector, which can plan a collision-free and efficient obstacle avoidance trajectory for the UAV [21]. Although the potential field functions designed in the above references can achieve the effect of avoiding obstacles, the gains in the potential field function are all in the form of fixed coefficients, and multiple debugging is required to determine more reasonable parameters, which increases the difficulty of debugging. The repulsive potential field is only used to avoid static obstacles, but it does not mean that the potential field is also applicable to environments with static and dynamic obstacles. Although APF has the advantages of simple calculation and strong real-time performance, it also has defects such as unreachable targets, local minima, and self-collision. Aiming at the problem of the unreachable target. Wang et al. proposed a formation control strategy combining virtual leader and APF, which realized that multi-UAV formation can reach the target position safely without collision [22]. Dai et al. modified the attractive potential field function and the repulsive potential field function based on the segmented idea to make the UAV reach the target point smoothly [23]. Aiming at the problems of self-collision and local minima. Zhang et al. proposed a "lead follower" control strategy based on APF to solve the problem of self-collision and local minima of multi-UAV and enable UAV to effectively avoids space obstacles [24]. Sun et al. proposed a method with distance factor and jump strategy to solve the problem of collision [25]. The potential field function between the UAVs designed in the above references does not consider the influence of the communication weight, which does not conform to the principle of distributed control. The theory of consensus is also widely used in the field of UAVs. The so-called consensus means that in the absence of global communication, several individuals in the spatial distribution achieve the same state through local mutual coupling [26]. Dai et al. used the idea of segmentation to improve the attractive potential field function and the repulsive potential field function, introduced the rotation force and the potential field force between the UAVs, and corrected the state error of the UAV based on the consensus theory, and designed the obstacle avoidance control law of cooperative formation to achieve state consensus and trajectory planning [27]. Wen et al. realized the multi-UAV formation obstacle avoidance control by combining the strategy of Leader-Follower, the APF, and the consensus algorithm [28]. Belkacem K et al. proposed a new distributed consensus algorithm based on the consensus theory for the cooperative control of the second-order multi-UAV system to realize the formation avoidance and tracking control of UAVs [29]. He XY et al. designed a distributed adaptive consensus algorithm combined with the potential field method with distance constraints to enable the UAV to achieve tracking control in the anti-collision situation [30]. The above-mentioned references adopt the method of combining IAPF and consensus theory to achieve the consensus of state and obstacle avoidance, but the potential field function between the UAVs still does not consider the influence of communication weight, and the formation recovery of UAVs after obstacle avoidance is relatively slow.
According to the above discussion and analysis, it can be seen that the research of multi-UAV formation obstacle avoidance and consensus control has made certain progress, and the method of combining APF and consensus theory has been widely used in the field of formation avoidance control, but existing research still exists several questions. For example, the UAV is not well able to adapt to the complex environment with static and dynamic obstacles because the gain in the designed potential field function in [18][19][20][21] is still in the form of a fixed coefficient. UAVs cannot avoid dynamic obstacles since the movement velocity of dynamic obstacles is not considered in the improved repulsive potential field functions of these references. The potential field function between the UAVs designed in [22][23][24][25] is not completely consistent with the topological relationship of the communication network because it does not consider the influence of the communication weight. And most of the references do not comprehensively consider the problem of UAV obstacle avoidance and the consensus of the state after obstacle avoidance. The potential field function between the UAVs designed in [27][28][29][30] still does not consider the influence of the communication weight, and each UAV cannot quickly return to the original desired formation after avoiding obstacles. In response to the above problems, a new potential field function is defined, and a consensus protocol is designed based on a distributed formation control structure. The consensus control of multi-UAV system cooperative formation obstacle avoidance is studied based on the idea of combining IAPF and consensus theory.
The main contributions of this study are as follows: 1. The fixed coefficient form of the gain in the potential field function is improved into a coordination factor form that can be automatically adjusted in real-time. The attractive potential field function containing the coordination gains factor is defined, and the influence factor of the repulsive force is introduced into the repulsive potential field function to prevent the UAV from falling into a local minimum and ensure that the UAV reaches the target point smoothly. 2. The coordination gains factor of the repulsive force based on the movement velocity of the dynamic obstacle, planning angle, and distance deviation is introduced into the repulsive potential field function to improve the adaptability of the UAV to static and dynamic obstacle environments. And the potential field function between the UAVs with communication weight is defined to improve the convergence efficiency. 3. A distributed cooperative formation obstacle avoidance control algorithm based on IAPF and consensus theory is proposed to achieve control objectives such as rapid obstacle avoidance, the consensus of the velocity of UAV, relative distance, and relative height between UAVs. The rest of the paper is organized as follows. In Sect. 2, the UAV particle models and system dynamic models are established, and the related knowledge of graph theory is briefly described. In Sect. 3, the obstacle avoidance control algorithm of cooperative formation is designed, and the principles of the IAPF and improved consensus protocol are discussed in detail. In Sect. 4, the stable convergence of the algorithm is proved by the Lyapunov function. In Sect. 5, simulation is carried out to compare and analyze the simulation results to further verify the effectiveness of the algorithm. In Sect. 6, the research content is summarized and the future research work has prospected in this paper.

Modeling and Problem Description
The research of UAV formation consensus control usually includes three basic elements of dynamic individuals, communication network topology, and consensus protocol [31]. The particle model of the UAV and the system dynamic model based on the second-order integrator will be established, and the graph theory knowledge used to establish the communication network topology will also be introduced in this section. The design method of cooperative formation obstacle avoidance and consensus control protocol will be discussed in Sect. 3.

The Particle Model of the UAV
In this paper, the dynamic individual is the UAV, and its motion model in space is mostly a complex six-degree-offreedom model. The center of mass motion equations of the UAV have been described in detail in Ref. [32], and this paper will not repeat it. To conveniently analyze the problems of formation avoidance, formation recovery, and the consensus of relative position and velocity, the control of attitude is ignored, and each UAV is regarded as a single agent, and the simplified UAV mathematical model is described in matrix form as shown in Eq. (1): is the movement velocity of the UAV, F usi = (F usix , F usiy , F usiz ) is the resultant force received by the UAV, d ui min and d ui max are the minimum and maximum values of the UAV's visual distances, respectively, d uij is the expected distance between the two UAVs that can exchange information. Since the IAPF can calculate the movement velocity of the UAV in real-time, it is considered that there is a certain velocity range, and v ui max is set as the maximum velocity of the UAV, i, j ∈ {1, 2, … , n}.
This model describes the relationship between the resultant force received by the UAV in the IAPF and the movement velocity and space position. In each iteration, the resultant force is obtained to calculate the acceleration and velocity corresponding to the next moment, and the position information at the next moment based on the position information at the current moment is treated as a new starting position. The calculation mechanism is continuously looped to plan the flight path for the UAV in real-time.

The Dynamic Model of Multi-UAV System
As far as the state is concerned, the formation consensus means that the relative position and velocity of UAVs converge and tend to be consistent, therefore, a dynamic model of the multi-UAV system based on the second-order integrator is established. Without loss of generality, this paper considers a formation system with UAVs, where the dynamic equation of the i-th UAV is shown in Eq. (2): w h e r e x ui = (x uix , x uiy , x uiz ) , v ui = (v uix , v uiy , v uiz ) a n d u ui = (u uix , u uiy , u uiz ) are the position status, velocity status, and control input of the i-th UAV, respectively. The state

3
vector and the second-order basic consensus protocol of the formation system are shown in Eq. (3) and (4), respectively: where a ij is the communication weight between UAVi and UAV j , 1 > 0 and 2 > 0 are the protocol parameters.
Definition 1 When each UAV satisfies Eq. (5) for any given initial state, it is said that the multi-UAV system gradually reaches consensus.
It should be noted that when the consensus theory is applied to the control of multi-UAV formations, to avoid the center of mass of the UAVs overlapping at one point, the safety distance between UAVs should be considered and the position coordination variables should be improved. See Sect. 3.3 for details.

The Knowledge of Graph Theory
The information interaction process between the UAVs can be described by the knowledge of graph theory, that is, nodes represent UAVs, and the edges between nodes represent the information transfer relationship between the UAVs. Sup- is an undirected edge between v i and v j in the graph. If the UAV i can transmit information to the UAV j , then v i is called the parent node, v j is the child node, that is, v i is the neighbor of v j . The set of all the neighbors of the node v j can be represented by where l ij = −a ij , ∀i ≠ j,l ii = ∑ n j=1,j≠i a ij . In the graph, the total number of all UAVs that transmit information to the UAV i is defined as the input degree, and the diagonal matrix D composed of the input degree is the degree matrix of the graph and L=D − A is the Laplacian matrix of the graph.

Obstacle Avoidance Control Algorithm of Cooperative Formation
This section mainly designs the obstacle avoidance control algorithm of cooperative formation. Firstly, the basic principles of the traditional APF are summarized, and the reasons for its inadequacy in the field of formation control are analyzed. Secondly, an IAPF with three parts includes the attractive potential field, the repulsive potential field, and the potential field between the UAVs are designed. Then, the position variable and the velocity variable in the consensus protocol are improved, respectively, through the reference vector of the formation center and the expected velocity. Finally, an obstacle avoidance control algorithm of cooperative formation based on the IAPF and improved consensus protocol is proposed.

Traditional APF
Khatib proposed an APF based on the virtual field in Ref. [33]. In a 2D static obstacle environment, a UAV moves toward the target through the attractive force generated by the attractive potential field at the target point, and the UAV hinders itself from moving toward the obstacle through the repulsive force generated by the repulsive force field around the obstacle. The UAV finally reaches the target position driven by the resultant force. The principle of the traditional APF is shown in Fig. 1. the attractive potential field function, the function of the attractive force, repulsive potential field function, and the function of the repulsive force are shown in Eqs. (6)-(9), respectively: are the attractive potential field and the repulsive potential field, respec- are the attractive force and the repulsive force, respectively, ‖ ‖ x u − x t ‖ ‖ is the distance between the UAV and the target point, ‖ ‖ x u − x o ‖ ‖ is the distance between the UAV and the obstacle, d o is the influence distance of the obstacle repulsive potential field on the UAV, ut and uo are the gains coefficients of the attractive force and the repulsive force, respectively.
The resultant force received by the UAV is shown in Eq. (10): where F ut (x u , x t ) , F uo (x u , x o ) and F u (x u ) are the attractive force, the repulsive force, and the resultant force, respectively.
There are several problems when the traditional APF is applied to UAV formation control: 1. The UAV will not be able to reach the target point because the repulsive force generated by all obstacles on the UAV may be much greater than the attractive force generated by the target point on the UAV when there are obstacles near the target point. Or the UAV falls into a local minimum because the resultant force is zero when the UAV is located in an area with dense obstacles. 2. UAVs can only avoid static obstacles but cannot avoid dynamic obstacles because the traditional repulsive potential field function does not consider information such as the velocity of dynamic obstacles. 3. UAVs are prone to collision with each other because they are only affected by the attractive force and the repulsive force and the interaction between UAVs is not consid- ered when multiple UAVs fly at the same time. After avoiding obstacles, the UAV cannot quickly recover the expected formation and cannot ensure the consensus of the relative position and velocity because the communication weight is not considered in the potential field function.

IAPF
The multi-UAV is not only affected by the attractive force and the repulsive force in a 3D obstacle environment, but also by the potential field force between the UAVs. Supposing the resultant force received by the UAV is shown in Eq. (11): are the attractive force, the repulsive force, the potential field force between the UAVs and the resultant force, respectively, and i, j ∈ {1, 2, … , n}.

The Attractive Potential Field of the Target
A coordination gain factor is introduced into the piecewise attractive potential field function to make each UAV reach the target point smoothly in a complex obstacle environment, and the factor is determined by the distance between the UAV and the target point and the expected distance deviation of the formation. Then the newly defined attractive potential field function and the function of the attractive force are shown in Eqs. (12) and (13), respectively: where: is the distance between the UAV and the target point, d uij is the expected distance between the two UAVs that can exchange information, ut1 ( uti ) and ut2 ( uti ) are both the coordination gains factor of the attractive force, uti is the deviation about the distance between the UAV and the target point and the expected distance, i, j ∈ {1, 2, … , n}.
The gains coefficients of the attractive force adjusted by UAV under certain obstacle environment is no longer applicable under other types of obstacle environment because the gain in the traditional attractive potential field and the improved attractive potential field of the existing reference is still in the form of a fixed coefficient. However, for the improved attractive potential field in this paper, both ut1 ( uti ) and ut2 ( uti ) can automatically adjust their size by uti adjusting the intensity of the attractive force. Adjusting can appropriately increase the attractive force to prevent the UAV from being unable to reach the target point due to too small attractive force when there are obstacles near the target point.

The Repulsive Potential Field of the Obstacle
The coordination gains factor of the repulsive force is introduced into the repulsive potential field function to improve the UAV's adaptability to static and dynamic obstacle environments or improve the efficiency of obstacle avoidance, and this factor is determined by the movement velocity of the obstacle, planning angle and distance deviation. The influence factor of the repulsive force is introduced to prevent the UAV from falling into a local minimum because the resultant force is zero, and this factor is determined by the distance between the UAV and the target point. The planning angle is calculated based on the distance between the UAV and the geometric center of the obstacle, the distance between the UAV and the target point, and the distance between the geometric center of the obstacle and the target point. Then the newly defined repulsive potential field function and the function of the repulsive force are shown in Eqs. (16) and (17), respectively, and the schematic diagram and calculation method of the planning angle are shown in Fig. 2 and Eq. (20), respectively: is the repulsive force, x op is the space position coordinate of the intersection point that the connection between the UAV and the geometric center of the obstacle with the obstacle surface, is the distance between the UAV and the intersection,  , and q ∈ (0, 1) The improved gain of the repulsive force takes into account the movement velocity of dynamic obstacles, planning angle, and distance deviation. The size of ui will has a certain impact on the size of the repulsive force. Figure 2 shows that the UAV moves towards the target direction and keeps approaching the obstacle will increase ui when the UAV is within the influence of the repulsive potential field of obstacles. In other words, under the premise that the UAV is within the influence of the repulsive potential field, the larger the ui is, the closer the UAV is to the obstacle, at this time, the smaller uopi is, the larger the gains factor of the repulsive force is, which increases the repulsive force effect to a certain extent. Therefore, this can enhance the UAV's adaptability to static and dynamic obstacle environments and improve the efficiency of obstacle avoidance. The second factor in the first paragraph of the repulsive potential field function of Eq. (17) contains two items, and the first one will decrease as the distance between the UAV and the target point decreases, and even tends to zero. At this time, the second term increases relatively. This equation mainly plays a role in reducing the repulsive force. This equation can also reduce the repulsive force to a certain extent to prevent the UAV from falling into a local minimum due to the equal and opposite directions of the attractive force and the repulsive force.

The Potential Field Between the UAVs
Extending the design ideas of the attractive potential field function and the repulsive potential field function in the traditional APF to the design method of the potential field function between the UAVs to prevent UAV collision. The communication weight is introduced into the potential field function between the UAVs to make full use of communication between UAVs to quickly restore the originally expected formation after avoiding obstacles. Then the newly defined potential field function between the UAVs and the potential field force between the UAVs are shown in Eqs. (21) and (22), respectively: where: where is the distance between the UAV i and its neighboring UAV j , d uij is the expected distance between the two UAVs that can exchange information. uij ( uij ) and uij ( uij ) are the mutual reference gain factor and mutual exclusion gain factor, respectively, a ij is the communication weight from UAV j to UAV i , N i is the set of all UAVs that interact with the UAV i , if UAV i can receive information from UAV j , then a ij > 0 , otherwise a ij = 0 , and for all i ∈ {1, 2, … , n} , a ii = 0 will be assumed, i, j ∈ {1, 2, ⋯ , n}.
It can be seen from Eq. (22) that there are both the attractive force and the repulsive force between the UAVs, and the potential field function between the UAVs with a ij is more in line with the actual communication network topology. The attractive potential field between the UAVs plays a leading role when the distance between the UAVs is greater than the formation safety distance. At this time, the UAVs are preferentially attracted to UAVs with high communication weights, and the distance between the UAVs is appropriately reduced to avoid leaving the formation. The repulsive potential field between the UAVs plays a leading role when the distance between the UAVs is less than the formation safety distance. At this time, the UAVs preferentially repel each other with UAVs with high communication weights, and the distance between the UAVs

3
is appropriately increased to prevent UAVs from colliding. The force between the UAVs is zero when the distance between the UAVs is equal to the expected distance, and the UAV formation tends to be stable.

Obstacle Avoidance Control Protocol of Cooperative Formation
Although the UAV can prevent self-collision by the IAPF, it can quickly restore its formation after avoiding obstacles safely, and reach the target point smoothly, but the IAPF alone cannot achieve the consensus of position information and velocity information about UAV. In response to this problem, considering that a certain expected distance must be maintained between the UAVs, the formation center reference vector represented by the formation expected distance and expected velocity is introduced in the basic consensus protocol [34] to improve the position variable and the velocity variable, respectively. That is, the deviation between the actual position of the UAV and the reference vector of the preset formation center is taken as the corresponding formation center, and the deviation between the actual velocity and the expected velocity is taken as the new velocity variable. where: The obstacle avoidance control protocol of cooperative formation designed by combining the IAPF and the improved consensus protocol is shown in Eq. (27): Putting Eq. (13), Eq. (17)  where u ci (t) is the improved consensus protocol, x ui (t) is the position information difference between the actual position x ui (t) of the UAV i and its preset formation center reference vector x ′ ui , v ui (t) is the velocity information difference between the actual velocity v ui (t) of the UAV i and its expected velocity v ′ ui , 1 , 2 and 3 are all adjustable protocol parameters greater than 0, a ij is the communication weight of the UAVs, which is used to describe the information interaction process between the UAVs. If information can be transferred between two UAVs, assumed that a ij > 0 , otherwise a ij = 0 , i, j ∈ {1, 2, … , n}. Definition 2 If the formation system can always meet the conditions shown in Eq. (30) under any given initial state conditions, it is said that the UAVs can restore the originally expected formation after avoiding obstacles, and realize the consensus of velocity , relative distance and height between the UAVs.

Stability and Convergence Analysis
The stability, convergence, and control performance of obstacle avoidance and collision avoidance of the formation control system will be analyzed in this section. Among them, the stability and convergence of the system are mainly proved by the characteristics of the solution of the closedloop dynamic equation, the Lyapunov function defined by the total energy of the system, and the LaSalle invariant set principle. For obstacle avoidance and collision avoidance, it is mainly proved by contradiction.
The following assumptions are given to be able to better control the UAV formation flight: 1. The formation system composed of n UAVs performs formation flying under the action of Eq. (27). The UAVs will encounter m obstacles in the external environment during the flight. 2. 2)Each UAV is equipped with onboard communication equipment and the communication between the UAVs is in good condition, without communication delay, data packet loss, etc. 3. There is a spanning tree in the fixed communication network topology, that is, any UAV in the formation system can at least obtain communication information through a neighbor UAV. 4. The total energy function of the formation system constructed by the potential energy function and the kinetic energy function is defined as V(t) , and the total energy function is a finite value, there is V(t) ≤ a.
The following theorem is now given: Theorem 1 Under the action of Eq. (27), the UAV can not only prevent collisions between UAVs, but also safely avoid static and dynamic obstacles, quickly recover the expected formation after avoiding obstacles, and achieve the consensus of relative position and velocity. Proof ] T is the initial velocity state. It is assumed that the vector form of the improved synergy variable and the improved potential field force are shown in Eq. (31) and Eq. (32), respectively: Therefore, Eq. (27) can be rewritten as: where I n is an n-dimensional identity matrix, and 0 n is an n-dimensional zero vector.
Next, Eq. (36) is solved, and the stability and convergence of the system are discussed according to the characteristics of the solution. The solution of this equation corresponding to the homogeneous equation is: Now the Lyapunov function including the potential energy and kinetic energy function of the formation system is established as shown in Eq. (38). Among them, the attractive potential energy can be set to zero because the UAV is always affected by the attractive potential field of the target to move towards the target point.
Taking the derivative of Eq. (38) can get Eq. (39): Knowing that 2 > 0 , from Eq. (39), when t → ∞ , there is , then V(t) ≤ a holds for both ∀t , and L V (a) is the invariant set. According to the principle of the LaSalle invariant set [35], the formation system will eventually converge to the maximum invari- if the initial solution of the system is in L V (a) . If V (t) = 0 , then there is v u (t) = 0 , and v u (t) = v � u is easy to get, then there is v u1 (t) =v u2 (t) = ⋯ =v un (t) = 0 , so there is x u1 (t) =x u2 (t) = ⋯ =x un (t) = 0 . It can be seen that V(t) is positive semidefinite because L is positive semidefinite, and the total energy of the potential field is U u (x � u ) ≥ 0 , that is, U u (x u (t)) ≥ 0 is obtained. Therefore, the system can be stable according to the Lyapunov theorem.
For the convergence and consensus of the system. There is ̇v � u = 0 because the initially expected velocity is a constant value, and the special solution of the corresponding nonhomogeneous equation of Eq. (36) can be solved under this constraint: Therefore, when t → ∞ , and the control protocol parameters are reasonably selected, the solution of Eq. (36) will gradually converge to [x � u , v � u ] T . That is to say, each UAV can restore the originally expected formation after avoiding (39) ∇U uij x ui (t) obstacles to achieve the convergence and consensus of the state. The realization of collision avoidance between UAVs and obstacle avoidance can be proved by contradiction.
For the realization of collision avoidance between UAVs, supposing [x u (0),v u (0)] T ∈ L V (a) is the initial state, when t 1 > 0 , UAV i and UAV j collide, at this time U uij (x ui (t 1 )) → ∞ , then there are: From Eq. (41), it is contradictory to V(t) ≤ a , so the original hypothesis is not true, that is, there will be no collision between UAVs in the system. In the same way, the UAV's ability to avoid obstacles can also be proved by contradiction, which is omitted here to save space.
In summary, under Eq. (27), multiple UAVs can adapt to static and dynamic obstacle environments. They can avoid obstacles safely while preventing collisions between UAVs. The UAV can quickly restore the originally expected formation and achieve the consensus of relative position and velocity after avoiding obstacles. The certification is completed.

Establishment of Simulation Environment and Parameter Initialization
This paper intends to simulate and compare the traditional APF, the IAPF in this paper, the algorithm in [27], and the obstacle avoidance control algorithm of cooperative formation proposed in this paper in a 3D obstacle environment to verify the effectiveness and feasibility of the proposed algorithm. Static obstacles are simulated by 2 cylinders, 3 spheres and 2 hemispheres, respectively, and another sphere is used to simulate dynamic obstacles, and it moves from (120, 25,95) to (25,120,95) at a velocity of v o = 5 m∕s . Four UAVs are pre-formed at the starting point of the expected formation based on a diamond. A fixed undirected connected graph is used to represent the communication network topology of the multi-UAV system as shown in Fig. 3. There is a two-way connection between the UAVs and the expected distance is 40 m, that is, d u12 = d u13 = d u24 = d u34 = d u23 = 40 m , then d u14 = 40 √ 3 m , and the relative height between the UAVs can also be h u12 = h u13 = h u24 = h u34 = 20 3 m . If the two UAVs can exchange information, there is a ij = 2 , otherwise a ij = 0 , and for i ∈ {1, 2, … , n} , a ii = 0 will be assumed, and the adjacency matrix is shown in Eq. (42). The preset formation center vector is set according to the expected distance of formation as shown in Eq. (43). The main parameters of the algorithm proposed in this paper are q = 0.5 , 1 = 0.001 , 2 = 0.5 , 3 = 1 . The coordinates of the geometric center position of each obstacle are shown in Table 1. The starting position and initial velocity of each UAV and target position coordinates are shown in Table 2.

Simulation Results and Analysis
In the 3D obstacle environment model, the traditional APF (Denoted as A 1 ), the IAPF in this paper (Denoted as A 2 ), the control algorithm in [27] (Denoted as A 3 ) and the obstacle avoidance control algorithm for cooperative formation proposed in this paper (Denoted as A 4 ) are simulated from the aspects of formation obstacle avoidance track and state consensus, respectively, and the results are compared and analyzed to further verify the effectiveness and feasibility of A 4 . The formation obstacle avoidance track of the diamond formation under the action of the above four algorithms are shown in Fig. 4a-d, respectively.
It can be seen from Fig. 4a that the four UAVs can pass between the two cylinders, but they stagnate near the first sphere obstacle on the left when the diamond formation is flying under the action of the algorithm A 1 . A complete and feasible trajectory from the starting point to the target point was not planned, and the formation flight mission could not be completed. It can be seen from Fig. 4b that the four UAVs can not only avoid static obstacles but also dynamic obstacles. Finally, all UAVs can reach the target position when the diamond formation is flying under the action of the algorithm A 2 . However, the UAVs moved directly toward the target point and did not quickly recover the expected formation after avoiding obstacles. It can be seen from Fig. 4c that the four UAVs can avoid static obstacles, but the UAV4 directly passes through the dynamic obstacles and cannot avoid it because the dynamic obstacles are not considered in the repulsive potential field function when the diamond formation is flying under the action of the algorithm A 3 . Although all UAVs can eventually reach the target position, the speed of the UAVs returning to the originally expected formation is relatively slow. It can be seen from Fig. 4d that the UAV's adaptability to complex    obstacle environments is enhanced because the potential field gains in the algorithm A 4 are all factors that can be automatically adjusted in real-time. All four UAVs can safely evade static and dynamic obstacles. The UAVs can quickly return to the expected formation and maintain a stable formation after avoiding obstacles. Finally, the UAVs reach the target point smoothly without collisions between UAVs. The corresponding state change curve is not drawn because the UAV cannot plan a complete trajectory under the effect of the traditional APF. The change curve of the relative distance and the relative height between the UAVs under the algorithm A 2 , algorithm A 3 , and algorithm A 4 of the diamond formation with time t is shown in Fig. 5, where time t is the total step time.
It can be seen from Fig. 5 that the four UAVs can maintain the preset diamond formation before obstacle avoidance, and the relative distance and relative height between the UAVs can be consistent with the expected value when the diamond formation is flying under the action of the above three algorithms. The formations are scattered, and the relative position change curve has a certain range of fluctuations in the process of obstacle avoidance. However, the relative distance and relative height of the UAV did not quickly converge to the expected value after avoiding obstacles under the algorithm A 2 , which shows that the consensus of the relative position cannot be achieved by simply improving the APF. The relative distance and relative height of the UAV begin to converge to the expected value at about the 100th second after obstacle avoidance under the algorithm A 3 , which shows that the convergence speed of the relative position between the UAVs is slow when the communication weight is not considered in [27]. The relative distance and relative height of the UAV begin to converge to the expected value at about the 80th second after obstacle avoidance under the algorithm A 4 , which shows that the introduction of communication weights in the potential field function between UAVs can speed up the convergence speed of the relative position. The change curve of the velocity component of the diamond formation under the algorithm A 2 , algorithm A 3 , and algorithm A 4 with time t is shown in Fig. 6.
It can be seen from Fig. 6 that the velocity components on each coordinate axis remain the same before obstacle avoidance when the diamond formation is flying under the action of the above three algorithms. During the obstacle avoidance process, the UAV's velocity component change curve has a certain range of fluctuations. Among them, the velocity curves under algorithms A 2 and A 4 fluctuate when the dynamic obstacle moves near the UAV, and the velocity change under this algorithm is more severe than other algorithms because the algorithm A 4 takes into account the planning angle and distance deviation, which can improve the efficiency of obstacle avoidance. However, the velocity curve under the algorithm A 3 does not show a certain degree of fluctuation, which shows that the algorithm in [27] cannot avoid dynamic obstacles. The velocity components under the algorithm A 2 do not completely converge after each UAV avoids obstacles. The velocity component under the algorithm A 3 starts to converge approximately at the 100th second.
The velocity component under the algorithm A 4 starts to converge at about the 80th second, which shows that the algorithm in this paper converges faster than the algorithm in [27], which fully verifies the feasibility of the algorithm in this paper.

Conclusion and Outlook
The problems of cooperative formation avoidance and consensus control of multi-UAV systems in a 3D obstacle environment are mainly studied in this paper. The main conclusions are as follows: 1. The coordination gains factor of the attractive force is introduced into the segmented attractive potential field function, and the influence factor of the repulsive force is introduced into the repulsive potential field function to prevent the UAV from falling into a local minimum and ensure that the UAV reaches the target point smoothly. 2. The coordination gains factor based on the movement velocity of the dynamic obstacle, planning angle, and distance deviation is introduced into the repulsive potential field function to enhance the UAV's adaptability to complex obstacle environments and improve the efficiency of obstacle avoidance. 3. The communication weight is introduced into the potential field function between the UAVs, and a cooperative formation obstacle avoidance control algorithm based on the IAPF and the improved consensus protocol is designed. The algorithm can achieve multiple control objectives such as collision avoidance, obstacle avoidance, formation recovery, and the consensus of the position and velocity. This paper assumes that the communication between UAVs is good, but there may be communication delays in the actual formation system. Therefore, it is also worth studying the consensus problems of multi-UAV formations with communication delays based on the algorithm of this paper in future work.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:// creat iveco mmons. org/ licen ses/ by/4. 0/.