# Affine Formation Maneuver Control for Multi-Agent Based on Optimal Flight System
## 3 Agent Motion by Forces
### Local Trajectory Planning  
In order to avoid the system oscillations resulted from the sudden change of velocity, the receding horizon strategy is utilized to reduce the settling time in formation control of UAVs swarm navigation in the presence of obstacles. Therefore, the Runge-Kutta of order 4 (RK4) method is introduced in the paper for kinematic discretization description to update the agents' state. The purpose of employing this method is to facilitate the adaptability of local trajectories, meaning that new trajectories are smoothed and discretized within the time step prior to the agents reaching new target points. As a result, the agents ultimately converge towards an equilibrium point, where the total sum of virtual forces becomes zero, effectively preventing any potential collisions. The description of local control law is as follows:  
\[\mathbf{u}_{local}^{i}=\underbrace{-\sum_{j=1,j\
eq i}^{N}\
abla_{i}[\lambda_{ij} U_{ij}(||\widetilde{\mathbf{p}}_{ij}||)+\lambda_{io}U_{io}(||\widetilde{\mathbf{p}}_{io}||)+ \lambda_{iv}U_{ip}(||\widetilde{\mathbf{p}}_{iv}||)]}_{f_{i}^{p}}+\underbrace{C_{1 }\sum_{j=1,j\
eq i}^{N}(\mathbf{v}_{i}-\mathbf{v}_{j})+(\mathbf{v}_{i}-\mathbf{v}_{vl})}_{f_{i }^{p}} \tag{15}\]  
where \(C_{1}\) is the constant value, \(\lambda_{ij}\), \(\lambda_{io}\), and \(\lambda_{iv}\) are different spring constants. \(\mathbf{f}_{i}^{p}\) is the gradient-based term, which regulates position consensus by employing local repulsive and attractive forces, ensuring collision avoidance and cohesion maintenance, and \(\mathbf{f}_{i}^{p}\) means the agent's velocity is adjusted by utilizing the weighted average velocity of its neighbors as a reference. Denote \(X\{\mathbf{p}_{i},\mathbf{v}_{i}\}\) as the state of the agent, and the state is updated within a time step. Thus, the process of updating is described as follows:  
\[X_{n+1}=X_{n}+h_{n+1}{\sum_{i=1}^{s}a_{i}k_{i}},i=1,2,\ldots,s \tag{16}\]  
\[k_{i}=f(t_{s},x_{n}^{j},x_{n+1}^{j}),j=1,2,\ldots,s \tag{17}\]  
Figure 4: Illustration for virtual forces between agents and virtual leader: (**a**) Formation fight by desired path; (**b**) agent local planning; (**c**) flight in corresponding configuration. The green line represents the gradient descent direction of APF. The leader is red, virtual leader red-dotted, followers blue. (Both arrows show the direction). where the \(k_{i}\) is a slope of four points in the time step interval, calculated at both ends and two midpoints of the interval. Hence, input \(\mathbf{u}_{i}^{i}\) is initially derived through the application of the local control law. Subsequently, the acquired position and velocity are discretized to facilitate the update of the local trajectory as Figure 5 shows. As depicted in Figure 5, the agent interacts with other agents, obstacles (with d-react), and the virtual leader, which generates the three kinds of artificial potential forces \(U_{i}\) to obtain the fast gradient descent direction \(\
abla(U_{i})\) to equilibrium state \(X_{i}\). Then, the state of the formation would be constantly updated \(X_{n+1}^{i}\) in a receding horizon to avoid the collision. The following Algorithm 1 summarizes the local control.