Optimization Design and Exploration on Flight Control Based on Four-rotor Unmanned Aerial Vehicle

UAV flight control is a hot and difficult point in today's world. Although the development of quadrotor UAVs has nearl-y ten years of development, its dynamics modeling and mechanical design have become mature, but there are still many problems to be solved in the design of machine control and its optimization algorithm. For example, the optimization of adaptive control and balance control of UAV in different environments is still a problem that many research institutes and commercial companies focus on. Under different environmental conditions, how to reasonably maintain the stability of the UAV's own balance under the circumstances of heavy wind or rain, and the same balance corresponding time and corresponding state under the loads of different weights and shapes of UAV loads. The project attempts to introduce PID control algorithm to solve this problem, with the use of matlab simulation test, compared with the existing commercial UAV.The project team mathematically modeled the quadrotor UAV to get the aerodynamic model of the quadrotor UAV, PID controller building, simulink simulation model of the construction, and the function of the Particle Swarm Optimization algorithm optimization parameters.The main purpose of the project is to explore the unmanned aircraft flight control adaptability to different environments. It is difficult to achieve a unified problem and try to solve this problem. The development of today's drones and the further integration of control and mechanics by our mechanical major have far-reaching implications. At the same time, it also provides a new perspective and thinking direction for the combination of current control theory and computer science.


Introduction
Unmanned aerial vehicles (UAVs) have become the most popular and pioneering topic today and even throughout the 21 st century, as they are widely applied in such sectors as public security, city management, agriculture, geology, meteorology, electricity, emergency rescue & disaster relief, and video recording. However, UAVs cannot execute tasks efficiently due to the complicated environment in which they are applied. By combining theory with practice, this project aims to systematically study the PID flight control of quadrotor UAVs, and perform the simulation on matlab platform. On this basis, particle swarm optimization (PSO) algorithm is further utilized to select the optimal PID parameters, and input them into quadrotor UAVs for simulation of specific control, so as to considerably improve their reliability.

Overseas Research Status
The studies conducted by overseas universities, research institutions and companies on quadrotor UAVs focus on their control, positioning and expanded applications.
OS4 quadrotor UAV by Swiss Federal Institute of Technology: OS4 is a powered miniature quadrotor flight vehicle developed by EPFL automation system laboratory, which dedicates itself to the research and development of flight control algorithm and intends to realize the completely independent flight of quadrotor flight vehicle indoor and outdoor. At present, the Institute has developed a control algorithm called Integral Backstepping, which combines the advantages of PID algorithm and Backstepping algorithm, and successfully achieved the hovering, takeoff and landing of OS4 UAVs.
Quadrotor UAV by the University of Pennsylvania, U.S.: The miniature quadrotor flight vehicle researched and developed by the University of Pennsylvania, U.S. has a weight of less than 0.1 pound, and it is driven by a power supply of around 15kW only. The flight vehicle can roll and rotate by 360° within 0.5s, and quickly restore its balance [1] . STARMAC quadrotor UAV by the Stanford University, U.S.: The project focuses on the study of miniature multi-rotor flight vehicles as well as the minimum cost distributed cooperative search and control technology [2] .
Commercial quadrotor UAV: Amazon, Google and some other companies are actively making extensive investments in the research and development of delivery service with UAVs. At present, Google is developing the UAV delivery system Project Wing [3] , not much different from the UAV delivery system announced by Amazon. In the project, UAVs are employed to deliver goods to customers. However, the main purpose of Project Wing is to deliver supplies to the affected areas during disaster.

Domestic Research Status
DJI "Wu" quadrotor UAV is equipped with one HD camera of 12.76M pixels to provide visual navigation and achieve stable hovering without GPS outdoor.
COMB Studio of Beihang University, a national key laboratory for flight control integration, mainly studies the application of miniature quadrotor flight vehicles in some indoor operations, which can accurately locate the target objects through visual module, laser and other sensors.
A great number of fruitful studies on quadrotor UAVs have been carried out around the world. Meanwhile, studies have started focusing on intelligent flight and commercial application of quadrotor UAVs. However, there are fewer studies on quadrotor UAVs in China, while most of them are still at the early stage. As revealed in the overview of studies in China, most researchers pay attention to modeling and control algorithm simulation, and only a few have performed practical flight tests. A few scientific research institutes have manufactured prototypes, but they cannot achieve the satisfying performance of flight due to the lack of core technology and experience in the quadrotor UAV control [4] . Especially, there are very few studies on the optimization of adaptive control and balance control for quadrotor UAVs under different conditions, so the UAVs made in China may encounter some unpredictable situations that are difficult to avoid during flights, especially unmanned autonomous flight [5]. For instance, the UAVs may be unable to address collision with flying birds or insects, or encounter with heavy wind or snowstorm, and may crash due to the loss of balance.

Dynamics Modelling of Quadrotor UAVs [6]
To construct the mathematic model of quadrotor UAVs, two coordinate systems must be created first, i.e. inertial system (OXYZ) and non-inertial system (oxyz), and the following assumptions are given as well: 1) The origin of inertial system coincides with the geometrical center of quadrotor UAV; 2) The resistance to quadrotor UAV in the air is unrelated to its weight and flight altitude; 3) The model of quadrotor UAV is a uniform and symmetric rigid body; 4) The lifting force provided by four rotors of quadrotor UAV is directly proportional to the speed of motor; 5) The wind speed complies with the law of classical physics. The angles are defined as follows: Yaw ψ : The angle formed by X axis and the projection of Ox on the OXY plane; Pitch θ : The angle formed by Z axis and the projection of Oz on the OXY plane; Roll φ : The angle formed by Y axis and the projection on the OYZ plane;

Fig. 1 Schematic diagram of model
The matrix for converting the coordinates of quadrotor UAV into inertial system is as follows: cos cos cos sin sin cos sin cos sin sin sin cos sin sin sin sin sin cos sin cos sin cos sin cos cos After that, it is defined that Fx, Fy and Fz are the components of external force on three coordinate axes; v is the velocity of UAV; M is the total moment of force applied onto UAV; m is Meanwhile, it is defined that p is the component of angular velocity ω on Ox, while q and r are its components on the other two coordinate axes respectively.
Similarly, the quantitative relationship between p and q can be obtained.
, , x y z M M M are the components of M on three coordinate axes, and i I is the moment of inertia around each axis. Then the four independent control inputs U1, U2, U3, and U4 of quadrotor UAV are defined as follows: vertical control U1, rolling control U2, pitching control U3 and yawing control U4. ki is the proportional coefficient of lifting force and square of rotor speed.
After that, it is defined as follows: After calculation and sorting out, the mathematic model is eventually obtained as follows: In which, [ , , z] x y is the coordinates of the position at which the UAV's center of mass locates in the inertial system; [ , , ] ψ φ θ is three angles of UAV's attitude, i.e. yaw, roll and pitch; l is the distance from the end of each UAV rotor to the UAV's center of mass, i.e. the length of UAV radius; i I is the calculated moment of inertia around each axis; i K is the coefficient of wind resistance; and m is the absolute mass of quadrotor UAV with load.
It is known that quadrotor UAV is an under-actuated system, which means that the number of system inputs is lower than the number of system outputs. As quadrotor UAV is a model with 6 degrees of freedom, it is impossible to track every degree of freedom. For this reason, an attempt is made to simplify the control by tracking the flight trajectory [ , , z] x y and the roll φ , while guaranteeing no change to such two angles.
To ensure the generality of the model, the control target is also set as follows: In the PID control, system stability is mostly affected by PID parameters. Hence, Hurwitz criterion is employed to select and optimize the parameters. In other words, the conditions for the stability of two-order system 2 2 1 0 0 a s a s a + + = are as follows:

Design of Inner and Outer Closed-loop PID System for Quadrotor UAVs
PID, short for proportional, integral and derivative, constitutes a control over an object through the linear combination of proportional, integral and derivative terms in error. The controller of this kind is called PID controller. Fig. 2 presents a simple framework of PID controller.

Fig. 2 Schematic diagram of PID
As PID system features good robustness, easily mastered algorithm and high resistance to interference, PID control algorithm is employed in the design of control for quadrotor UAVs.
According to the principles and features of PID control, the closed-loop system structure for quadrotor UAVs is obtained as presented in the following figure 3.
The above closed-loop system is a control system composed of inner loop and outer loop, so the control rate should be designed by employing the method for control over double loops, i.

Design of Outer Loop Position Controller
The goal is to realize: According to the above known mathematic equations of quadrotor UAVs, it is therefore defined as follows: Hence, the position model for quadrotor UAVs can be simplified as follows [7] : The parameters of system at the position x is first designed. For convenience of calculation, PD control is employed only. According to the principles of PID control, the control law of the system is as follows: After it is substituted into the position model, it is obtained that: According to the Hurwitz criterion for two-order system, it is known that the conditions for the stability of two-order system 2 2 1 0 0 a s a s a + + = are as follows: To satisfy 0 The above is the initial PD parameters obtained when the system is at the position x. Similarly, the PD control law can be designed for the position subsystem at the position y as follows: According to the Hurwitz criterion for two-order system, we can also take 5.0, 5.0 py dx k k = = As for the subsystem at the position z, the PD control law based on feedforward and gravity compensation is designed due to the existence of gravity as follows: According to the Hurwitz criterion, the initial values are 5.0, 5.0 pz dz k k = = .

Inverse Solution of Two Intermediate Angles
According to the designed structure of inner and outer loops, the required attitude angles for intermediate transmission are d θ and d ψ . To realize the tracking of d θ through θ , and tracking of d ψ through ψ , it is necessary to solve d θ and d ψ .
In the inner loop position controller, it is already defined as follows: Through matrix conversion and inverse matrix multiplication, the above formula can be changed to: After simplification, it is obtained that: In this case, there will not be inverse solution. This is a shortcoming of this algorithm.
To overcome the shortcoming of this algorithm, the above equation can be rewritten into: -1 +1 ， , the value is zero. If exceeding the range, the value is a real number that supports the above equation. This alteration has satisfactorily avoided the shortcoming of this algorithm. Moreover, the time-varying real number causes any disturbance of the input, which may be overcome through the robustness of controller.
After obtaining d θ and d ψ through inverse solution, we can obtain the control law of position as follows:

Design of Attitude Controller for Quadrotor UAVs
The position controller of quadrotor UAVs is designed as follows: Similar to the design of position controller, the goal is to realize , ,