Next Article in Journal
A Safe and Efficient Navigation Framework for Ground Vehicles on Uneven Terrain Considering Kinematic Constraints and Terrain Traversability
Previous Article in Journal
Deep Learning-Based Contact Force Control for a Robotic Leg
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Formation Control for UAVs Considering Safety Constraints Based on Control Barrier Functions with Switched Trajectories and Switching Communication Topologies

Beijing Key Laboratory of Robot Bionics and Function Research, Beijing University of Civil Engineering and Architecture, Beijing 100044, China
*
Author to whom correspondence should be addressed.
Sensors 2026, 26(5), 1477; https://doi.org/10.3390/s26051477
Submission received: 27 January 2026 / Revised: 20 February 2026 / Accepted: 24 February 2026 / Published: 26 February 2026
(This article belongs to the Section Sensors and Robotics)

Abstract

This paper investigates the formation control problem of multi-UAV systems in the presence of switched trajectories and time-varying communication topologies. A distributed formation control protocol is proposed to enable UAVs to track piecewise continuous trajectories while the underlying communication network switches among a finite set of directed graphs. Sufficient and necessary conditions for achieving accurate formation tracking under dual-switching scenarios are derived through stability analysis while the stability of the overall switched system is proven by using multiple Lyapunov functions. To ensure collision avoidance during both trajectory and topology transitions, control barrier functions (CBFs) are employed to construct safety sets, and a quadratic programming(QP)-based optimization framework is designed to modify control inputs in real time. Simulation results demonstrate that the proposed approach effectively coordinates formation tracking, topology switching, and inter-agent safety, offering a solution for UAV collaboration in dynamic and uncertain environments.

1. Introduction

Unmanned aerial vehicle (UAV) systems have attracted significant attention in both civilian and military domains due to their versatile applications, including reconnaissance [1], target detection, search and positioning [2], and communication relay networks [3].
Existing approaches to formation control primarily encompass the leader–follower method [4], behaviour-based method [5], and virtual structure method [6]. Although the leader–follower strategy is relatively simple to deploy, it is prone to error propagation within its cascaded framework. This leads to the accumulation of tracking inaccuracies, which can ultimately affect the stability of follower UAVs [7]. Behavior-based techniques, while conceptually intuitive, present difficulties in terms of rigorous stability proof and accurate maintenance of the formation geometry [8]. Virtual structure methods are often inflexible and depend on complex mechanisms to synchronize information across multiple UAVs, reducing their applicability in rapidly changing scenarios [9].
In the last few years, distributed coordination in multi-agent systems (MASs) has attracted extensive research attention, particularly in the context of consensus problems. Based on this background, the application of consensus-based strategies to UAV formation control has become a topic of significant interest. Wei Ren, through his work in [10,11], laid important theoretical and practical foundations in this area. He conducted systematic investigations into consensus algorithms for trajectory tracking and formation coordination, and further validated their feasibility through experiments involving wheeled robots. With ongoing developments in consensus theory, formation control schemes built upon such principles have continued to evolve. For instance, reference [12] established sufficient conditions under which second-order clustered MASs can attain desired formation motions over undirected communication graphs. In [13], the problems of trajectory tracking and formation stabilization were studied for discrete-time MASs, leading to a constructive method for designing consensus-based controllers. Furthermore, the authors of ref. [14] addressed trajectory tracking and formation control in first-order integrator-type MASs operating under switching communication topologies, deriving necessary conditions for achieving stable formation configurations.
In the study of formation-related challenges using consensus methodologies, the team headed by Xiwang Dong has made notable contributions in recent years. The study in reference [15] examines time-varying formation design for high-order linear multi-agent systems (MASs) subject to directed switching communication topologies, adopting a consensus-based strategy. Following this, the authors of references [16,17] address formation control issues via output feedback and state feedback, respectively. In the domain of UAV control, references [18,19] developed consensus-based formation control schemes tailored to directed and undirected switching communication networks, respectively. The algorithms proposed in these works have been effectively tested on UAV platforms, confirming both the feasibility and practical applicability of the adopted approaches.
In recent years, reinforcement learning (RL), as a fundamental artificial intelligence technique, has garnered extensive attention from scholars for its applications in the control domain [20]. Currently, numerous researchers have attempted to apply RL algorithms to multi-agent systems (MASs), giving rise to multi-agent reinforcement learning (MARL) [21]. To address complex cooperative tasks characterized by vast policy spaces and convergence difficulties, hybrid approaches that integrate multiple paradigms have emerged as a prevailing trend, with representative works such as [22]. Reinforcement Learning from Human Feedback (RLHF) represents a critical pathway. In [23], prior knowledge or online assessments from human operators are introduced into the training loop as an additional signal, forming a human–machine collaborative closed loop. This method guides agents to learn safe and compliant policies more rapidly. Inspired by biological swarms in nature, research on emergent coordination mechanisms has also attracted increasing attention [24].
However, real-world deployment of such switching protocols must account for safety constraints. As the density of UAVs increases, ensuring inter-agent collision avoidance during these inherently risky transition phases becomes an important concern. Traditional methods may not adequately address these dual objectives of performance and safety in dynamic and uncertain environments. Safety constraints can effectively improve the efficiency of UAV system safety analysis, especially the control barrier functions (CBFs) proposed in recent years [25,26,27].
The Control Barrier Function (CBF) approach incorporates barrier functions to confine the system state within a safe region, establishing a direct relationship between control inputs and safety constraints. This ensures system stability while complying with all safety requirements [28,29]. Moreover, the method can collect environmental data and employ learning strategies to continuously adapt the safe region. CBF offers a versatile solution for addressing safety concerns in UAV systems. With relatively low computational complexity and strong constraint-handling capability, it is suitable for ensuring operational safety under various conditions, including both known and unknown environments, as well as uncertain system states [30]. It can also be integrated with more aggressive planning algorithms to improve mission efficiency [31]. In recent years, CBF has become an important method for safety control in UAV system research, and has been applied to scenarios such as fixed-area coverage [32], mobile coverage [33], communication maintenance [34], payload transport [35], and aircraft carrier landing [36]. The introduction of safety barrier certificates has further improved the scalability of UAV systems in complex multi-constraint environments [37], broadening the applicability of CBF in UAV operations.
However, there still exist challenges in actual deployment using the safety constraint methods:
1. Ensuring that UAVs form the expected formation, tracking the switched trajectories, while avoiding collisions during the switching process.
2. Considering the switching of trajectory and communication topology at the same time.
The main contributions of this paper are summarized as follows:
1. Unlike works that handle only a single type of switching or plan safety offline, this paper designs a distributed protocol capable of simultaneously handling online switching in both communication topology and reference trajectories, integrated with a real-time safety mechanism based on Control Barrier Functions (CBFs), forming a complete closed-loop solution.
2. By employing the multiple Lyapunov functions approach and deriving a dwell time constraint, this paper provides rigorous stability analysis for UAV swarm systems undergoing simultaneous trajectory and topology switching, proving exponential stability under the proposed conditions.
3. In contrast to many works that apply CBFs in static environments or under fixed topologies, this paper addresses the critical challenge of ensuring collision-free operation throughout the mission by the online construction of safety sets and real-time modification of control inputs via Quadratic Programming (QP) during the highly dynamic process where both trajectories and topology are switching.
The subsequent discussion is structured as follows. Preliminary knowledge and a mathematic model of UAVs are given in Section 2. The control protocol is presented in Section 3. The control barrier functions are proposed in Section 4. Section 5 reports the simulation verification results. Section 6 provides conclusions.

2. Problem Formulation

2.1. Preliminary Knowledge

Considering a system with N UAVs, the interaction topology of the system is characterised as a directed graph G κ t = Q , ε κ t , W κ t , consisting of a set of nodes Q = q 1 , q 2 , , q N , a set of edges ε κ t q i , q j : q i , q j Q and a weighted adjacency matrix W κ t = [ w i j κ t ] . The edges of G κ t are denoted by ε i j κ t = q i , q j . The set of neighbors of node consists of N i κ t = q j κ t Q : q j , q i ε i j κ t . The incidence of node is defined as i n d q i κ t = j = 1 N w i j κ t . The incidence degree matrix of G κ t is defined as D κ t = diag i n d q i κ t , i = 1 , 2 , , N . The Laplacian matrix of G κ t is defined as L κ t = D κ t W κ t . κ t : 0 , H is the switching signal, and H = 1 , 2 , , H is a finite set of topological modes. The existence of a spanning tree for a directed graph is contingent upon the presence of at least one node that possesses directed paths to all other nodes.
Lemma 1 
([38]). It is posited that L R N × N donates the Laplacian matrix of a directed graph G; then,
(1) L has one zero eigenvalue at least, and 1 N is an associated eigenvector, i.e., L 1 N = 0 .
(2) In the event that G possesses a spanning tree, it can be deduced that 0 is a simple eigenvalue of L and that all of the remaining N 1 eigenvalues possess positive real parts.
Lemma 2 
([39]). For a system φ ˙ ( t ) = M φ ( t ) where M is a 2 × 2 complex matrix and the characteristic polynomial is f ( z ) = z 2 + a 1 z + a 2 , the system is asymptotically stable if and only if Re ( a 1 ) > 0 and Re ( a 1 ) Re ( a 1 a ¯ 2 ) Im ( a 2 ) 2 > 0 .
Lemma 3 
([40]). Suppose we have candidate Lyapunov functions V θ V · , θ , and vector fields as in x ˙ = f x , θ θ Z + with f ( 0 , θ ) = 0 , for each θ Z + . Also, V : R n × Z + R + is continuous. Let S be the set of all switching sequences associated with the system. If for each θ S , of all θ, V θ is Lyapunov-like for f θ and x θ · , and V θ satisfies the sequence-nonincreasing condition for x θ · , then the system is stable in the Lyapunov sense.

2.2. Formation Problem

In the context of formation control, the UAV can be expressed as a point-mass system. The dynamics of the UAV system can be modelled as follows:
p ˙ i ( t ) = v i ( t ) v ˙ i ( t ) = u i ( t )
where i = 1 , 2 , , N , p i t R n denotes the position vector, v i t R n denotes the velocity vector, and u i t R n denotes the control input of the UAV.
In the following, for simplicity of description, it is assumed that n = 1 , if not otherwise specified. However, it should be pointed out that similar analysis can also be performed for the higher-dimensional case by using Kronecker product, and all the results hereafter remain valid for n > 1 .
The UAV system above can be rewritten as follows:
Γ ˙ i ( t ) = B 1 B 2 T Γ i ( t ) + B 2 u i ( t ) ,
where B 1 = 1 , 0 T , B 2 = 0 , 1 T , Γ i t = p i t , v i t T .
Let F i s ( t ) = [ F i p s ( t ) , F i v s ( t ) ] T ( i = 1 , 2 , , N and s Z + , s = 1 , 2 , , M indicate which variable will switch) be piecewise continuously differentiable vectors, where F i p s ( t ) and F i v s ( t ) represent the reference position and velocity components for each UAV, respectively, and F s ( t ) = ( F 1 s ) T t , ( F 2 s ) T t , , ( F N s ) T t T R 2 N , where
F i s t = F i p 1 t , F i v 1 t T , t t 0 , t 1 , F i p 2 t , F i v 2 t T , t t 1 , t 2 , F i p M t , F i v M t T , t t M 1 , t M ,
and F i s ( t ) is continuous in each time interval. Furthermore F i s ( t ) satisfies F i s ( t s ) = F i s + 1 ( t s ) at the switching instant, where t s is the time for formation switching.
Definition 1. 
It is asserted that a UAV system is said to realize the formation F s ( t ) , provided lim t ( Γ i ( t ) F i s ( t ) ) = 0 ( i = 1 , 2 , , N ) is satisfied.
Based on the description above and considering the challenges identified in the Introduction, this paper aims to address the following problem: designing a control protocol for system (1) to complete switching formation control and ensure the safety of the formations during switching.

3. Control Protocol Design

The formation control protocol is designed as shown below:
u i s , κ ( t ) = K 2 j N i w i j κ t ( Γ j ( t ) F j s ( t ) ) ( Γ i ( t ) F i s ( t ) ) + F ˙ i v s ( t ) + K 1 ( Γ i ( t ) F i s ( t ) ) ,
where i = 1 , 2 , , N , K 1 = [ k 11 , k 12 ] , K 2 = [ k 21 , k 22 ] and k 11 , k 12 , k 21 , k 22 are the constants.
The following discussion first addresses the case where the communication topology is fixed. At this point, formation control protocol is denoted as follows:
u i s ( t ) = K 2 j N i w i j ( Γ j ( t ) F j s ( t ) ) ( Γ i ( t ) F i s ( t ) ) + F ˙ i v s ( t ) + K 1 ( Γ i ( t ) F i s ( t ) ) ,
Let Γ ( t ) = [ Γ 1 T ( t ) , Γ 2 T ( t ) , , Γ N T ( t ) ] T , F p s ( t ) = [ F 1 p s ( t ) , F 2 p s ( t ) , , F N p s ( t ) ] T , F v s ( t ) = [ F 1 v s ( t ) , F 2 v s ( t ) , , F N v s ( t ) ] T . Subsequently, under the condition of employing the formation control protocol (4), the UAV system can be expressed as follows:
Γ ˙ ( t ) = ( I N ( B 2 K 1 + B 1 B 2 T ) L ( B 2 K 2 ) ) Γ ( t ) ( I N ( B 2 K 1 ) L ( B 2 K 2 ) ) F s ( t ) + ( I N B 2 ) F ˙ v s ( t ) .
Let Γ ˜ i ( t ) = Γ i ( t ) F i s ( t ) i = 1 , 2 , N and Γ ˜ ( t ) = [ Γ ˜ 1 T ( t ) , Γ ˜ 2 T ( t ) , , Γ ˜ N T ( t ) ] T ; UAV system (5) can then be expressed in the following equation:
Γ ˜ ˙ ( t ) = I N ( B 1 B 2 T ) F s ( t ) + ( I N B 2 ) F ˙ v s ( t ) F ˙ ( t ) + ( I N ( B 2 K 1 + B 1 B 2 T ) L ( B 2 K 2 ) ) Γ ˜ ( t ) .
Due to the condition of B 1 = 1 , 0 T , B 2 = 0 , 1 T and F ˙ s t = I N I 2 F ˙ s t , UAV system (6) can be rewritten as follows:
Γ ˜ ˙ ( t ) = ( I N ( B 2 K 1 + B 1 B 2 T ) L ( B 2 K 2 ) ) Γ ˜ ( t ) + ( I N B 1 ) ( F v s ( t ) F ˙ p s ( t ) ) .
By defining the tracking error relative to the reference trajectory, the formation tracking problem can be equivalently transformed into a consensus problem of the error system. That is to say, cluster system (5) can achieve formation F s ( t ) if and only if cluster system (7) achieves consensus.
Let λ i i = 1 , 2 , N be the eigenvalue of the Laplacian matrix L of the directed graph G, where λ 1 is the eigenvalue corresponding to the eigenvector u ¯ 1 = 1 N , λ 2 is the eigenvalue corresponding to the eigenvector u ¯ 2 , λ 3 is the eigenvalue corresponding to the eigenvector u ¯ 3 , and so on; 0 < Re ( λ 2 ) Re ( λ N ) . Let U 1 L U = J , where U = [ u ¯ 1 , u ¯ 2 , , u ¯ N ] , U 1 = [ u ˜ 1 , u ˜ 2 , , u ˜ N ] H , J is the approximate standard form of L.
Theorem 1. 
In the case of fixed communication topology and formation command, UAV system (1) is asymptotically stable under control protocol (4) if and only if the following conditions hold:
(a) For any i 1 , 2 , , N , j N i , we have
lim t ( F i v s ( t ) F j v s ( t ) ) ( F ˙ i p s ( t ) F ˙ j p s ( t ) ) = 0 ,
(b) For any i 2 , 3 , , N , we have
Re ( λ i ) k 22 k 12 > 0 ,
Im ( λ i ) 2 k 21 2 + ( Re ( λ i ) k 22 k 12 ) ψ i > 0 ,
  • where 
ψ i = ( Im ( λ i ) 2 + Re ( λ i ) 2 ) k 21 k 22 + k 12 k 11 Re ( λ i ) ( k 11 k 22 + k 12 k 21 ) .
Proof. 
Through Lemma 1, let J = diag 0 , J ¯ ; J ¯ consists of approximate blocks corresponding to λ i i = 2 , 3 , , N . Let U ˜ = [ u ˜ 2 , u ˜ 3 , , u ˜ N ] H , ε ( t ) = ( u ˜ 1 H I 2 ) Γ ˜ ( t ) , σ ( t ) = U ˜ I 2 Γ ˜ ( t ) ; then, system (7) can be transformed into the following:
ε ˙ ( t ) = ( B 2 K 1 + B 1 B 2 T ) ε ( t ) + ( u ˜ 1 H B 1 ) ( F v s ( t ) F ˙ x s ( t ) ) ,
σ ˙ ( t ) = ( I N 1 ( B 2 K 1 + B 1 B 2 T ) J ¯ ( B 2 K 2 ) ) σ ( t ) + ( U ˜ B 1 ) ( F v s ( t ) F ˙ p s ( t ) ) .
It can be inferred from the previous sections that cluster system (5) can realize the formation F s ( t ) in each time interval if and only if lim t Γ ˜ t = 0 . Therefore, according to σ ( t ) = U ˜ I 2 Γ ˜ ( t ) , the following equation can be obtained:
lim t σ ( t ) = 0 .
We first establish that if condition (a) holds, then the following equation holds:
lim t ( U ˜ B 1 ) ( F v s ( t ) F ˙ x s ( t ) ) = 0 .
If condition (a) holds, then so does the following:
lim t ( L B 1 ) ( F v s ( t ) F ˙ p s ( t ) ) = 0 .
Substituting J = U 1 L U into Equation (12) and left-multiplying both sides simultaneously by U 1 I , we have the following:
lim t ( J ¯ U ˜ B 1 ) ( F v s ( t ) F ˙ x s ( t ) ) = 0 .
Since G has a spanning tree, according to Lemma 1 and the structure of J, J ¯ is nonsingular. Left-multiplying J ¯ 1 I 2 on both sides of (13), i.e., condition (a), creates a sufficient condition for (11).
Let U ˜ = U ^ , u ^ , where U ^ C N 1 × N 1 and u ^ C N 1 × 1 , with u ^ being the last column vector of U ˜ . Since rank ( U ^ ) = N 1 , then from (11),
lim t ( U ^ , u ^ B 1 ) ( F v s ( t ) F x s ( t ) ) = 0 .
Since U = [ u ¯ 1 , u ¯ 2 , , u ¯ N ] is an approximately transformed array, it can be demonstrated that the row vectors are mutually perpendicular, and since U ˜ = [ u ˜ 2 , u ˜ 3 , , u ˜ N ] H and u 1 = 1 N , U ˜ 1 N = 0 , U ˜ and 1 N are chunked into the following chunked matrices, respectively:
U ˜ = U ^ , u ^ , 1 N = 1 N 1 1 ,
Multiplying the two equations together, we have U ^ 1 N 1 + u ^ = 0 , i.e.,
u ^ = U ^ 1 N 1 .
Let F ¯ p s ( t ) = [ F 1 p s ( t ) , F 2 p s ( t ) , , F ( N 1 ) p s ( t ) ] T F ¯ v s ( t ) = [ F 1 v s ( t ) , F 2 v s ( t ) , , F ( N 1 ) v s ( t ) ] T , ; then, the following can be obtained from Equations (14) and (15):
lim t ( U ˜ I 2 ) ( ( I N 1 B 1 ) ( F ¯ v s ( t ) F ¯ ˙ p s ( t ) ) ( 1 N 1 B 1 ) ( F N v s ( t ) F ˙ N p s ( t ) ) ) = 0 .
Left-multiplying U ^ 1 I 2 on both sides of (13), we obtain the following:
lim t ( ( F i v s ( t ) F N v s ( t ) ) ( F ˙ i p s ( t ) F ˙ N p s ( t ) ) ) = 0 .
It can be demonstrated from Equation (17) that condition (a) is satisfied. Therefore, condition (a) in Theorem 1 is equivalent to Equation (11).
We can find that condition (a) differs from Equation (17) in form. For a detailed proof of equivalence between the two formulas, please refer to Appendix A.
At this point, Equation (9) becomes the following:
σ ˙ ( t ) = I N 1 ( B 2 K 1 + B 1 B 2 T ) J ¯ ( B 2 K 2 ) σ ( t ) .
Since J ¯ = diag λ 2 , λ 3 , , λ N ,
I N 1 ( B 2 K 1 + B 1 B 2 T ) J ¯ ( B 2 K 2 ) = diag ( M 2 , , M N ) ,
where
M i = ( B 2 K 1 + B 1 B 2 T ) λ i B 2 K 2 ( i = 2 , 3 , , N ) .
Therefore, the stability of system (18) is equivalent to the stability of the following N 1 subsystems:
σ ˙ i ( t ) = ( B 2 ( K 1 λ i K 2 ) + B 1 B 2 T ) σ i ( t ) ( i = 2 , 3 , , N ) ,
where
B 2 ( K 1 λ i K 2 ) + B 1 B 2 T = 0 1 k 11 λ i k 21 k 12 λ i k 22 .
The characteristic polynomial of the subsystem state matrix is given by the following expression: f i ( z ) = z 2 ( k 12 λ i k 22 ) z ( k 11 λ i k 21 ) , where z is a complex variable, i = 2 , 3 , , N . As demonstrated in Lemma 2, system (9) is asymptotically stable under condition (b).
Proof ends. □
Theorem 2. 
In the case of fixed communication topology and switching formation command, if there exist positive definite symmetric matrices P s , Q s such that
A T P s + P s A = Q s ,
where A = I N ( B 2 K 1 + B 1 B 2 T ) L ( B 2 K 2 ) , UAV system (1) can achieve stability in the Lyapunov sense under control protocol (4), that is, the UAV system can achieve formation F s ( t ) .
Proof. 
Take the Lyapunov functions in each time interval as
V s Γ ˜ = Γ ˜ T P s Γ ˜ ,
Then, we have the following:
V ˙ s = Γ ˜ T A T P s + P s A Γ ˜ = Γ ˜ T Q s Γ ˜ λ min Q s Γ ˜ 2 < 0 .
Due to F i s ( t ) satisfying F i s ( t s ) = F i s + 1 ( t s ) at the switching instant and Γ ˜ i ( t ) = Γ i ( t ) F i s ( t ) , the error state is continuous at the switching instant, i.e., Γ ˜ t s | s = Γ ˜ t s | s + 1 .
For each Lyapunov function of each subsystem, if we take P s + 1 < P s , then
V s + 1 ( Γ ˜ ( t s + 1 ) ) V s ( Γ ˜ ( t s ) ) .
According to (23), (24) and Lemma 3, the UAV system is stable in the Lyapunov sense under the condition that the communication topology is fixed.
The proof ends. □
Theorem 3. 
In the case of switched communication topology and switching formation command, if there exist positive definite symmetric matrices P h , Q h such that
A h T P h + P h A h = Q h .
where A h = I N ( B 2 K 1 + B 1 B 2 T ) L h ( B 2 K 2 ) , the dwell time τ D satisfies τ D > ln μ 2 α , where μ = λ max P h + 1 λ min P h and α > 0 . Then, UAV system (1) can achieve exponential stability under control protocol (3), that is, the UAV system can achieve control objectives.
Proof. 
Considering system (7), since A h T P h + P h A h = Q h , take the Lyapunov functions for each topology h as follows:
V h Γ ˜ = Γ ˜ T P h Γ ˜ ,
For each subsystem under a given topology, we have the following:
V ˙ h λ min Q h Γ ˜ 2 λ min Q h λ max P h V h .
Take α h = λ min Q h 2 λ max P h , then
V ˙ h 2 α h V h .
Let the switching moment be t h , then the following inequality holds:
V h + 1 ( Γ ˜ ( t h + 1 ) ) μ V h ( Γ ˜ ( t h ) ) .
Considering the time interval t t h , t h + 1 and κ t = h , the system operates under topology h within this interval; therefore,
V h t e 2 α t t h V h t h .
where α = min h α h .
Remark 1.
The physical meaning of α is the lower bound of the minimum convergence rate of the overall switched system across all possible communication topologies. It directly determines the minimum dwell time required to guarantee exponential stability: τ D > ln μ 2 α . A larger α indicates the stronger intrinsic stability and faster convergence capability of the system, thus allowing for more frequent switching. Conversely, a smaller α requires that switching cannot be too frequent, ensuring the system has sufficient time to converge between switches.
At the switching moment t h ,
V h + 1 t h μ V h t h .
The following can be obtained by successive recursion:
V κ t t μ N κ 0 , t e 2 α t V κ 0 0 ,
where N κ 0 , t represents the number of switches within [ 0 , t ] , and N κ 0 , t t τ D .
Then,
V κ t t e ln μ τ D 2 α t V κ 0 0 .
When τ D > ln μ 2 α is satisfied, the system is exponentially stable.
Proof ends. □

4. Safety Constraints

4.1. Control Barrier Functions

The Control Barrier Function (CBF) is a method employed to ensure that an agent performs collision-free motion. Constraining the time derivatives of the CBF within prescribed limits ensures the forward invariance of the desired set and guarantees the stability of the system.
Consider the following control system in affine form:
x ˙ = f x + g x u .
where x R n and u R m , f and g are Lipschitz-continuous, and assuming that there exists a set C R n , we would like the states of all agents to remain invariant. Therefore, the objective is to design a controller u which can guarantee the forward invariance of C , i.e., to make the state of the system (34) remain within C , from the beginning to the end. Assume that the set denoted by C can be defined as the level set of a particular function h ( x ) :
C = x R n h x 0 .
Definition 2 
([41]). For a continuously differentiable function h : R n R and a given system, system (34), if there exists a local Lipschitz expansion of the class K of functions α and a set C D R n such that for all x D ,
sup u U L f h ( x ) + L g h ( x ) u + α ( h ( x ) ) 0 .
then the function h is defined as a Control Barrier Function, defined on D .
Given a CBF h, the feasible set of control inputs is as follows:
K ( x ) = { u U L f h ( x ) + L g h ( x ) u + α ( h ( x ) ) 0 } .

4.2. Safety Constraints

As previously outlined, the dual integrator system for UAV can be modified as follows:
Γ ˙ i ( t ) = 0 I n × n 0 0 p i ( t ) v i ( t ) + 0 I n × n u i s , κ ( t ) = f Γ i + g Γ i u i s , κ .
Define safety constraints and safety sets, respectively:
h i j Γ i , Γ j = p i p j 2 D s 2 ,
C i , j = Γ i , Γ j h i j Γ i , Γ j = p i p j 2 D s 2 0 ,
where D s is the defined safety distance, while i , j 1 , 2 , , N , and i < j .
To ensure the forward invariance of C i , j , the following must be satisfied:
h ˙ i j + γ h i j 0 ,
where γ is the lower bound of the decay rate.
Remark 2.
In the CBF, the decay rate is usually related to the derivative of the function h x and the function value h x itself. Specifically, if there exists a constant γ which makes h ˙ x + γ h x 0 hold, then it can be considered a lower bound on the decay rate of the CBF. The size of the lower bound on the decay rate γ affects the strength of the CBF’s “rejection” of the system state. When γ is large, the function h will have a weaker repulsion effect on the unsafe region, and the system state may approach the unsafe region more easily. If γ is small, the function h will have a stronger repulsion effect on the unsafe region, and the system state may approach the unsafe region with more difficulty.
Remark 3.
(39) depends only on the local position information of agents while the definition and computation are independent of the global communication topology. Regardless of how communication links switch, as long as two agents are within sensing range of each other, the CBFs remain well-defined and can be computed. This provides an absolute safety boundary for the motion of the agents.
According to (37) and (39), the UAV safety constraints can be constructed as follows:
K safe = Γ i , Γ j | A i j Γ i , Γ j u ^ i b i j Γ i , Γ j } i , j { 1 , 2 , , N } , i < j ,
where
A i j Γ i , Γ j = 2 p i p j , b i j Γ i , Γ j = γ h i j Γ i , Γ j ,
which means that the UAV system is guaranteed to be safe according to Definition 2.
Using QP allows us to achieve the goals of collision avoidance and minimization of changes to the original control inputs:
u i = arg min u J ( u ) = i = 1 N u i s , κ u ^ i 2 , s . t . A i j u ^ i b i j , i j u ^ i u max , i { 1 , 2 , , N } .
where u i is the original control input and u ^ i is the input modified by CBFs.
This QP allows the system to operate with high-performance tracking most of the time, and only introduces safety intervention with minimal performance cost when necessary, thereby achieving an optimal balance between the safety and tracking accuracy during switching processes.

5. Simulation

This section will demonstrate the application of the above method in a simulation environment to prove the validity of the theory proven in Section 3 and Section 4. The communication topology of the UAV system is shown in Figure 1, with a weight of 1 in the communication topology, Figure 2 shows the period of communication topology switching.

5.1. Formation Setting

Since the simulation takes place in 3D space, according to the conditions in Theorem 1 and Remark 1, we take K 1 = 2 , 1.2 I 3 , K 2 = 0.35 , 0.75 I 3 and the lower bound of the attenuation rate γ = 1.2 . Meanwhile, h ( x ) is designed as (39) and D s = 2 m.
The initial positions of each UAV are set to (0, 0, 2), (2, 2, 2), (−2, 2, 2), (4, 4, 2), and (−4, 4, 2), respectively, and the five UAVs are numbered in order as i (i = 1, 2, 3, 4, 5).
In the first stage, i.e., before 20 s, the trajectory of UAV N o . 1 is formulated as follows:
F 1 p s ( t ) = x 1 y 1 z 1 = t , 0 , 2 T , t 5 , s = 1 t , 1 cos ( 0.5 ( t 5 ) ) , 2 T , t 5 , s = 2
where x ( t ) , y ( t ) , z ( t ) are the components of the UAVs’ reference trajectory in the three coordinate axes. The UAV platform adopted in this simulation is a quadcopter aircraft.
In particular, let the formation trajectory 5 s later be designated c ( t ) , which is the formation centre after formation switching.
The trajectories of UAVs named N o . 2 5 are as follows:
F i p s t = x i , y i , z i T = F 1 p s t + Δ x i , Δ y i , 0 T
where i = 2, 3, 4, 5, and the variables Δ x i and Δ y i represent the initial position deviations of the i-th UAV and the first UAV, respectively, in the x and y axis directions.
At 20 s, the formation is switched, and the subsequent trajectories of the five UAVs are illustrated in the subsequent equation:
F i p s t = 4 cos 0.5 t 20 + 2 π i 1 5 4 sin 0.5 t 20 + 2 π i 1 5 2 + c t ,
where i = 1, 2, 3, 4, 5 and s = 3.

5.2. Simulation Results

Figure 3 shows the distances between each pair of UAVs under conditions with and without safety constraints, respectively. It can be seen that when there exist no safety constraints, collision between UAVs may happen. As shown in Figure 3a, the minimum inter-agent distance throughout the entire mission is 2.03 m, which unmistakenly exceeds the safety threshold D s = 2 m.
Figure 4 illustrates the formation trajectory under CBFs.
Figure 5 illustrates the error between the actual trajectory of the UAVs and the expected trajectory. As shown in Figure 5, the tracking error converges rapidly and remains within 0.15 m in a steady state.
Figure 6 illustrates the comparison between the actual trajectory and the reference trajectory of each UAV.
It can be seen that there is a certain degree of error between the actual trajectory and the reference trajectory after the formation switching. This result is due to CBFs adjusting the control input to ensure the safety of the formation.

6. Conclusions

By addressing communication topology switching and formation trajectory switching, the corresponding novel switching formation control protocol and safety control framework are proposed. Through this control protocol, UAVs can maintain a stable formation structure and perform switched trajectories. Additionally, a proof of the sufficient and necessary conditions for the switching formation control protocol is provided to ensure that each subsystem of the UAV system can be asymptotically stable. Moreover, through the method of multiple Lyapunov functions, it is proven that switching systems can allow us to achieve stability under the condition that each subsystem is asymptotically stable. Furthermore, the CBFs enable the monitoring of distances between UAVs, thereby ensuring safety during trajectory switching. The simulation results validate the effectiveness of the proposed method: all inter-agent distances remain above 2 m throughout the mission, guaranteeing collision-free operation. The tracking error converges to within 0.15 m after each switch, demonstrating high-accuracy formation tracking. Meanwhile, successful formation and topology switching corroborates the dwell time condition for switched-system stability. Future work will focus on extending the proposed method to more realistic dynamics and robust communication protocols, and providing experimental validation with physical UAV platforms.

Author Contributions

Conceptualization, Z.W. and X.Z.; methodology, Z.W. and X.Z.; validation, Z.W. and X.Z.; analysis, X.Z. and Y.S.; writing—original draft preparation, Z.W., X.Z. and R.G.; writing—review and editing, Z.W. and X.Z.; project administration, R.G. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the National Natural Science Foundation of China (62371032), the R&D Program of Beijing Municipal Education Commission(KM202310016005, KM202410016009), and the Young Scholar Research Capability Improvement Plan of BUCEA (X21081).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Data are contained within the article.

Acknowledgments

The authors would like to thank the Editors and the Reviewers for their works.

Conflicts of Interest

The authors declare no conflict of interest.

Appendix A

It is first shown that condition (a) leads to Equation (17).
Assume that condition (a) holds:
lim t ( F i v s ( t ) F j v s ( t ) ) ( F ˙ i p s ( t ) F ˙ j p s ( t ) ) = 0 , j N i .
Since G has a spanning tree, there exists a directed path from any node i to the reference node N. Noting that the number corresponding to node i is i 0 and the number corresponding to node N is i m , applying condition (a) to each edge
lim t ( F i 0 v s ( t ) F i 1 v s ( t ) ) ( F ˙ i 0 p s ( t ) F ˙ i 1 p s ( t ) ) = 0 , lim t ( F i m 1 v s ( t ) F N v s ( t ) ) ( F ˙ i m 1 p s ( t ) F ˙ N p s ( t ) ) = 0 .
Adding up all the above equations:
lim t k = 0 m 1 ( F i k v s ( t ) F i k + 1 v s ( t ) ) ( F ˙ i k p s ( t ) F ˙ i k + 1 p s ( t ) ) = 0 .
Simplifying the above equation yields Equation (17).
Equation (17) is described as for any i there are:
lim t ( ( F i v s ( t ) F N v s ( t ) ) ( F ˙ i p s ( t ) F ˙ N p s ( t ) ) ) = 0 .
Then for j N i also satisfies:
lim t ( ( F j v s ( t ) F N v s ( t ) ) ( F ˙ j p s ( t ) F ˙ N p s ( t ) ) ) = 0 .
Subtracting the above two equations gives condition (a). Therefore, condition (a) and formula (17) are equivalent.

References

  1. Liu, C.; Liang, G.; Wang, H.; Li, W. The Application of Ant Algorithm to Path Planning to Reconnaissance UAV. J. Fire Control Command Control 2005, 30, 22–24. [Google Scholar]
  2. Pack, D.J.; DeLima, P.; Toussaint, G.J.; York, G. Cooperative control of UAVs for localization of intermittently emitting mobile targets. IEEE Trans. Syst. Man Cybern. Part B (Cybern.) 2009, 39, 959–970. [Google Scholar] [CrossRef] [PubMed]
  3. Sivakumar, A.; Tan, C.K.Y. UAV swarm coordination using cooperative control for establishing a wireless communications backbone. In Proceedings of the 9th International Conference on Autonomous Agents and Multiagent Systems; ACM: Richland, SC, USA, 2010; Volume 3, pp. 1157–1164. [Google Scholar]
  4. Wang, X.; Yadav, V.; Balakrishnan, S. Cooperative UAV formation flying with obstacle/collision avoidance. IEEE Trans. Control Syst. Technol. 2007, 15, 672–679. [Google Scholar] [CrossRef]
  5. Sharma, R.; Ghose, D. Collision avoidance between UAV clusters using swarm intelligence techniques. Int. J. Syst. Sci. 2009, 40, 521–538. [Google Scholar] [CrossRef]
  6. Li, N.H.; Liu, H.H. Formation UAV flight control using virtual structure and motion synchronization. In Proceedings of the 2008 American Control Conference, Seattle, WA, USA, 1–13 June 2008; IEEE: New York, NY, USA, 2008; pp. 1782–1787. [Google Scholar]
  7. Xue, Z.; Zeng, J. Circle formation control of large-scale intelligent swarm systems in a distributed fashion. In Proceedings of the International Symposium on Neural Networks, Wuhan, China, 26–29 May 2009; Springer: Berlin/Heidelberg, Germany, 2009; pp. 1105–1115. [Google Scholar]
  8. Liu, Y.; Geng, Z. Finite-time formation control for linear multi-agent systems: A motion planning approach. Syst. Control Lett. 2015, 85, 54–60. [Google Scholar] [CrossRef]
  9. Atrianfar, H.; Haeri, M. Flocking of multi-agent dynamic systems with virtual leader having the reduced number of informed agents. Trans. Inst. Meas. Control 2013, 35, 1104–1115. [Google Scholar] [CrossRef]
  10. Ren, W. Consensus strategies for cooperative control of vehicle formations. IET Control Theory Appl. 2007, 1, 505–512. [Google Scholar] [CrossRef]
  11. Ren, W.; Sorensen, N. Distributed coordination architecture for multi-robot formation control. Robot. Auton. Syst. 2008, 56, 324–333. [Google Scholar] [CrossRef]
  12. Xie, G.; Wang, L. Moving formation convergence of a group of mobile robots via decentralised information feedback. Int. J. Syst. Sci. 2009, 40, 1019–1027. [Google Scholar] [CrossRef]
  13. Turpin, M.; Michael, N.; Kumar, V. Decentralized formation control with variable shapes for aerial robots. In Proceedings of the 2012 IEEE International Conference on Robotics and Automation, St. Paul, MN, USA, 14–18 May 2012; IEEE: New York, NY, USA, 2012; pp. 23–30. [Google Scholar]
  14. Nian, X.H.; Su, S.J.; Pan, H. Consensus tracking protocol and formation control of multi-agent systems with switching topology. J. Cent. South Univ. Technol. 2011, 18, 1178–1183. [Google Scholar] [CrossRef]
  15. Dong, X.; Shi, Z.; Lu, G.; Zhong, Y. Time-varying formation control for high-order linear swarm systems with switching interaction topologies. IET Control Theory Appl. 2014, 8, 2162–2170. [Google Scholar] [CrossRef]
  16. Dong, X.; Shi, Z.; Lu, G.; Zhong, Y. Time-varying output formation control for high-order linear time-invariant swarm systems. Inf. Sci. 2015, 298, 36–52. [Google Scholar] [CrossRef]
  17. Dong, X.; Hu, G. Time-varying output formation for linear multiagent systems via dynamic output feedback control. IEEE Trans. Control Netw. Syst. 2015, 4, 236–245. [Google Scholar] [CrossRef]
  18. Dong, X.; Yu, B.; Shi, Z.; Zhong, Y. Time-varying formation control for unmanned aerial vehicles: Theories and applications. IEEE Trans. Control Syst. Technol. 2014, 23, 340–348. [Google Scholar] [CrossRef]
  19. Dong, X.; Zhou, Y.; Ren, Z.; Zhong, Y. Time-varying formation control for unmanned aerial vehicles with switching interaction topologies. Control Eng. Pract. 2016, 46, 26–36. [Google Scholar] [CrossRef]
  20. Zhang, D.; Yuan, Q.; Meng, L.; Xia, R.; Liu, W.; Qin, C. Reinforcement learning for single-agent to multi-agent systems: From basic theory to industrial application progress, a survey. Artif. Intell. Rev. 2025, 59, 46. [Google Scholar] [CrossRef]
  21. Tian, Z.; Chen, R.; Hu, X.; Li, L.; Zhang, R.; Wu, F.; Peng, S.; Guo, J.; Du, Z.; Guo, Q.; et al. Decompose a task into generalizable subtasks in multi-agent reinforcement learning. Adv. Neural Inf. Process. Syst. 2023, 36, 78514–78532. [Google Scholar]
  22. Peng, K.; Qi, H.; Ma, T. Graph based multi-agent reinforcement learning with evolutionary population for cooperation. Neural Netw. 2025, 196, 108437. [Google Scholar] [CrossRef]
  23. Yang, L.; Zhao, J.; Chi, P.; Wang, Y. Human feedback reinforcement learning for multiple agent systems online safe consensus control. Neurocomputing 2026, 671, 132618. [Google Scholar] [CrossRef]
  24. Aina, K.O.; Ha, S. Deep reinforcement learning for multi-agent coordination. Artif. Life Robot. 2025, 1–11. [Google Scholar] [CrossRef]
  25. Xiao, W.; Belta, C.A.; Cassandras, C.G. Sufficient conditions for feasibility of optimal control problems using control barrier functions. Automatica 2022, 135, 109960. [Google Scholar] [CrossRef]
  26. Marvi, Z.; Kiumarsi, B. Robust satisficing cooperative control barrier functions for multirobots systems using information-gap theory. Int. J. Robust Nonlinear Control 2022, 32, 1721–1737. [Google Scholar] [CrossRef]
  27. Capelli, B.; Fouad, H.; Beltrame, G.; Sabattini, L. Decentralized connectivity maintenance with time delays using control barrier functions. In Proceedings of the 2021 IEEE International Conference on Robotics and Automation (ICRA), Xi’an, China, 30 May–5 June 2021; IEEE: New York, NY, USA, 2021; pp. 1586–1592. [Google Scholar]
  28. Zeng, J.; Zhang, B.; Sreenath, K. Safety-critical model predictive control with discrete-time control barrier function. In Proceedings of the 2021 American Control Conference (ACC), New Orleans, LA, USA, 25–28 May 2021; IEEE: New York, NY, USA, 2021; pp. 3882–3889. [Google Scholar]
  29. Marvi, Z.; Kiumarsi, B. Safe reinforcement learning: A control barrier function optimization approach. Int. J. Robust Nonlinear Control 2021, 31, 1923–1940. [Google Scholar] [CrossRef]
  30. Singletary, A.; Klingebiel, K.; Bourne, J.; Browning, A.; Tokumaru, P.; Ames, A. Comparative analysis of control barrier functions and artificial potential fields for obstacle avoidance. In Proceedings of the 2021 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), Prague, Czech Republic, 27 September–1 October 2021; IEEE: New York, NY, USA, 2021; pp. 8129–8136. [Google Scholar]
  31. Wu, G.; Sreenath, K. Safety-critical control of a 3d quadrotor with range-limited sensing. In Proceedings of the Dynamic Systems and Control Conference, Minneapolis, MN, USA, 12–14 October 2016; American Society of Mechanical Engineers: New York, NY, USA, 2016; Volume 50695, p. V001T05A006. [Google Scholar]
  32. Funada, R.; Santos, M.; Gencho, T.; Yamauchi, J.; Fujita, M.; Egerstedt, M. Visual coverage maintenance for quadcopters using nonsmooth barrier functions. In Proceedings of the 2020 IEEE International Conference on Robotics and Automation (ICRA), Paris, France, 31 May–31 August 2020; IEEE: New York, NY, USA, 2020; pp. 3255–3261. [Google Scholar]
  33. Dan, H.; Yamauchi, J.; Hatanaka, T.; Fujita, M. Control barrier function-based persistent coverage with performance guarantee and application to object search scenario. In Proceedings of the 2020 IEEE Conference on Control Technology and Applications (CCTA), Montreal, QC, Canada, 24–26 August 2020; IEEE: New York, NY, USA, 2020; pp. 640–647. [Google Scholar]
  34. Capelli, B.; Sabattini, L. Connectivity maintenance: Global and optimized approach through control barrier functions. In Proceedings of the 2020 IEEE International Conference on Robotics and Automation (ICRA), Paris, France, 31 May–31 August 2020; IEEE: New York, NY, USA, 2020; pp. 5590–5596. [Google Scholar]
  35. Hegde, A.; Aloor, J.J.; Ghose, D. Bounded distance control for Multi-UAV formation safety and preservation in target-tracking applications. Proc. Inst. Mech. Eng. Part G J. Aerosp. Eng. 2023, 237, 1403–1416. [Google Scholar] [CrossRef]
  36. Zhou, H.; Zheng, Z.; Guan, Z.; Ma, Y. Control barrier function based nonlinear controller for automatic carrier landing. In Proceedings of the 2020 16th International Conference on Control, Automation, Robotics and Vision (ICARCV), Shenzhen, China, 13–15 December 2020; IEEE: New York, NY, USA, 2020; pp. 584–589. [Google Scholar]
  37. Hirshberg, T.; Vemprala, S.; Kapoor, A. Safety considerations in deep control policies with safety barrier certificates under uncertainty. In Proceedings of the 2020 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), Las Vegas, NV, USA, 25–29 October 2020; IEEE: New York, NY, USA, 2020; pp. 6245–6251. [Google Scholar]
  38. Ren, W.; Beard, R.W. Consensus seeking in multiagent systems under dynamically changing interaction topologies. IEEE Trans. Autom. Control 2005, 50, 655–661. [Google Scholar] [CrossRef]
  39. Zahreddine, Z. On the stability of a system of differential equations with complex coefficients. Indian J. Pure Appl. Math. 1988, 19, 963. [Google Scholar]
  40. Branicky, M.S. Multiple Lyapunov functions and other analysis tools for switched and hybrid systems. IEEE Trans. Autom. Control 2002, 43, 475–482. [Google Scholar] [CrossRef]
  41. Ames, A.D.; Coogan, S.; Egerstedt, M.; Notomista, G.; Sreenath, K.; Tabuada, P. Control barrier functions: Theory and applications. In Proceedings of the 2019 18th European Control Conference (ECC), Naples, Italy, 25–28 June 2019; IEEE: New York, NY, USA, 2019; pp. 3420–3431. [Google Scholar]
Figure 1. Communication topology G 1 and G 2 .
Figure 1. Communication topology G 1 and G 2 .
Sensors 26 01477 g001
Figure 2. The period of communication topology switching ( τ D = 8 s).
Figure 2. The period of communication topology switching ( τ D = 8 s).
Sensors 26 01477 g002
Figure 3. Safety distance monitoring.
Figure 3. Safety distance monitoring.
Sensors 26 01477 g003aSensors 26 01477 g003b
Figure 4. Formation trajectory.
Figure 4. Formation trajectory.
Sensors 26 01477 g004
Figure 5. Position error.
Figure 5. Position error.
Sensors 26 01477 g005
Figure 6. Comparisons.
Figure 6. Comparisons.
Sensors 26 01477 g006
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Wei, Z.; Zhang, X.; Song, Y.; Guo, R. Formation Control for UAVs Considering Safety Constraints Based on Control Barrier Functions with Switched Trajectories and Switching Communication Topologies. Sensors 2026, 26, 1477. https://doi.org/10.3390/s26051477

AMA Style

Wei Z, Zhang X, Song Y, Guo R. Formation Control for UAVs Considering Safety Constraints Based on Control Barrier Functions with Switched Trajectories and Switching Communication Topologies. Sensors. 2026; 26(5):1477. https://doi.org/10.3390/s26051477

Chicago/Turabian Style

Wei, Zerui, Xiaoyu Zhang, Yang Song, and Rong Guo. 2026. "Formation Control for UAVs Considering Safety Constraints Based on Control Barrier Functions with Switched Trajectories and Switching Communication Topologies" Sensors 26, no. 5: 1477. https://doi.org/10.3390/s26051477

APA Style

Wei, Z., Zhang, X., Song, Y., & Guo, R. (2026). Formation Control for UAVs Considering Safety Constraints Based on Control Barrier Functions with Switched Trajectories and Switching Communication Topologies. Sensors, 26(5), 1477. https://doi.org/10.3390/s26051477

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop