Flight Trajectory Control System on Fixed Wing UAV using Linear Quadratic Regulator

Utilization of Unmanned Aerial Vehicle (UAV) technology has developed rapidly over the past decade. Its use is no longer limited to the military field but has covered various aspects of human work. One type of UAV that is widely used is a type of fixed wing. This type of UAV has the advantage of being able to maneuver with 6 Degree of Freedom (DoF) by utilizing deflections from its surface controls. The surface controls of this UAV consist of an elevator, a rudder, and two ailerons. By utilizing all of the surface controls, the UAV is expected to fly according to the specified flight path. Therefore, flight control systems are needed. Linear Quadratic Regulator (LQR) is an optimal control that can be used to maintain lateral and longitudinal attitude stability of the UAV while tracing the waypoint coordinates. The results of the study show the response of the system under the desired specifications. These results indicate that the control system has been able to maintain vehicle stability while tracing the path along with the waypoints. Keywords—LQR; UAV; Control

INTRODUCTION Utilization of Unmanned Aerial Vehicle (UAV) technology has developed rapidly over the past decade. Its use is no longer limited to the military field but has covered various aspects of human work. One type of UAV that is widely used is fixed wing aircraft. The UAV has the advantage of its ability to maneuver with 6 Degree of Freedom (DoF) that utilizes deflection from its control surfaces [1]. Also, deflection of the surfaces control can also be used as a vehicle to be able to adjust the direction of translational motion on the axis of the body of the UAV. The control surfaces consist of elevators, rudder, and aileron.
A UAV must have the ability to fly to a coordinate in order to complete its flight mission [2]. The ability of a UAV to reach a coordinate point is known as the waypoint search. Waypoint is a flight path in the form of an imaginary straight line drawn from the coordinates of the flight destination [3]. The UAV needs to maintain its heading towards its destination and flight path when carrying out flight missions so that the flight duration and flight distance are optimal. If the UAV takes an inappropriate flight path, it is risky to continue flying without being able to reach the destination coordinates. Besides, if the UAV cannot maintain its flight trajectory when carrying out mapping or monitoring missions, the resulting image is not as expected [4].
One of the primary disturbances experienced by the UAV to be able to reach a coordinate and maintain its flight path is a change in speed and dynamic wind direction. This condition can result in sudden changes in lift force on the wing, which results in UAV experiencing roll or pitch motion with extreme angles [5]. A longitudinal and lateral stability control system of the UAV is needed to overcome the unwanted rotational motion. Deflection of control surfaces is a component used to regulate the stability of the UAV's attitude. If control surfaces have a response that is not too optimal, then the UAV will experience overshoot or even steady state error. This condition can result in the UAV finally experiencing stall, even stall spin [6].
Also, wind disturbances can also make the UAV unable to maintain the direction of the flight path when heading to the coordinates. A lateral control system is needed to overcome this problem, by utilizing the rudder to adjust the attitude of the heading of the UAV to the bearing destination coordinate point [7]. If control surfaces have a slow response, the UAV will deviate far from its destination point. Whereas when the response is too fast, the UAV will experience oscillation [8].
From the above explanation, it can be concluded that a reliable longitudinal and lateral stability control system is needed to regulate the attitude of Fixed Wing UAVs so as not to experience overshoot (even multi overshoot) and steadystate error, and be able to maintain stability and flight trajectory while carrying out flight mission. Steady state error is the deviation or difference produced by the UAV's response to the expected steady position and lasts long enough. Several control methods have been used to regulate vehicle stability, including Proportional Integral Derivatives (PID) and Linear Quadratic Regulators (LQR).
LQR is a modern control method that works over statespace representations. LQR can handle multiple inputs and generate multiple outputs (MIMO). Besides that, LQR generates feedback gain by utilizing the Hamilton-Jacobi-Bellman (HJB) equation by using the cost function to achieve optimal control. With the advantages possessed by LQR, it is expected that the application of this control method can produce the optimal lateral and longitudinal stability control system of a Fixed Wing UAV. MATERIAL AND METHODS A Fixed Wing UAV utilizes a combination of thrust generated by the thruster and the lift force generated by the airfoil of its wing to fly in the air. This UAV can manoeuvre during flights by utilizing several servo motors, which are installed as actuators in ailerons, rudders and elevators. When the UAV maneuvers, it works with the North-East-Down (NED) earth inertia frame. The x-axis of the UAV body is parallel to the north. The right-hand rule is used to get the axes of the other body frame. The y-axis corresponds to the east direction of the earth, and the z-axis corresponds to the downward direction of the UAV body [9].
The UAV uses an IMU sensor to determine its orientation [10]. A UAV can be said to be stable when its orientation angle error is smaller than the tolerance limit angle (5%) [11].
A Fixed Wing UAV can make translational motion along the x or y-axis body's reference frame. The UAV will continue to move along these axes until it gets some instructions for rotating roll and yaw. The roll and yaw motion will change the direction of the UAV's flight. These instructions can come from the input of the remote control or autonomously in the form of several waypoint coordinates. The points of the waypoint coordinates are sent to the UAV via the ground control station (GCS). These points become references for UAV movements. The UAV will use data from the LEA 6-H GPS receiver, to compare the position of latitude and longitude itself to the target coordinates. The difference in value will be feedback on the control system to regulate the roll and yaw motion of the UAV in order to fly to the target coordinate point [12].
The waypoint trajectory tracking control system utilizes proportional gain Kp where the gain value serves to improve the response of the UAV during flight missions. The system uses output data from the process of calculating the difference between heading towards the UAV's coordinates. The difference between the coordinate points of the UAV position and the destination coordinate point is commonly known as the bearing angle. The relationship between bearing angle, vehicle heading and destination coordinate point is shown in Fig. 2.
The difference between bearing angle values and the heading attitude is optimized with Kp gain in regulating vehicle movements towards a coordinate point. This method is used because the value of the UAV's body yaw angle must always correspond to the bearing angle. The flight towards the coordinate point will be arranged using the rudder as the control surface. The UAV requires a control system that can overcome some unwanted motion when it moves along a path to the waypoint coordinates. Some unwanted motion occurs due to interference from external factors or sensors in the system. These movements can make the UAV unstable so that it deviates from the specified flight path. The control system is expected to be able to adjust the control response time and to minimize the occurrence of steady-state errors so that the UAV can maintain its flight path.
In this research, the UAV must be able to maintain its heading towards imaginary paths that are formed from several coordinate points. The UAV must also have a short response time (rise time) to prevent the UAV from stalling before being able to correct its attitude. In addition, a short rise time also prevents too much deviation or overshooting of the expected trajectory. Overshoot experienced from flight paths is limited so that the UAV does not experience unstable flight. Flight stability can be achieved with an adequate control system. Based on previous studies, control with the LQR method on fixed-wing UAVs can only experience overshoot of less than 10%. This overshoot problem must be overcome with less than three seconds (settling time) for lateral and longitudinal motion.

A. System Dinamics
A fixed-wing aircraft has several vector variables that work on it, as shown in Fig. 3. Based on the figure, we can obtain some equation around some vectors that work on a fixed-wing plane during the flight phase. A fixed-wing UAV as an inheritance of a regular wing plane can use the same principle. The vectors consist of several components like angular velocities, angles, forces, and torques, as shown in Fig. 4. These vectors are translated into (1), (2), and (3) [13].
Fixed-wing aircraft use the airfoil and its fixed wing to give a lift to the aircraft when the thruster works so that the plane can fly. The lift and thrust of the thruster must be higher than the air or drag resistance experienced by the vehicle. Therefore, the lift produced by the wing needs to be calculated to determine the actuator deflection angle effects on changes in lift force. Lift force of a wing can be determined using (4).
During the flight, a fixed-wing aircraft still produces forces and torques whose equations are written as (6) and (7) [13].
CG is the plane's moment of inertia shown in Equation (8) [14].
where is body mass, is body length, is height, is body width, is wing mass, is wing length, is wingspan, is wing height, ℎ is horizontal stabilizer mass, ℎ is horizontal stabilizer length, ℎ is horizontal stabilizer width, ℎ is horizontal stabilizer height, is vertical stabilizer mass, is vertical stabilizer length, is vertical stabilizer width, is vertical stabilizer height, is propeller radius, ℎ is propeller height, is spinner radius, ℎ is spinner height, is propeller radius, and is spinner mass. By using equations (6) and (7), the equations of fixed-wing aircraft motion can be reduced to (12) to (17).

B. Electronics Design
Electronic system design adapts to the functions needed by the system. There are three main parts in an electronic system, namely input, processor and output as shown in Fig. 5 The sensor used as a reference for the UAV body is an IMU that contains an accelerometer and gyroscope sensor. The sensors are connected to a microcontroller by utilizing SDA and SCL through I2C communication lines. The UAV uses a GPS LEA 6-H receiver to find out its position in real time. Besides, the HMC8883L magnetometer sensor is needed as a reference for yaw attitude to find out the heading angle of the UAV and the magnitude of the bearing heading itself to the destination coordinate point.
GPS receivers use serial communication through RX and TX to communicate with microcontrollers. Serial communication is also used to give commands from the Ground Control Station to the UAV via Radio Frequency during flight. Whereas manually controlling UAVs can be done by using a nine channel remote control through several digital pins from a microcontroller.

C. Electronics Design
This research uses the Linear Quadratic Regulator (LQR) control method. The LQR method is useful in determining the full-gain feedback K of the system [16]. The block diagram of the control system of this research can be seen in Fig. 6  • Roll angle (ϕ) and roll angular velocity (p) • Pitch angle (θ) and pitch angular velocity (q) • Yaw angle (ψ) and yaw angular velocity (r) The control system is modeled based on the UAV rotational motion model in the form of state space as in equation (21) [17].

III. RESULTS AND DISCUSSION
UAVs must have the ability to maintain lateral and longitudinal attitudes when conducting waypoint missions. Therefore anti-rotation control is needed to eliminate unwanted yaw, pitch and roll motion during the flight phase. Tests are carried out in stages for each UAV rotation attitude.
Anti-rotation control testing is done by simulating Q determination of each rotational motion to get the most optimal full-feedback gain K automatically. The simulation begins by making a mathematical model of the system be controlled in the form of state space. Then the Q component of each rotational motion is simulated to find the optimal Q value to be tested fly. The component of the Q value tested on the system consists of: • for roll angles, • for roll angle velocity, • for pitch angle, • for speed of pitch angle, • for yaw angle, and • for yaw angular velocity. •  TABLE 2 is the conversion of Q to gain K generated in the simulation process. The results of the simulation are then tested on UAV flights to test their stability when receiving disturbance.  The best Q shown in the simulation consist of = 10 and = 1. The response of the system using Q is shown in Fig.  7. The simulation results show that the value of Q tuning results meets the desired specifications with a rise time less than 2 seconds, the settling time is less than 4 seconds, and the overshoot is no more than 2.5 meters/second. The same thing applies to anti-pitch control simulations, as shown in Fig. 9. So based on the simulation results, the system has been able to control according to the reference value given. When implemented in a UAV and flown in the real world, the control system experiences a rise time of 0.7 seconds with steady-state error approaching the state level (0°), which is equal to 0.29° The system also does not experience overshoot outside the set tolerance, so it experiences a short settling time, as shown in Fig. 8. These parameters meet what is desired.
The same thing is also experienced with pitch motion control. The simulation results (shown in the Fig. 9) are applied to UAVs and flown in the real world. The system no longer experiences multiple overshoots, with the system still having a rise time of 0.7 seconds. Also, the system has a maximum overshoot of 3.18°, which is still within the specified tolerance area. The steady state error tendency is at 0.37°, where the condition approaches the level (0°) and the settling time is concise, as shown in Fig. 10. These parameters also meet what is desired. The simulation produces Q, which is converted to K for each angles and angular velocities of the UAV. The simulation results are then validated through flight testing. Based on the testing, it was found that the system has a rise time that matches the expected control specifications for each antirotation (roll, pitch, and yaw). However, for the anti-yaw control, which is a control that helps the UAV to set its headings and overcome interference during flight missions, it still experiences multi overshoot, which is shown in Fig. 12, different from the anti-yaw simulation results that look good (as shown in Fig. 11).. Then automatic optimization is done to reduce the multi overshoot, as shown in Fig. 13. The flight direction reference is a yaw angle reference. The yaw angle reference is generated from heading processing when the data is taken, then compared with latitude and longitude destination coordinates. This difference results in a bearing angle. A bearing angle is an angle formed by an aircraft with a destination coordinate point. Besides, the difference between latitude-longitude values of the UAV and the destination coordinate points results in a distance between the coordinates and the UAV.
The bearing angle will be used as a parameter in determining the yaw angle reference. This determination is calculated using a small angle to determine the yaw response, whether the response turns left or right with the yaw angle reference obtained. Proportional gain plays a role in these calculations.  The test results show that the system response still does not meet what is desired. The system is still not responsive in maintaining its heading to the flight destination coordinates. The UAV's flight path even deviates more than 50 meters from the expected trajectory (flight path reference), which results in the UAV circling in the sky and prolonging the duration of the flight. External factors such as air resistance and the presence of wind disturbances from the side or crosswind are the main causes of this problem. The UAV is difficult to set the heading directly to the coordinates of the next destination.
Therefore, proportional gain Kp from needs to be optimized again to improve the response of the UAV in the face of external interference. Kp tuning is done automatically during the flight process with an increase of 0.01. This auto-tuning takes place as long as the difference between the desired value and reality is still high. In the test, while automatically tuning the Kp gain, we only use three waypoints. This method is used so that the determination of the value of Kp is easier than using four waypoints or more. The auto-tuning finally produces a gain Kp equal to 1.7, which is considered to have a reasonably optimal response, as shown in Fig. 15. IV. CONCLUSIONS The conclusion that can be drawn from the research that has been done is that the UAV can maintain its trajectory autonomously during the waypoint search mission using the Linear Quadratic Regulator (LQR) method. The results of the LQR control cascade with Kp proportional gain in the test show that the UAV can maintain its heading so that the control response consisting of rising time, settling time, steady-state error, and overshoot shows the results as desired.
The next study is to add an altitude control system to a fixedwing aircraft so that the waypoint tracking control system is obtained for three-dimensional flight paths.