Modelling and PSO Fine-tuned PID Control of Quadrotor UAV

This paper describes nonlinear dynamics model of x-configuration quadrotor using Newton-Euler modelling technique. To stabilize quadrotor attitude (roll (φ), pitch (θ), yaw (ψ)) during hovering, a PID controller is proposed. There is individual PID controller for each roll, pitch, yaw and z where 12 parameters consist of kp, ki, and kd are fine-tuned using particle swarm optimization algorithms. From the simulation, the sum absolute error fitness function give the best optimize result where quadrotor achieve zero steady state error for hovering with 18.9% overshoot, and 4.42s settling time. Accordingly, for attitude stabilization, roll angle, pitch angle, and yaw angle converge to the set point, zero approximately with settling time 2.76s, 0.1s and 3.2s respectively. Keywords— UAV; PID; PSO: quadrotor; Newton-Euler.

With simplest electronics and mechanical structures design, quadrotor UAV is an aerial vehicle that has capabilities in vertical take-off and landing (VTOL), omnidirectional flying, and easy hovering performances in limited spaces always being considered in research.
The quadrotor is an under-actuated and dynamically unstable system which possess with complex behaviours. Many presented work in literatures use '+' configuration and simplified model, where non-linear effect is neglected. Several literatures have mentioned of proportional-integralderivative (PID) control a quadrotor [8] [9][10] but using linearize model.
The main issues addressed in this paper is a fine-tuned PID controller for highly nonlinear quadrotor, xconfiguration model focus on attitude stabilization during altitude control. Since there are 12 parameters to be tuned, a particle swarm optimization is chosen to amend control parameters; kp, ki, and kd to the best optimal values for the preferred control response.

A. Quadrotor Model
Quadrotor is a type of helicopter that can be controlled by varying the rotor speeds. It is an under-actuated, dynamic vehicle with four input forces and six output coordinates. Quadrotor, composed of four rotors with symmetrically arrangement where two diagonal motors (1 and 2) are running in the same direction whereas the others (3 and 4) in the other direction to eliminate the anti-torque [7][11] [12]. As shown in Fig. 1, there are two basic types of quadrotor configurations; a plus configuration and a cross configuration [13][14] [15].
Quadrotor is a helicopter category composed of four rotors with symmetrically structure in either 'x' mode configuration or '+' mode configuration. To eliminate antitorque force during maneuver, two diagonal motors (1 and 2) are set to run in the same direction (anti-clockwise) while (3 and 4) in the other direction (clockwise). This paper present 'x' mode configuration quadrotor as illustrated in Fig. 1, where the coordinate systems of two reference frames describe the dynamics of a quadrotor; an earth fixed initial reference frame, {E} and a body fixed reference frame {Q} located at the center of gravity (COG) of quadrotor body frame which is a rigid body in free motion with six degree of freedom (DOF) consist of three translational and three rotational. For the modelling, the following assumption is defined for simplification [16]: 1. The quadcopter is assumed as a rigid body.
2. The quadcopter's structure is assumed as symmetric with respect to the XY-axis. 3. The centre of mass and the origin of the body fixed frame are coinciding. 4. The propellers are considered as rigid; no blade flapping occurs. 5. The four propellers work under the same conditions at any time, meaning that thrust coefficient, and reaction torque coefficient, are the same for all propellers. 6. The generalized coordinates for the quadrotor based on Fig. 1 can be described as follow where, vector , Eq. (1) denotes the position of the quadrotor relative to inertial frame, vector , Eq. (2) denotes the attitude of the quadrotor. The relation of body fixed reference frame, {Q} respect to earth fixed initial reference frame, {E} satisfy as . Eq. (3) defines the rotation matrix , where, S and C stands for trigonometric operators 'sin' and 'cos' respectively.
From general Newton-Euler translational and rotational dynamics, the quadrotor dynamics, is described as Eq. (4) and Eq. (5), where, is gravitational coefficient, vector matrix of z-axis defined as , is total thrust force generated by four rotors. is the moments of inertia for the quadrotor, a diagonal matrix 3-by-3 and defined as . is rotor inertia, is total rotor speeds generated from the two pairs of rotor. , and are total torque, related to quadrotor as of total summation of Coriolis torque, , and Gyroscopic torque, and quadrotor body frame torque, . ( Finally, from Eq. (3) and Eq. (4), the final equation for quadrotor translation dynamics and rotational dynamics can be formulated as (5) (6) Table 1 shows x-configuration quadrotor's parameter used in this research which is obtained through system identification. Fig. 2 shows the hardware configuration of the laboratory quadrotor UAV system used in this research.

B. PID Control
PID controller is a classical controller that has proven to be robust and tremendously beneficial in many linear or nonlinear applications. The PID design are pointed out in many references, such as [10][17] [18][19] [20]. The controller attempts to minimize the error over time by adjustment of a control variable u(t). The mathematical representation of PID controller is given as (7) where, is the input signal and the error signal is defined as (8) On the other hand, a PID controller continuously calculates an error value then applies a correction based on proportional, integral, and derivative terms as shown in Fig. 3 (a). The proposed controller for attitude and altitude stabilization in this simulation is shown as Fig. 3 (b), where each of references input have its own PID controller to control highly nonlinear quadrotor model.
The main objective of this simulation is to design controller which makes x-quadrotor's attitude stabilized during hovering or taking off. The PID parameters are tuned by particle swarm optimization (PSO) method and Sum Square Error (SSE) is chosen as it fitness functions.

C. Particle Swarm Optimization (PSO)
PSO was firstly introduced by Kennedy and Eberhart in 1995, based on fish schooling and bird flocking movement behaviour [21] [22][23] [24]. In PSO algorithm, particles will move randomly in any possible direction towards it global best and current best location using its present velocity which later then being updated randomly. Hence, the used of real-number randomness and global communication between particles will increase efficiency in swarm. Let x i and v i is the position vector and velocity vector for particle i, respectively. There are 12 parameters of PID controller to be tuned, therefore the proposed model of this application is as shown in Eq. (9).
For this simulation, the swarm particles, x i and particles' velocity, v i are initially set randomly using Eq. (10) and Eq. (11), respectively, where l b (lower boundary) and u b (upper boundary) is limitation space or regions set for the particles, r 1 , and r 2 is random real-number between [0 1].
(10) (11) In this application, the objective is to find minimum error of the fitness function. There are four fitness function which are as shown in Eq. (12) -Eq. (15).
Where the fitness of the particle is evaluated based on the responses by sum square error (SSE). The personal best of an agent is updated based on the mathematical statement in Eq. (16) as (16) While the global best is updated based on the mathematical statement in Eq. (17) as (17) The new velocity vector [22] for this PSO is determined by the following formula (18) where, an inertia function, as Eq. (19) [26], and is random real-number between [0 1], the parameters and are the social coefficient and personal coefficient which is constant and typically set as two [22].
The new position then is updated by (20) Stopping criteria used in this application is maximum iteration where, once the iteration reached the maximum value set, the simulation will stop and the best result obtained is display.

III. RESULT AND DISCUSSION
In this simulation, initially, ϕ, θ, and ψ are set at 0.2 radian. The simulation times is set from 0 to 20s and updates every 100Hz. Desired ϕ, θ, and ψ are set to 0 radian, while desired z is set at 10 meters. Number of iteration is set fixed at 100. The fitness function or so-called objective functions is set all high priority using logical AND (&&) in MATLAB programming to have better performance of very nonlinear quadrotor system compared to [24] which analyses each one separately. The data is recorded few times with difference number of particles being set. Overall performances are measured using sum square error (SSE). Table 2 shows the first setting with SSE fitness function for z-axis, roll (ϕ), pitch (θ), and yaw (ψ). Fig. 4 shows the z-axis performance after each optimizing process. Based on this figure, the suitable PID parameter for altitude performance of quadrotor during hovering is best at Case 6 with percentage of Overshoot (%OS) at 0.86, settling time, Ts at 0.83s and final value at 10.09 as stated in Table 3. Fig. 5, Fig. 6, and Fig. 7 show the roll (ϕ), pitch (θ), and yaw (ψ) angle after each optimizing process, respectively. Overall, from the figures and per Table 3, it clearly shows that performance of SSE on Case 1 is preferable where, the attitude control converges faster to the set point, 0 at 0.42 seconds for roll, and 0.70 seconds for pitch while the altitude settling at 10.12 seconds even though with 1.2% error. The simulation is then being continued with difference mix fitness function, difference number of particles, difference lower boundary. But still overall performances are measured using sum square error (SSE). The chosen results are tabulated as shown in Table 4. Result from Table 4 and Table 5, clearly shows that fitness function, Sum Absolute Error (SAE) and the combination of fitness function Mean Absolute Error (MAE) and fitness function Sum Absolute Error (SAE) give zero steady state error for hovering which means quadrotor can reach the desired position (10 meters) compared to others with 0.4% to 1.4% error. MAE + SAE have better settling time, Ts at 3.06s compared to SAE with 4.42s but the percentage of Overshoot (OS%) MAE+SAE is nearly double of SAE. For attitude performances, it clearly shows that fitness function SAE give fastest settling time, 2.75s for roll (ϕ), 0.10s for pitch (θ), and 3.19s for yaw (ψ) angle. Fig. 8, Fig. 9, Fig. 10 and Fig. 11 show the comparison performances between mix fitness function for altitude and attitude for quadrotor during hovering, respectively. Fig. 5 Roll, ϕ performance after optimizing using SSE fitness function Fig. 6 Pitch, θ performance after optimizing using SSE fitness function Fig. 7 Yaw, ψ performance after optimizing using SSE fitness function     In this paper, a fined-tuned PID control of quadrotor UAV using PSO algorithm is proposed. The quadrotor used in this simulation is x-configuration types and a Newton-Euler modelling is used to describe quadrotor nonlinear dynamics model. A standard accelerate PSO is used in tuning the PID parameter where four type fitness functions; sum square error, sum absolute error; sum absolute error + sum square error, mean absolute error + sum square error, and mean absolute error + sum absolute error, has been tested to see quadrotor performances during attitude and altitude control for the desired set point. The obtained result shows that sum absolute error fitness function gives the best PID parameters with lower overshoot, better settling time and reach set point value compared to others. In the other hands, the higher the number of particles, the longer algorithm takes to complete it iteration but the result sometimes is not even better from the previous run.