Simulation and analysis of stability of UAV control system based on PID control under different wind forces

The four-rotor UAV has attracted the attention of various fields and has been applied in more areas due to its advantages of low cost, high reliability and simple structure. Nowadays, more complex environment and interference factors put forward higher requirements for the accuracy and stability of the flight control system of UAV. At present, the most widely used four-rotor UAV flight control system is PID control system. This paper constructs a UAV control system based on PID algorithm to analyse and study the dynamic stability control effect of UAV under different wind impact scenarios. MATLAB is used to simulate and analyze the system, and the future development is expected according to the simulation results.


Introduction
Unmanned aerial vehicle is a kind of unmanned aircraft manipulated by radio remote control equipment and self-provided program control device, which is called UAV for short.The UAV first appeared in the first world war and was mainly used in the military field.At the beginning, it was mainly used as a target for training air defense gunners.With the development of electronic technology, UAVs have been frequently used in military missions, including reconnaissance, intelligence collection, tracking and communication.After the Gulf War, western countries fully recognized the strategic value of UAVs and gradually applied high-tech to the field of UAVs which had greatly improved the endurance, image transmission and digital transmission speed, flight stability and other performance of UAV.
Compared with traditional aircraft, the advantages of UAV are low manufacturing cost, low flight loss, strong mobility, strong concealment, etc., especially in performing some tasks with strong repeatability and high-risk factor.In recent years, the four-rotor UAV is a significant research direction in the field of UAV.Compared with other types of aircraft, the four-rotor UAV has smaller size, more flexible flight movement and higher adaptability to the flight environment.These advantages make it outstanding in a variety of civil fields, including aerial photography, agricultural breeding, express transportation, mapping and other aspects [1].But in the meantime, the design difficulty of control system of the four-rotor UAV is far more other aircraft, which hinders the development of the four-rotor UAV.
As far as China is concerned, UAV research is relatively late.However, after the rapid development in recent years, many high-tech UAV enterprises have emerged, which have made great achievements in seismic monitoring, aerial photography, road safety and other aspects.Simultaneously, it has attracted more and more researchers who are interested in UAV research and design, and promoted the development of UAV related technologies.
UAV flight is a highly nonlinear movement which brings serious challenges to its flight control system.Nowadays, the mainstream UAV control algorithms are mostly separated into three types, including linear control algorithm, nonlinear control algorithm and intelligent control algorithm [2].
PID algorithm is a classical linear control algorithm.The algorithm has straightforward structure and strong adaptability, which is widely applied in intelligent equipment.It mainly includes three parts: proportion, integral and differential.If the three parts are set properly, an excellent control performance can be obtained.In addition, linear control algorithm also includes LQR control algorithm, robust control, etc.
Back stepping control is a typical nonlinear control algorithm.Its principle is to layer the complex multi variable control system.Then control and adjust the input parameters at each layer of the system and output them as the input of the next layer.Finally, each layer of control system is connected in series to complete the control system.The error of the algorithm is small, but the control system is too complex.In addition, such control algorithms also include sliding mode variable structure control and model predictive control.
Fuzzy control is a common intelligent control algorithm in UAV, which imitates human's fuzzy reasoning and decision-making process in behavior.At first, the fuzzy control compiles the skills of users or professionals into fuzzy rules, then fuzzes the input quantity to obtain the fuzzy quantity.After that, the fuzzy reasoning is completed for the fuzzy quantity, and the actual control quantity is obtained by making the result of the reasoning clear.This algorithm can improve the dynamic response ability of the control system, but it will lead to poor steady-state accuracy of the system.At the same time, neural network control also belongs to intelligent control algorithm.
In the real flight application of UAV, the control system needs to consider the interference of environmental factors on UAV flight in real time, and the most common problem is wind interference which will change in real time with altitude, weather and other factors.Aiming at these problems, this paper constructs an UAV control system based on PID algorithm to analyses and study the dynamic stability control effect of UAV under different wind impact scenarios.

Dynamic model of four-rotor UAV
The movement principle of the four-rotor UAV is to change the lift generated by the rotor by changing the rotation speed of the four motors around the fuselage, and finally change the flight attitude through different changes in the lift.Compared with single-rotor helicopter, four-rotor UAV can complete complex flight movements such as ascending, descending, forward, backward, left, right, left, right, vertical takeoff and landing, and hovering in the air.This flexibility benefits from its six degrees of freedom, four input forces, and six state outputs.
When establishing the dynamic model of the four-rotor UAV, this paper selects the inertial coordinate system, takes the starting point of the UAV takeoff as the origin, sets the z axis normal to the horizontal plane, and determines the x axis and y axis according to the right-handed rule.When the fourrotor UAV rotates around the x-axis, its deflection angle is the roll angle (ϕ).The angular velocity is p.When rotating around the y-axis, its deflection angle is the pitch angle(θ).The angular velocity is q.When rotating around the z-axis, its deflection angle is yaw angle(φ).The angular velocity is r.Let the forces generated by the four motors be  1 , 2 , 3 , 4 .The length from rotor to fuselage center is l, and the constant torque coefficient is d.The driving force equation is Set the target position of UAV as (, , ), the flight angle as ϕ, θ, ψ,UAV mass as m and the acceleration of gravity as g.The six equations of linear motion are: The six equations of angular motion are : According to the equations of linear motion and angular motion, a simple dynamic model of UAV flight can be constructed [3][4][5].

PID control algorithm
The four-rotor UAV control algorithm used in this paper is the traditional PID algorithm, which is a linear control algorithm, and is the most widely used control algorithm in UAV control and even industrial control.The algorithm has the advantages of mature control method, easy to understand, good control effect, good security and high stability.
PID refers to Proportional, Integral and Differential.PID algorithm is a control algorithm combining proportion, integral and differential.It is essentially a mathematical operation based on the error between the input measured value and the target value and the functional relationship of proportion, integral and differential.Finally, feedback based on the operation results.In the process of UAV control, the ideal PID control equation is In this equation,   represents proportional gain,  represents integral time constant,  represents differential time constant,u() represents output signal of PID controller,e() represents the difference between the target value r() and the measured value.
The proportional control in PID can reflect the deviation signal of control system proportionally.The output value u() of the controller is proportional to the input error e(), and the proportional value is   Correlation.When the value of   decreases, the control effect weakens and the response speed decreases; When the value of   increases, the control effect is enhanced and the response speed is accelerated.However, excessive   will reduce the stability of the control system, so it is necessary to select appropriate   according to the characteristics of the UAV system.
The integral control in PID is mostly used to diminish the static error of UAV system.Integral control is related to the error value e().If the system has errors, integral control can always exist.The integration effect is related to   .When the value of   decreases, the integration speed is accelerated and the integration effect is enhanced.However, excessive value of integration effect can lead the system oscillate.
The differential control of PID reflect the changing tendency of error value, accelerate system response, and prevent the error signal from becoming too large which is mainly used in some PI control systems that will produce large overshoot and oscillation.It is able to heighten the dynamic function of the control system and reduce the time of adjustment.However, excessive value of differential time constant will make the system unstable [6][7][8][9].

Experimental platform
The platform is MATLAB/Simulink simulation platform.MATLAB is a new high-level language popularly applied in the field of engineering calculation and numerical analysis, and has now developed into an excellent engineering application development environment.The software is mostly used in the high-tech programming, visualization, and scientific calculation environments.It combines a variety of potent features into a simple-to-use window environment, including numerical analysis, matrix computation, scientific data visualization, modelling, and simulation of nonlinear dynamic systems.Its advantages come from its full-featured graphic processing capability, visualization of calculation results and programming, friendly user interface, natural language expressions that are close to mathematical ones, and application toolbox with rich functions.It also benefits from its effective numerical calculation and symbolic calculation functions, which aids users deal with complicated mathematical analysis.
The Simulink module is a graphical dynamic system modelling and simulation environment in the MATLAB software, which can provide a graphical user interface to model the system and use the system module to build the model by dragging the mouse.Automobile, aviation, industrial automation, largescale modelling, complicated logic, physical logic, signal processing, etc. are some of its application areas.Simulink offers a graphical editor, a module library that is adaptable, and a solver for modelling and simulating dynamic systems, designing systems, simulating them, automatically creating code, and continuously testing and verifying embedded systems.
The MATLAB algorithm can be integrated into the Simulink model according to the integration of the two programs, and the results of simulation can be imported into MATLAB for additional analysis.This simulation uses the Simulink module of MATLAB, based on the PID structure control chart, and according to the dynamics model of the UAV, builds the UAV model for simulation experiments.

UAV control system configuration
In the experiment, it is necessary to adjust the size of   ,   and   continuously on the basis of the simulation model of the UAV control system, according to the data of the model, mathematical equation calculation and actual simulation image data analysis.Finally, under the condition of meeting the experimental requirements, the parameters with the best comprehensive effect of system control effect and control speed are obtained.
The experimental requirement of this paper is that under PID control, the angle control of UAV can reach stability within 2s, and the overshoot in the control process shall not be higher than 20%.Based on this standard, this experiment uses step signals to send signals to UAV that the three angles of φ, θ, ψ deflect 0.1 target value respectively, then adjust the PID parameters several times.Finally, when the PID parameters are shown in Table1, the PID control meets the requirements and the comprehensive control effect is the best.
Through adjusting the PID control system, this paper has successfully found the relatively stable PID control parameters.However, In the actual flight process of UAV, the flight control system not only needs to ensure the normal flight of UAV, also needs to consider the anti-interference ability to environmental factors during flight.The most common interference factor is wind interference.Therefore, this paper also tests whether the PID control system can react quickly to maintain the stable flight of UAV when encountering wind interference.Based on the adjusted PID control system, this paper uses the step signal to simulate the wind interference encountered by UAV during flight [10].The specific process is to add a disturbance signal with size of 0.02 and duration of 1s as wind interference when T = 0s, T = 1s and T = 2s respectively.

UAV control system configuration
Through the above experimental operation, this paper can get the experimental images of PID control results without wind disturbance, as shown in figure 1.It can be seen from the images that the PID control system performs very well in controlling the angle change of UAV without wind interference.All three angles can complete the response in about 2s, and the overshoot is small.Compare three images, the angle ψ has the shortest response time and the best control effect, and the angle θ has the longest response time and relatively poor control effect.And next, the paper adds wind interference in the PID control system when  = 0 , = 1, = 2.
The images after adding wind interference are shown as follows.According to the analysis of the above three sets of images, when the UAV is disturbed by the wind at T = 0, the time for the three angles to reach stability is delayed but the three curves are relatively smooth and do not fluctuate violently.Of the three curves, θ takes more time to reach stability, but it will produce the smallest error in the end, and the other two angles will produce obvious deviation after reaching stability.
When the UAV is disturbed by the wind at T = 1, the control curves of three angles have certain fluctuations, and finally have certain errors.The angel ψ takes the shortest time to adjust to stability, the angle θ takes the longest time and the smallest error, The error of angel φ is the largest after reaching stability.
When the UAV is disturbed by the wind at T = 2, The control curves of three angles have obvious fluctuations.The angel ψ takes the shortest time to adjust to stability, the angle θ takes the longest time and the smallest error, the error of angel φ is the largest after reaching stability.
Compared with the three images, the UAV shows better control ability when it is disturbed by wind at T = 0 than T = 2s.Combined with images without wind interference, the UAV angle control has reached a stable state when T = 2s.It can be seen that the external interference will have a greater impact on the UAV flight when the UAV flight reaches a stable state.

Conclusion
Nowadays, the four-rotor UAV has been widely used in all fields of our life.However, in the process of using the UAV, people have higher requirements for its flight control ability, endurance ability, intelligent recognition ability and other aspects.This paper mainly discusses the flight control capability of UAV based on PID algorithm.At present, the mainstream UAV control still uses the traditional PID control algorithm, but through the data and conclusions of this paper, this paper can clearly find that although the PID control can still ensure the stability of UAV flight, in the face of interference factors in the environment, such as wind interference, the PID control system will have a certain delay and deviation in response.This is because PID belongs to linear control algorithm, while UAV flight is an outdoor movement, which is affected by many complex factors and belongs to nonlinear movement.This makes it difficult for PID controller to realize real-time adjustment, and the control ability cannot meet people's higher requirements.Nowadays, many UAV researchers try to integrate intelligent algorithms such as fuzzy control or neural network control into PID control to improve the flight control performance of UAV.It can be predicted that four-rotor UAV control system can still have further research and progress in the direction of flight control and anti-interference in the future, so as to ensure that the UAV can face more severe external environment and achieve more sophisticated work.

Figure 1 .
Figure 1.PID control results without wind disturbance.It can be seen from the images that the PID control system performs very well in controlling the angle change of UAV without wind interference.All three angles can complete the response in about 2s, and the overshoot is small.Compare three images, the angle ψ has the shortest response time and the best control effect, and the angle θ has the longest response time and relatively poor control effect.And next, the paper adds wind interference in the PID control system when  = 0 , = 1, = 2.The images after adding wind interference are shown as follows.

Figure 2 .
Figure 2. PID control results with wind disturbance when  = 0,  = 1, and  = 2.According to the analysis of the above three sets of images, when the UAV is disturbed by the wind at T = 0, the time for the three angles to reach stability is delayed but the three curves are relatively smooth and do not fluctuate violently.Of the three curves, θ takes more time to reach stability, but it will produce the smallest error in the end, and the other two angles will produce obvious deviation after reaching stability.When the UAV is disturbed by the wind at T = 1, the control curves of three angles have certain fluctuations, and finally have certain errors.The angel ψ takes the shortest time to adjust to stability, the angle θ takes the longest time and the smallest error, The error of angel φ is the largest after reaching stability.