Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 7, No. 2, 2023 101 PID Control Algorithm Based on Particle Swarm Optimization for Quadrotor UAV with Tip Defect Zhenhao Qin1, a 1Lille College, Hohai University, Nanjing, Jiangsu, 211100, China ae-mail: qzh974771@gmail.com Abstract: For the four-rotor UAV (Unmanned Aerial Vehicle), blade is one of the most important actuator, the four-rotor UAV is prone to blade tip defect during use, which will directly affect the reasoning size of the four-rotor UAV, resulting in the flight quality or performance decline of the four-rotor UAV, ordinary PID control in the case of blade tip defect, it can still be optimized by other algorithms. In this paper, particle swarm optimization will be used to optimize PID parameters in the case of tip defect of quadrotor UAV, and simulation experiments will be conducted in MATLAB Simulink to verify the reliability of particle swarm optimization by comparing and optimizing data curves such as forward and backward roll Angle and yaw Angle. Keywords: Quadrotor UAV PID control, Particle swarm optimization, Tip defect. 1. Introduction In recent years, the rapid development of UAV technology has shown a wide range of application potential in many fields, especially the four-rotor UAV, as an important vertical take- off and landing UAV, has gradually become an ideal platform for various tasks. The four-rotor UAV has the characteristics of good motion performance, small size, light weight, low price, easy manufacturing and environmental friendliness, and is widely used in various fields, such as: aerial photography, detection, urban environmental monitoring [1] and so on. In recent years, it has been a research hotspot in the field of aviation, but the production accuracy of quadrotor UAV is high, and the failure or missing of any component may lead to the performance of quadrotor UAV. At the same time, the problem of flight control of four-rotor UAVs remains one of the key challenges in the field of UAVs. For four-rotor UAVs, blade is one of the most important actuators and an important component that generates thrust for UAVs. However, due to factors such as excessive rotational speed, blade often vibrates during rotation, which will lead to accelerated blade wear and reduced service life. Therefore, blade tip defects or fractures are likely to occur during the use of four-rotor UAVs. This will directly affect the inference size of the quad-rotor UAV, resulting in a decline in flight quality or performance of the quad-rotor UAV, or even out of control [2]. In the four-rotor UAV, the main controls include PID control, fuzzy control, fuzzy PID control [3], PID control has been widely used many years ago [4] In recent years, the research on intelligent PID control has gradually deepened and strengthened. PID controller has low requirements for model accuracy and strong adaptability. PID controller is widely used in quad-rotor UAV because of its good adaptability to some parameters which cannot be accurately measured. Even though PID control is so widely used in quadcopters, it can still be optimized using other algorithms. Particle swarm optimization (PSO) has the advantages of fewer parameters, easy operation and design, and fast convergence. In this paper, the PID algorithm of the four-rotor UAV is optimized by particle swarm optimization under the condition of blade tip defect, and the corresponding data is obtained by using Simulink simulation tool in MATLAB, and then compared with the data after particle swarm optimization. Explore the advantages and disadvantages of particle swarm optimization. 2. Uav Modeling and Pid Control 2.1. Principle and model of four-rotor UAV Four-rotor UAV is a vertical take-off and landing multi- rotor aircraft, which is composed of four symmetrical rotors. Each rotor is driven by a motor to generate thrust, and the flight control can be achieved by adjusting the speed. The structure of the four-rotor UAV: Fuselage: The fuselage of a quadrotor drone is the main body of the entire aircraft and is usually made of lightweight materials such as carbon fiber or aluminum alloy to reduce overall weight and improve flight performance. Rotors: The quadrotor UAV has four symmetrically arranged rotors, each driven by a motor, attached to the four brackets of the fuselage. The rotors are the source of flight power, which enables the drone to hover and fly in the air by generating upward thrust. Motor and electric modulation: Each rotor is equipped with a motor and corresponding electrical modulation (electronic governor). Electric regulation controls the speed of the motor, thus controlling the thrust of the rotor. By adjusting the speed of the motor, the drone can achieve actions such as rising, falling, hovering and steering. Flight control system: The flight control system is the core control part of the four-rotor UAV, which is usually composed of the Flight Controller and related sensors. The flight controller is responsible for receiving sensor data and calculating control instructions, and then adjusting the speed of each motor through electrical regulation to achieve stable control of the UAV and flight tasks. Sensors: Drones are equipped with a variety of sensors to sense the environment and flight status. Common sensors include Gyroscope, Accelerometer, Compass, Barometer, and GPS positioning systems. These sensors provide the data needed by flight controllers to monitor the drone's attitude, altitude, position and speed in real time. 102 Dynamic equation of four-rotor UAV, based on Newton- Euler equations [5] and model proposed in [6]. The six equations for the angular motion: ๐ผ ๐‘ ๐ผ ๐ผ ๐‘ž๐‘Ÿ ๐œ (1) ๐ผ ๐‘ž ๐ผ ๐ผ ๐‘๐‘Ÿ ๐œ (2) ๐ผ ๐‘Ÿ ๐ผ ๐ผ ๐‘๐‘ž ๐œ (3) ฮฆ ๐ฉ ๐ซ ๐ช sin ฯ• tanฮธฮธฮธ๐›‰ (4) ฮธ q cos ฯ• r sin ฯ• (5) ฮจ rcos ๐›Ÿ q / cos ๐›‰ (6) The six equations for the linear motion: x ๐‘‰ (7) y ๐‘‰ (8) z ๐‘‰ (9) ๐‘š๐‘ฃ ๐น cos ฯ• cos ฮจ sin ฮธ sin ฯ• sin ฮจ (10) ๐‘š๐‘ฃ ๐น cos ฯ• sin ฮธ sin ฮจ cos ฮจ sin ฯ• (11) ๐‘š๐‘ฃ ๐‘š๐‘” ๐น cos ฯ• cos ฮธ (12) In the above formula, p stands for roll rate, q stands for pitch rate, r stands for yaw rate, ฯ„p stands for rolling moment, ฯ„q stands for pitching moment, ฯ„r stands for yawing moment, stands for Roll angle, stands for Pitch angle, stands for Yaw angle. 2.2. Establishment of tip defect model of four- rotor UAV According to the paper [8], ฯf is defined as the ratio between the thrust generated by the propeller after the propeller tip defect fault and the original thrust: ฯ ฮธ k /3 ฮธ k /4 ฮปk /2 / ฮธ /3 ฮธ /4 ฮป/2 (13)[8] Where ฮธ0 represents the zero incidence Angle of the blade, ฮธtw represents the torsional incidence Angle, ฮป represents the ratio of the incoming flow velocity to the tip velocity, and k represents the ratio between the blade radius after the defect and the initial blade radius. In this paper, the blade parameters of the four-rotor UAV in paper [6] will be taken as an example. The parameters are specifically set as ฮธ0= 0.67rad, ฮธtw= 0.29rad, ฮป=0.05, and the k value is assigned as 0.7 The mathematical form of this fault can be expressed as: T ฯ T (14) Where Tn is the lift force generated by a propeller under normal conditions 2.3. PID control PID controller is the most used in UAV control. PID control algorithm is a common feedback control algorithm, which is used to realize the stability control of the system. PID stands for proportional (P), integral (I), and differential (D) control terms, which are combined to compute the control signal and adjust the output of the control system so that it is as close as possible to the expected value. Proportional (P) item: The proportional control acts on the current error (deviation), and its output is proportional to the size of the error. When the error is large, the output of the proportional term will also increase, thus speeding up the system response. Integral (I) item: Integral control is used to eliminate steady-state errors in the system. It controls the cumulative error, that is, the cumulative value of the error over time is integrated. The integral term can eliminate the steady-state error caused by the proportional term and the differential term. Differential (D) term: Differential control is used to suppress overharmonic oscillations of the system. It predicts the development trend of future error by detecting the rate of change of error, and adjusts the control signal to slow down the system response speed. 2.4. PID control of UAV Position varies with speed, Angle varies with speed. Therefore, we divide the variables into: Inner ring: Speed and posture rate. Outer ring:Position, posture, Angle. Velocity varies with attitude Angle, so the ring of attitude Angle is also the inner ring of velocity. Rate control: Controls p,q,r The figure 1 below considers the control for example. treat the plant as a black-box. Figure 1. Rate Control Attitude controls. Treat the rate control loop as the inner loop as shown in Figure 2. Figure 2. The rate control loop 103 Treat the rate control loop and the plant as the black box as shown in Figure 3. Figure 3. The rate control loop and the plant And then do the same for the Position Control Repeat the same procedure for velocity and position control loops as shown in Figure 4. Figure 4. Velocity and position control loops 3. Particle Swarm Optimization 3.1. Introduction The study of bird foraging behavior led to the invention of particle swarm optimization (PSO), because birds can find the best destination through the sharing of collective information. The PSO algorithm has six important parameters, which are the position of the i th particle, the speed of the i th particle, the optimal position searched by the i th particle, the optimal position searched by the group, the adaptation value of the optimal position searched by the i th particle and the adaptation value of the optimal position searched by the group In particle swarm optimization, each candidate solution is called a "particle" that represents a point in D-dimensional space if D is the number of parameters to optimize. We can use the following vector to represent the position of the I-th particle, and the population is formed: ๐‘ฅ ๐‘ฅ ๐‘ฅ ๐‘ฅ . . . ๐‘ฅ (15) X x , x , . . . , x (16) In the process of finding an optimal solution to the problem, the particle will redefine its trajectory in parameter space (i.e. update its position iteratively) according to the following equation of motion[7]: ๐‘ฅ ๐‘ก 1 ๐‘ฅ ๐‘ก ๐‘ฃ ๐‘ก 1 (16) the velocity of the ith particle is defined as[7]: vi(t+1)=vi(t)+c1(pi-xi(t))R1+c2(g-xi(t))R2 (17) Where pi refers to the best fit value of the particle, that is, the coordinates at which the particle has obtained the best solution so far, G is expressed as the overall optimal solution, c1 and c2 are learning factors, usually between 0 and 4, and R1 and R2 are random numbers distributed in the range of 0 to 1. The flow of particle swarm optimization is as follows: (1) Initialize particle swarm parameters,(2) randomly initialize the position and velocity of each particle,(3) update the velocity and position of each particle according to the conditions met, and calculate the current fitness of each particle,(4) update the individual historical optimal fitness value and position of each particle,(5) for each particle, Compare its adaptation value with the historical best adaptation value (6) If a good enough solution is reached or the number of iterations reaches the maximum, end; otherwise, go to step (3).[4] 3.2. The optimized simulation results The particle swarm optimization of PID control of a quadrotor UAV with tip defect is carried out under simulink simulation in MATLAB. The following 5 data comparison graphs are obtained The particle swarm optimization functions are respectively: delta_max_T = max(T)/11.5*100; delta_max_tau_p = 0; %max(tau_p)*200; (18) delta_max_tau_q = 0; %max(abs(tau_q))*100; (19) delta_max_tau_r = abs(min(tau_r))*20000; (20) obj_ij = 1/(delta_max_T+delta_max_tau_p+delta_max_tau_q+delta_ max_tau_r)*1000; (21) 104 tau_p stands for this rolling moment,tau_q stands for this pitching moment,tau_r stands for this yawing moment. The experimental data is shown in Figure 5-9 Figure 5. The convergence process The curve becomes regionally stable at about 40 iterations, which is 4.09 Figure 6. Experimental data of tau_p Figure 7. Experimental data of T Figure 8. Experimental data of tau_q Figure 9. Experimental data of tau_r The overshoot time of the four diagrams did not change much, and the overshoot decreased slightly by about 6%The results show that PSO has a slight optimization effect on PID control of the four-rotor UAV with tip defect. 4. Conclusion In this paper, PSO is used to optimize PID control in the case of blade tip defect of the four-rotor UAV, and various parameters of PID are optimized to different degrees, and certain results are obtained after optimization., but there are still some shortcomings in this paper.The main reason is that the number of iterations of particle swarm optimization algorithm is small, and the optimization of some modules may have a weakening effect on other modules. References [1] Liu X, Zhang W, Li G, et al. (2006). Technical problems of autonomous formation flight control of unmanned aerial vehicles. Electrooptics and Control, 06:28-31. [2] Wang J, Yang H, Wang D, et al. (2022). Modeling of tip defect of four-rotor UAV. International Journal of Aerospace Science, 10(2): 7. [3] Xu P, Wu Y, Zuo J, et al. (2018) Longitudinal attitude control of UAV based on fuzzy PID. 2018 IEEE CSAA Guidance, Navigation and Control Conference (CGNCC). Xiamen. [4] Wang H. (2020) Application of PID control in industrial production. Journal of Biotron Electronics, 12:82. 105 [5] Zadeh. (1977) Theory of Fuzzy Sets, Encyclopedia of Computer Science and Technology. Marcel Dekker, Nueva York, L.A. [6] A. Ramรญrez-Mendoza, J. L. Pรฉrez-Silva, F. LaraRosano. (2011) Electronic implementation of a fuzzy neuron model with a Gupta integrator. JART-Journal of Applied Research and Technology, 9(3):380-393. [7] Marini F, and Walczak B. (2015) Particle swarm optimization (PSO). A tutorial - ScienceDirect. Chemometrics and Intelligent Laboratory Systems, 149:153-165. [8] Wang Y , Yu H. (2019). Quadrotor PID control system based on particle swarm optimization. Micro Electric Machine, 06:80-82. [9] Mendoza A, Wen Y. (2023) Fuzzy Adaptive Control Law for Trajectory Tracking Based on a Fuzzy Adaptive Neural PID Controller of a Multi-rotor Unmanned Aerial Vehicle. International Journal of Control, Automation, and Systems, 21:51-59. [10] Eswaran P, Guda M, Priya M, et al. (2015) Stabilization of UAV Quadcopter. Proceedings of the International Conference on Soft Computing Systems, 1(397):827-837.