Optimization of UAV Robust Control Using Genetic Algorithm

A hybrid methodology combining the use of a robust LQR servomechanism (RSLQR) and a genetic algorithm (GA) for the design of the flight control system (FCS) of a lightweight unmanned aerial vehicle is the subject of this paper. The objective is to develop a systematic design approach based on a proven technique that provides improved time response and robust steady-state performance of the control system, so as to reduce the burden of trial-and-error procedures. The design of the inner loops of the UAV autopilot is formulated as an optimization problem where the GA is used to determine the weights of the RSLQR synthesis. The process is aimed at maximizing a weighted sum of an appropriately defined multi-objective fitness function, evaluated through a series of nonlinear simulations, so as to fully engage the control system in complex maneuvers, such as combined changes in altitude and heading at different flight speeds. The performance of the proposed control design approach is evaluated using analytical tools for linear systems, software-in-the-loop simulations, and Monte Carlo campaigns. The comparison between the new controller and a classical FCS with internal PID loops on attitude angles for stability and control augmentation is analyzed and discussed using an accurate vehicle model with an extended Kalman filter for output reconstruction.


I. INTRODUCTION
Unmanned aerial vehicles (UAVs) are increasingly used in different applications in both military and civilian domains.In particular, small fixed-wing UAVs present several advantages compared to multi-copter configurations, such as payload capabilities, a much wider operative range, and improved overall power efficiency.Moreover, a fixed-wing configuration is mandatory whenever endurance is a primary requirement.UAV operations can be challenging when the vehicle interacts with the environment [1], i.e. approaching terrain for inspection and data gathering, infrastructure and building monitoring, goods delivery, search and rescue missions, or providing medical emergency services.Moreover, small UAVs are more subjected to atmospheric disturbances due to their lightweight, particularly when flying close to the The associate editor coordinating the review of this manuscript and approving it for publication was Christian Pilato .ground, walls or rigid obstacles [2].Therefore, a major design objective is to develop, with limited effort and cost, effective and reliable FCSs for aerial systems having a significant level of model uncertainty.
Conventional autopilot systems for fixed-wing UAVs provide lateral and longitudinal control through proportionalintegral-derivative (PID) controllers and/or phase-lead or lag compensators [3].An optimization-based tuning for a classical PID plus compensator architecture is proposed in [4], where the longitudinal controller is found as the solution of a single objective, constrained nonlinear optimization problem, solved by means of a Sequential Quadratic Programming (SQP) algorithm.In [5], an automatic tuning algorithm is used for the controller design of a micro-aircraft, based on tests in a wind tunnel.In the framework of autotuning methods, the relay feedback approach is discussed in [6] for the determination of controller parameters once gain and phase margins are specified.This technique was further extended to allow the tuning of a gain scheduling PID controller, so as to provide improved performance with respect to system nonlinearities [7].
Besides PID controllers, more modern design methodologies have been proposed for fixed-wing UAVs, including robust control techniques such as H ∞ , used to reduce the response to atmospheric turbulence and ground effect [8], model predictive control (MPC) [9], and linear parameter varying (LPV) [10].The latter allows for improved control effectiveness by better capturing the system nonlinearities in the control design.Nonlinear model predictive control (NMPC) is applied in [11] to, again, include the nonlinear effects in the synthesis of attitude and speed control laws, and explicitly deal with the boundary of the flight envelope and the actuator limits.Feedback linearization and model reference adaptive control (MRAC) are integrated in [12] to improve the robustness of the attitude control system of a high-altitude UAV with respect to uncertainties and gust disturbances.Reference [13] presents a nonlinear controller for a twin-engine UAV in the 500 N weight class where a recurrent neural network trained offline realizes the inversion required for feedback linearization.A model reference adaptive control, specifically tailored to an LQR baseline controller, is proposed in [14], and a fuzzy neural network featuring a proportional controller is considered in [15] to deal with a high level of uncertainty in the UAV model.Adaptive laws based on uncertain Euler-Lagrange dynamics of the vehicle are developed in [16] for the autopilot of a fixed-wing UAV to explicitly take into account under-actuation in the dynamics, and system uncertainty.When reference is made to novel, advanced functionalities of FCSs for unmanned systems with unknown dynamics and disturbances, and in a broader perspective than for small-size drones, the study [17] is recalled where a fragility-avoidance prescribed performance control (PPC) methodology, based on a fuzzy neural approximation, is developed for velocity and attitude control.
In this study, a robust FCS is devised for a small fixed-wing UAV in the weight class of 150 N. In particular, control law parameters for the inner control loops are determined by means of the LQR and static projective control (SPC) methods [18], and LQR weights are specified solving an optimization problem through a genetic algorithm (GA).
The major design objective is to improve FCS performance throughout the UAV flight envelope while systematizing the synthesis process in order to relieve the designer from the need for time-consuming, manual tuning approaches and reduce the development time of low-cost aerial platforms.The robust LQR servomechanism design technique (RSLQR) is particularly suitable for realizing, along with the required level of stability, important flight characteristics for unmanned vehicles, such as reliable command tracking and minimal control effort in the presence of uncertainties in system dynamics, wind gust disturbances, and sensor noise.Furthermore, by reconstructing the closed-loop structure of the optimal system obtained by the RSLQR method, the SPC allows the system characteristics to be maintained even if not all the original feedback signals are available or accurate.
The present work builds on and aims to develop the preliminary analysis presented in [19] where i) the same approach was applied to a simplified UAV model not featuring the extended Kalman filter (EKF) for output reconstruction which is a key element of the real vehicle FCS, and ii) the synthesis method and the effects of outer loops on controller performance were not investigated.
Relevant examples of the effectiveness of the considered design methodology are reported in a number of applications.In the work of Lavrestsky [20] the results of RSLQR design for the longitudinal control of a UAV are compared with those based on projective control theory (PCT), namely RSLQG and RSLQG/LTR, where RSLQG and LTR stand, respectively, for robust servomechanism linear quadratic Gaussian, and loop transfer recovery.The high control accuracy of RSLQR is exploited in [21] for a UAV normal acceleration controller, where a L 1 adaptive controller [22] is used to compensate for the effects of model uncertainties.A combination of RSLQR and SPC techniques is considered in [23] for the inner control loops of the nonlinear model of a flying-wing UAV.The solution of a trajectory tracking problem shows the excellent response of attitude loops, in terms of quickness and precision, with respect to an ordinary PID autopilot.A pitch angle controller for UAVs based on RSLQR and Kalman filtering to improve performance under noisy conditions is presented in [24].Application of the RSLQR technique is combined with an extended state observer in [25] to design the control system of a tilt-rotor UAV, capable of successfully managing actuator saturation limits while improving tracking and disturbance rejection performance with respect to a PID controller.
Yet, the result of RSLQR design depends on the definition of a set of suitable weight parameters.In this respect, the goal, provided that a reasonably accurate model of the vehicle is available, is to reduce the gap, in the early stages of the design process, between the linear control synthesis model and the nonlinear assessment and validation framework.This may be obtained by parameterizing the LQR weight matrices and setting up a two-layer global optimization problem, where an evolutionary algorithm (EA) [26] determines the weights.
In order to design the inner control loops of the UAV autopilot, a composite merit index is defined that accounts for metrics related to flight qualities, as evaluated over a carefully-selected set of nonlinear simulations in extended regions of the UAV flight envelope.The resulting controller is expected to provide better overall performance in terms of stability, precision, and responsiveness of command tracking, robustness to model parameters, and disturbance rejection.
Application of EAs for solving real-world optimization problems is a recent and effective practice in the aerospace field [27].EA algorithms overcome traditional gradient-based numerical optimization methods in practical scenarios, being able to deal with non-differentiable, mixed real-discrete, and highly nonlinear objective fitness function landscapes [28].Using a population of candidate solutions in spite of a single one allows for a robust search that is less likely to get trapped in local optima than a traditional single-point search with gradient information and, in turn, provides a smoother (yet less accurate) alternative of the gradient.Being very simple to use and effective in practical problems, EAs are also suitable when the objective function is computed by means of numerical simulation, that is, as the output of a black-box (i.e., proprietary) code/tool like in CFD or computational structural design.Also, EAs are easy to scale on massively parallelized processing hardware, taking substantial advantage from current improvements in computing capabilities.Finally, EAs can be hybridized, that is, used in conjunction with (possibly derivative-free) local optimization algorithms, such as the Nelder-Mead Simplex technique [29] to retain the advantages of both methods.
Among various EA approaches, a GA that mimics the process of natural selection, in which the fittest individuals are selected for breeding to produce the next generation's offspring, was selected in this study for its superior usability and robustness [30].GAs have been extensively used for PID controller tuning.A comparison between GAs and the conventional Ziegler-Nichols method for PID tuning is presented in [31], where a first-order dynamical system is taken into consideration in order to illustrate the advantages of the former approach.A revised formulation of the same methodology is presented in [32], which relies on a combination of different performance metrics such as integral square error (ISE), integral time square error (ITSE), integral time absolute error (ITAE), and mean square error (MSE), to determine the optimal tuning of a controller for chemical processes.As for applications in the aerospace field, a method utilizing GA to automate the tuning process is proposed in [33] for the parameters of the Robust Inverse Dynamics Estimation (RIDE) controller of an F-18/HARV aircraft model.An improved GA, intended to overcome some shortcomings of the methodology such as premature or local convergence and low search efficiency, is presented in [34] to optimize the parameters of a PID pitch control loop for a small UAV.In the comprehensive study of [35], where a GA allows for the optimization of a set of trajectory-tracking controllers for autonomous aircraft, the performance index is composed of a set of metrics based on tracking error and control activity in response to a commanded trajectory consisting of a series of climbing and descending S-turns.
A GA has been utilized as a PI/PID tuning method to enhance the autopilot response of a very lightweight fixed-wing UAV [36].The Zeigler-Nichols method and GA optimization technique are considered in [37] to tune the roll-axis PID controller of an aircraft model.The PID gains in the inner loops of the position controller for a quadrotor are optimized in [38] using different meta-heuristic algorithms, including GA, to minimize a fitness function based on the integral of time multiplied by absolute error, and the rise time, settling time and overshoot.GA shows superior performance in forward flight among a number of EA algorithms, the performances of which are compared in the optimized tuning of a PID-based FCS for a medium-scale rotorcraft [39].GA effectiveness for control tuning has been also exploited by the authors for the attitude control of a launch vehicle in atmospheric flight [40].
Although the application of GA for controller tuning is an established field of research, further developments may lead to exploiting the full potential of the methodology and overcoming some limitations in its application.For example, in [31], [32], [36], and [37], the PID gains are adjusted to optimize performance indexes mainly associated with the error between the reference input signal and the simulated or ideal system step response for single-axis excitation.More representative performance indexes are considered in [34] and [38], based among others on control action, overshoot, rise and settling times, and system error, but still using PID-based control architectures in a SISO framework.In [33] the tuning is carried out by minimizing the Euclidean norm of the difference between the response of a linearized form of the aircraft model and an ideal reference model and, apparently, the analysis is limited to a single trim point and the roll response.
The main contribution of this work is as follows: • A relatively simple hybrid and robust control architecture is proposed, suitable for lightweight, low-cost UAVs, featuring a GA to determine the weights that enter the RSLQR problem, which, in turn, provides the optimal controller tuning.
• A complete UAV autopilot is considered, designed by RSLQR and SPC synthesis methodologies, with realistic and complete functionalities, and the increased complexity in tuning is handled by the GA.
• A generalized framework for UAV control system parameters evolutionary optimization is provided, where the LQR weights are determined by considering the nonlinear simulation of a sequence of maneuvers, including speed, height, and heading changes, thus encompassing a variety of flight conditions.The fitness function takes into account the quickness and precision of the UAV response to the reference commands at different flight speeds, together with the maximum value of the aerodynamic angles, the high-frequency content of the control signal, and the coupling between longitudinal, lateral, and speed controllers.
• The designed controller, whose characteristics are implicitly defined by the fitness function formulation, provides higher performance, compared with PID loops, under a wide range of flight conditions, despite nonlinearities, coupling, model uncertainty, and servo saturation.
The methodology is applied to the mathematical model of a 1:3 scale model of the Yakovlev Yak-112 aircraft, which is currently used as a flight and ground testbed for the design and validation of UAV FCSs.The performance of the FCS design is analyzed by software-in-the-loop (SIL) simulations of specific maneuvers.In particular, the effectiveness of the optimally tuned autopilot is compared, in terms of command tracking, robustness, and disturbance rejection, to that of the actual control system of the vehicle, which features PID inner loops on attitude angles (roll and pitch) and yaw rate for stability and control augmentation.
In what follows, the simulation model of the UAV is outlined in Sec.II, where a short description of the main features and architecture of the autopilot currently implemented in the vehicle is also reported.The design of the inner controllers is presented in Sec.III with reference to the two steps related to (i) RSLQR synthesis for the longitudinal and lateral dynamics, and (ii) optimal tuning of LQR weights.In Sec.IV FCS performance is analyzed and discussed in order to assess the advantages and possible limitations of the proposed control design technique.A section of conclusions ends the paper.

II. UAV SYSTEM A. SIMULATION MODEL
The main inertial and geometric characteristics of the UAV are reported in Table 1 together with a few performance data.The vehicle is modeled as a six-degrees-of-freedom rigid body flying over a flat, not rotating Earth.The equations of motion are standard (see for instance [41,Ch. 3]), and the dynamical system is represented, in state-space form, as where x = [x v , x s ] T , and the elements of x v = [u, v, w, p, q, r, φ, θ, ψ, , h, g , g ] T are related to the translational (velocity components u, v, w, altitude h and geographic longitude g and latitude g ) and rotational (angular velocity components p, q, r and Euler angles φ, θ, ψ) motions, and to the dynamics of the propeller rate of revolution (rpm) .The states in x s = [δ t , δt , δ e , δe , δ a , δa , δ r , δr ] T are associated with the servo model, where the subscripts t, e, a and r indicate throttle, elevator, aileron, and rudder, respectively.The command input vector is u = [δ cmd t , δ cmd e , δ cmd a , δ cmd r ] T , and y = [V , a y , a z , φ, θ, ψ, p, q, r, h, g , g , ḣ, χ] is the vector of measured outputs, being V the indicated airspeed, a y and a z the lateral and normal components of acceleration in body-axes, respectively, and χ the heading angle.The wind vector (input w) is represented as the sum of a persistent deterministic component, and a random variation described by a Dryden turbulence model specialized for low altitude [42].Finally, a standard atmosphere model for air density (ρ) and temperature (T ) is featured, the latter to be used in the single-piston engine model.Figure 1 shows the major elements of the UAV model.
As for the aerodynamic block, the expression of force and moment components in body axes is standard, and the aerodynamic coefficients are expressed as where α is the angle of attack and β is the sideslip angle, c and b are, respectively, the mean aerodynamic chord and the wing span.The aerodynamic model has been determined by means of the VSAERO ™ code [43], a 3D panel method that calculates irrotational and incompressible subsonic flows on bodies of arbitrary shape, featuring an iterative procedure for the calculation of nonlinear wake effects.Viscous effects are taken into account by coupling the potential flow field to a boundary layer solution.The constant parameters in Eqs. ( 3) are reported in Table 2, whereas the terms depending on the aerodynamic angles (subscript 1 in Eqs. ( 3)) are specified in tabular form in the ranges −10 ≤ α ≤ 9 deg and −30 ≤ β ≤ 30 deg, and shown in Fig. 2 for, respectively, the longitudinal and lateral coefficients.The Engine block features a two-strokes piston engine with first-order rpm dynamics and the propeller model.In particular, the DLE 55 gasoline engine brake horsepower curve is provided by a look-up table as a function of throttle level and rpm, taking into consideration air temperature  and pressure, while the performance data of the fixed-pitch propeller (thrust and power coefficients, efficiency) are also specified in tabular form depending on the advance ratio.
A second-order dynamics with a delay of 0.03 s is considered for the servos, with identified parameters for the Hitec ® HS-5965MG model, namely damping coefficient, natural frequency, and delay, given by ζ = 0.85, ω s = 21.318rad/s, and τ s = 30 ms, respectively.Angular ranges Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.AHRS (attitude and heading reference system) that measures the angular rate and linear acceleration components in body axes, and the attitude angles, and a GPS sensor Venus638FLPx by SkyTraq Technology, Inc. ® for position, velocity and heading angle χ.Sensor models associated with measurements of acceleration, angular rate, IAS, altitude, GPS velocity, and χ feature white noise additive errors the characteristics of which, identified through a campaign of ground tests, are reported in Table 3, where µ and σ are, respectively, mean value and covariance.The noise η g on position (GPS) and attitude (AHRS) measurements is described by a Gauss-Markov first-order process as where τ > 0 is the autocorrelation time, and η d is the driving zero-mean white noise.Table 4 shows the error model parameters for this second set of data.

B. FLIGHT MANAGEMENT SYSTEM
The architecture of the UAV autopilot is illustrated in Fig. 3 where the block related to the physical plant (featuring the models of vehicle, servos, and sensors shown in Fig. 1), and the EKF are also shown.The filter uses the values of Euler's angles provided by the Xsense ® proprietary sensor fusion algorithm as input, and the GPS data for position, altitude, and velocity components in the horizontal plane, together with the coarse output of the AHRS for acceleration and angular rate as measurements.Estimates of c.g. coordinates, altitude, acceleration, and velocity components in the North-East-Down (NED) frame, and angular velocity components in body axes are computed at the frequency of 50 Hz, and used in the inner or outer loops of the controllers.Biases on acceleration and angular velocity components are also evaluated at the same rate.The analog output of the differential pressure sensor is low-pass filtered by a Butterworth filter with unit gain and 0.48 Hz cutoff frequency prior to IAS computation.The block Mode and comms manager receives data from the ground station, such as mode switching and task processing commands, waypoint coordinates, and inputs for autopilot modes, that is, command and hold for speed, altitude, rate of climb and heading, and data on aircraft status to activate the control modes and functionalities related to the assigned mission.Reference values for the outer loops are generated in the block Guidance laws when the waypoint navigation mode or auto take-off and auto-landing modes are engaged.
All the UAV mission planning and control functionalities are included in the discrete-time model of the FMS, where servo commands are updated at 50 Hz, with a time delay of 0.03 s due to the effects of computational delay and sampling.
The actual control system of the vehicle (FCS block in Fig. 3), sketched in Fig. 4 and dubbed Controller 1, features a classic cascade structure with outer loops that generate reference commands for the inner loops using values of speed, altitude, rate of climb (RC), and heading provided by the guidance laws.The inner loops, which are designed to increase the damping of high-frequency modes, namely, short period and dutch-roll, command aileron and elevator using PI controllers with feedback on attitude error signals for roll and pitch angles, respectively, along with terms proportional to pitch and roll rates.The rudder is controlled by a yaw damper with a washout filter on the yaw rate.The design point of the inner loops is at 30 m/s flight speed and the closed loop system is compliant with the requirements shown in Table 5, so as to achieve adequate robustness, expressed in terms of classical gain and phase margins, attitude tracking performance through the limitation of steady-state error, and transient response, specified in terms of maximum angular rate, bandwidth, and settling time.The outer loops are designed at the same speed to guarantee a limited steady-state error with respect to reference variables, and the pertinent requirements are shown in Table 6.The inner and outer loop gains are reported in Tables 7 and 8, respectively.This classic control system is used to assess by comparison the optimal controller performance.

III. CONTROL LAW DESIGN
In this section, the main features of the RSLQR method and its application to the design of the inner loops of the UAV   FCS are discussed first.Then, the optimization problem is formulated, the solution of which provides the LQR weights for the determination of controller gains.
The control system must provide accurate tracking of reference commands, disturbance rejection, and adequate stability of the closed-loop system.To this end, the design process is carried out through three main steps [23], that is, i) development of servomechanism model (SM) [44], ii) LQR synthesis for full-state control, and iii) application of the SPC method in order to devise the output feedback control law, each of them being instrumental for a specific feature of the controller.In this respect, the first two requirements above are met by building the servomechanism model, whereas the LQR technique is adopted due to its excellent stability and robustness performance, since it guarantees, in theory, infinity gain margin and at least 60 deg of phase 122258 VOLUME 11, 2023 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.margin, and the resulting controller minimizes the control action [20].SPC is used because, unlike applications of the LQR method to conventional aircraft models, control angle and rate measurement are commonly not available on small UAVs.The UAV model is numerically linearized in the design points, which leads as usual to the decoupled longitudinal and lateral dynamics [41,Ch. 4].
The design approach is presented in some detail for the longitudinal controller.Lateral control synthesis follows the same guidelines and only major features are recalled.The reduced-order, short-period model of the UAV longitudinal dynamics is formulated in terms of normal acceleration sensed at c.g. (a z ) that, together with the pitch rate (q) is a measurable state.When the second-order servo dynamics are included, the model in Eq. ( 5) is obtained, as shown at the bottom of the page, where u e is the trim velocity, and w d is the disturbance due to stochastic wind.Symbols for the dimensional derivatives are standard [41,Ch. 4].

A. SERVOMECHANISM MODEL
The SM is obtained by adding the error dynamics, associated with the difference between the actual acceleration (a z ) and the reference input (a cmd z ), to the state-space form of Eq. ( 5) with state vector x lon = a z q δ e δe T .
The state-space form of the SM features a model of the class of signals to be tracked or rejected (in case of disturbances) such that, when LQR is applied, the accurate tracking of the selected class of external commands is realized [20].Type 1 controllers are considered in this study in order to track a constant input with zero steady-state error and reject disturbances of the same class (e.g.step gusts) according to the internal model principle [45].
Following the approach outlined in [20, Ch. 3], we assume ȧcmd z = 0 for the command input, and ẇd = 0 for the unknown disturbance model.Given the output equation where C c = [1 0 0 0] T and D c = 0, the goal is that tracking error decreases asymptotically to zero in a robust manner with respect to the plant description, in the presence of disturbance of the considered class.Upon differentiation, the error equation becomes that, considering Eq. ( 6), is written as Setting z x = ẋlon and µ = δcmd e , differentiation of Eq. ( 5) gives where, as said, the disturbance term is set to zero.Finally, the augmented state vector z = [e z T x ] T is defined by adding the error dynamics to the system in Eq. ( 9), and the SM is written as follows, in compact form

B. LQR SYNTHESIS FOR THE SM
A static state-feedback controller for the augmented system in Eq. ( 10) is given by where , and the gains K e I , K x lon , are obtained by applying LQR theory to Eq. ( 10), and solving a minimization problem with cost function where, again, reference is made to [20,Ch. 3] for the details on the formulation and solution of the optimization problem.The feedback gains K c depend upon the numerical values of the weight matrices Q and R, positive-semidefinite and positive-definite, respectively.The augmented state vector z contains the error dynamics and the system model (Eq.( )), and the control term µ, when integrated, is implemented for command tracking and state feedback for stabilization.
In particular, the control law for Eq. ( 5) is obtained by Eq. ( 11) so as to express the integral over time of the augmented state vector z as

C. OUTPUT-FEEDBACK CONTROL
As the full state x lon is not available, an output-feedback controller is devised in the form δ cmd e of = −K y lon y lon (14) where the measurement vector is y lon = [e I a z q] T = C lon z I lon , with C lon = [I 3×3 0 3×2 ].Application of the SPC gives a control law that (partially) recovers the eigenstructure of the system with full-state feedback [23].In particular, the gain vector in Eq. ( 14) is expressed as where the columns of X y ∈ R 5×3 are the eigenvectors obtained by the solution of (A − BK c )X y = X y y (16) while the elements of the diagonal matrix y ∈ R 3×3 are the eigenvalues associated to the dynamics of y lon .A sketch of the longitudinal control system is shown in Fig. 5 where, as said, the UAV model includes the dynamics of elevator servo.
The same design methodology is adopted for the lateral controller, sketched in Fig. 6, where a multi-input singleoutput (MISO) architecture is proposed for the coordinated control of ailerons and rudder.As for the longitudinal design, the lateral force equation is rewritten in terms of the acceleration a y , since the sideslip angle β is not available from the measurements.The state vector of the reduced-order model for the lateral controller is thus x lat = is computed according to the same procedure discussed in Sec.III-B.

D. OPTIMAL TUNING
Selection of the state and control weight matrices Q and R for the LQR synthesis is usually realized by means of an iterative procedure, where the elements are modified one by one using, for instance, the so-called design charts [20] that report performance metrics in the time and frequency domains as functions of loop-gain crossover frequency.This procedure is usually time-consuming and, more importantly, the resulting control law may exhibit degraded performance when tested in nonlinear simulations of an accurate model of the vehicle as well as in-flight tests, so that additional work is often required to recover the desired performance.
The optimal tuning procedure relies on a GA for selecting appropriate values of the weight matrices elements, and the resulting LQR controller minimizes a cost function that takes into consideration a linear combination of stability and performance metrics, directly evaluated by simulation of the vehicle model that features all the elements of the FCS but the EKF.In so doing, the coarse measurements of angular 122260 VOLUME 11, 2023 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
rates are considered in Eqs. ( 14) and ( 17) as the result of a trade-off between the increased influence of noise, and the improvement in control law performance when the effects of filter dynamics are neglected.As a remark, tuning the EKF after the completion of the inner-loop design seems effective, at least in this application, to handle the degradation of the frequency-domain properties of the control system usually associated with the filter.
Let ξ be the vector of the unknown parameters of the LQR weight matrices, and K(ξ ) a control law with the gain matrix of Eq. ( 15), obtained through the combined application of the SPC and RSLQR syntheses using the weights R(ξ ) and Q(ξ ).For the sake of simplicity, we assume that R is the identity matrix and Q is of diagonal form so that ξ reduces to the diagonal terms of Q.Let be a reference trajectory specified in terms of flight altitude, speed, and course angle, to be precisely tracked by the UAV, and s(ξ ) the trajectory determined by simulation of a high-fidelity model of the UAV when the controller K(ξ ) is used.The tuning problem is posed as where the J i (s) are scalar performance metrics evaluated through the simulation s using the controller K(ξ ), and weighted by a user-selected constant coefficient λ i .
The trajectory consists of a sequence of five basic maneuvers given by i) at t (1) 0 , a combined climb with altitude variation h and a χ right turn at constant speed V LS (low speed), ii) at t (2) 0 , a combined descent and left turn with variations of altitude and heading angle − h and − χ, respectively, at V LS , iii) at t (3) 0 , a speed variation from V LS to V HS (high speed) maintaining constant altitude and heading, iv) at t (4) 0 , a combined climb ( h) and right turn ( χ) at V HS , and v) at t For the sake of clarity, the metrics J i are organized into three groups.The first one is related to the quickness and precision of the UAV response to the reference commands, and the metrics are evaluated for the aforementioned values of altitude and heading variations, at low (V LS ) and high speed (V HS ).The use of rise time T r , settling time T s , and percentage overshoot (PO) defined, as usual, as the maximum value of step response minus its steady-state value divided by steady-state value, in percent units, appears as a natural choice.Accordingly, the performance indexes are written as where the subscript i stays for {χ LS , χ HS , h LS , h HS }, and T r , T s are, respectively, normalization values for rising and settling times defined as In Eq. ( 23) RC max is the maximum rate of climb, and ψmax = g V n 2 z − 1 is the maximum rate of turn (to be evaluated at V LS and V HS ), being n z = 1/cos φ max the limit load factor of the vehicle, and T s i is set to 1.2 T r i .The above parameters can be easily adjusted for specific applications and UAV characteristics by properly selecting the maximum bank angle and maximum rate of climb.The same values RC max = 3 m/s, and n z = 1.5 at V LS and V HS have been considered here.
The merit index J XC aims at mitigating the effects of unwanted coupling between longitudinal and lateral dynamics that may cause not negligible deviations from the reference trajectory, as in the case of maneuvers involving simultaneous variations of altitude and heading.Also, J XC appears particularly relevant in control architectures where the velocity and altitude are managed separately, in order to reduce the effects of change of velocity on altitude tracking and vice versa.In this respect, the error e x i is defined for the j-th basic maneuver as the absolute value of the maximum difference between the actual and reference values of flight speed, altitude, and heading angle, in the time frame from the initial time (t (j) 0 ) plus the settling time (T s ) through the beginning of the next maneuver (t (j+1) 0 ), that is where x i is a normalization value for the quantity x i ∈ {V , h, χ } and e (j) being x ref i the reference signal.The second group of metrics is introduced with the goal of minimizing the maximum variations of angle of attack α and sideslip angle β, so as to reduce the probability of incurring into a stall condition and improve the aerodynamic efficiency in turning flight, respectively.The following indexes are thus defined where α max and β max are the limit values of the aerodynamic angles.
The last metrics concern the high-frequency content in the control rates ( δa , δe , δr ) so as to penalize excessive control activity and limit oscillations in UAV response.They are written as where the subscript i now indicates the control variable {a, e, r}, and H HP is a second-order high-pass filter providing 50 dB attenuation at low frequency, the cut-off frequencies of which are ω c e = 3 rad/s, ω c a = 2 rad/s and ω c r = 2 rad/s, for ailerons, elevator, and rudder, respectively.The constant parameters and weight coefficients in the expressions of the metrics are reported in Table 9.Note that the values for rise time and settling time are specified according to the characteristics of the outer loops.The optimization problem in Eq. ( 19) is solved using a GA, that is, a population-based, derivative-free, meta-heuristic technique inspired by natural evolution, that performs a global optimization and, thanks to its stochastic selection and mutation operators, has greater chances to evade from local optima than greedy methods [30].This property is very helpful in the problem at hand, as the objective function landscape is characterized by a (possibly large) number of local minima so that a global optimization algorithm such as GA is highly effective in order to prevent premature convergence to a sub-optimal solution.
Although population-based techniques usually result in an order of magnitude lower convergence rate than deterministic optimization algorithms, adoption of GA is motivated by the fact that the fitness function J GA (ξ ) is non-differentiable and possibly not even defined for every choice of the design vector ξ .This is not an issue for GAs, where unfeasible solutions are simply discarded in favor of feasible ones, without compromising the effectiveness of the search process, provided that the feasible search space is sufficiently large as in the problem under investigation.In this respect, it is worth reporting that initial attempts at using a singlepoint derivative-free optimization, such as the Nelder-Mead algorithm [46], were unsuccessful, as the method is very sensitive to the initial guess and converges to a local optimum in a neighbor of the specified guess.
Also, note that the performance in solving the optimization problem is highly dependent on an appropriate definition of the merit index, which must be able to capture all relevant aspects of the nonlinear simulations while being as simple and fast as possible to compute.
In the design process of the novel controller, which will be heretofore referenced as Controller 2, the LQR synthesis is carried out for each step of the GA-based optimization procedure in the trim points at V = 30 and 15 m/s for the longitudinal and lateral loops, respectively.The operating points were specified following a preliminary analysis of control performance with respect to the requirements in the expected range of flight speed.Therefore, the resulting controllers provide good performance being not gain-scheduled as will be discussed in what follows- The GA is run with a population of N p = 128 individuals for N g = 128 generations, using a single tournament for selection operator, simulated binary crossover (SBX) operator with crossover probability p c = 0.9, and uniform mutations with probability p m = 0.1 as mutation operator [30].As a rule of thumb, a larger N p improves the search capability of the algorithm because more points in the objective function landscape are sampled at each iteration, thus improving the convergence in case of complex, (i.e., non-convex) problems.Larger populations require a greater N g in order to make the search effective, as the individuals are initially randomly scattered over all the search space, which slows down the convergence.As a result, increasing either parameter causes a linear increase in the computational effort; thus, a trade-off between available time and the desired quality of the solution is mandatory.The other parameters (i.e., crossover and mutation probability) are kept at the default values as suggested by several studies (see among others [30]) as, apparently, the solution depends only marginally on their values.A single run of the solver requires roughly 2 hours on a computer equipped with an 8core Intel Core i7-9700K CPU @3.60 GHz.Multiple runs are performed to ensure robustness against the inherent randomness of initialization, and the best solution found is elected as the putative optimum.The resulting LQR weights, that is, diag(Q), are reported in Tables 10 and 11 for the longitudinal and lateral controllers, respectively, together with the elements of the gain matrices K y lon and K y lat obtained by the solution of the projective control problem.
Outer loops are modified with respect to Controller 1 in order to generate reference values on normal acceleration (a z ) and roll rate (p), still retaining the simple PID structure of Controller 1, and using the same design constraints of Table 6. Figure 8 shows the architecture of the outer loops of Controller 2.
Note that, in fact, the optimal design is carried out on the inner loops while performance metrics also depend on the characteristics of outer loops.In this respect, the gains of outer loops, reported in Table 12, are specified before the tuning of inner loops is carried out by GA, and their characteristics are compliant with the specifications in Table 6.It is also worth mentioning that the inner loops of Controller 2 satisfy the requirements of Table 5 in the design point.
At this point, it should be emphasized that GA is not the only population-based, derivative-free algorithm that could be used to solve a single-objective multi-modal unconstrained optimization problem as the one here discussed.Several meta-heuristic algorithms have been proposed to this end, among which Particle Swarm Optimization (PSO) [47], Differential Evolution (DE) [48], and Covariance Matrix Adaptation Evolution Strategy (CMA-ES) [49] are the best known, even though the list is far longer and keeps growing [50].One might be tempted to try all these algorithms to find out which one is the best.Unfortunately, it is not possible to determine which algorithm is the absolute best, as the "no free lunch" (NFL) theorem states that no algorithm can be always better than another one for all problems, and their performance is the same if averaged over a sufficiently large number of problems [51].In addition, the choice of the algorithm is as important as the choice of the hyper-parameters, and an extremely lengthy trial-and-error procedure would be required, while the potential benefits are usually modest.According to the authors' experience on similar problems [52], GA is one of the most robust algorithms with respect to hyper-parameter selection and was therefore adopted in this study.

IV. RESULTS AND DISCUSSION
Performance of the FCS featuring the optimally tuned controller (Controller 2) is assessed using the model illustrated in Section II.First, the FCS robustness is evaluated through the computation of the singular-value-based MIMO stability margins in multiple operating points across the flight envelope.The margins provide a simple and effective means for capturing the stability of the linearized UAV model.
Next, simulation tests are run with the objective of comparing the performances of Controllers 1 and 2 in terms of command tracking, disturbance rejection, control response, and robustness to model parameter variations.A simulation model featuring a simplified version of the FCS not including the EKF, where all sensor models generate measurements at a sample rate of 50 Hz, is used in a number of tests.In this respect, the principal goal is to enhance the understanding of control law behavior, when complexity is reduced by neglecting a dynamic element that requires a tuning process specific to each controller.Conversely, sampling at different rates and sensor fusion by EKF is featured in the simulation model in specific cases where the effects of reference signal variations and atmospheric turbulence are discussed and, in these circumstances, the same values of filter parameters are used for the two controllers.

A. STABILITY MARGINS
MIMO stability margins are computed by means of the singular values of return difference and stability robustness matrices across the frequency spectrum, using the KG openloop transfer function matrix, where K and G are, respectively, the transfer functions of controller and plant [20].The margins, evaluated in the speed range from 15 m/s to 40 m/s for the longitudinal and lateral controllers, are reported in Fig. 9 along with the design requirement (red lines) of Table 5. Figure 9(a) shows that positive and negative gain margins for the longitudinal control decrease as velocity increases, with the positive margin slightly below the threshold at high speed (V > 36 m/s), and the negative gain margin going to −∞ for V < 33 m/s.Conversely, the gain margins of the lateral controller are compliant with the requirements in the considered range of flight speed and, in particular, the positive margin is nearly constant up to a speed V > 35 m/s beyond which there is limited reduction, while the negative margin remains well below the threshold despite non-negligible variations with flight speed.As for the phase margins in Fig. 9(b), the longitudinal controller satisfies requirements up to V = 36 m/s, whereas the margin of the lateral controller is slightly below the limit of 45 deg for 21 The same MIMO margins of Controller 1, where K now denotes the transfer function of the inner loops on θ, φ and r (see Fig. 4), are shown in Fig. 10 in order to improve the clarity of comparisons between the two control methodologies.Controller 1 has lower stability margins than Controller 2 in a wide range of flight speeds.It is also worth noting that the design of Controller 1 was done in a sequential loop-by-loop manner and, as a result, the somewhat conservative MIMO phase margins for lateral control laws are lower than the specification.Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply. of 30 m/s is maintained during the maneuver.The time histories of longitudinal and lateral state and control variables are determined by UAV model simulation, with the FCS including the EKF, for two c.g. positions, i.e., the nominal one and the one shifted backward by 10% c so as to reduce the stability margin.It has to be remarked that, as expected, the filter degrades to some extent the performance of both controllers, with a major effect on Controller 1 as it will be discussed when the robustness to wind disturbances is analyzed.It is apparent that the performance of Controller 2 is much improved with respect to Controller 1 in terms of control activities.In addition, Controller 2 provides more limited variations in aerodynamic angles (α and β) in the dynamic phase of flight, and a more uniform transient response, as well as reduced steady-state altitude and heading errors.Small-amplitude oscillations, more pronounced for Controller 2, are visible in the plots of δ e and α for the case with c.g. shifted backward, due to the reduced stability of the system when the static margin K N of the model is decreased from 0.28 to 0.18.
In particular, the Nichols plot reported in Fig. 12 for the nominal (blue line) and backward (red line) c.g. positions, shows a phase margin reduction of 21 deg at the crossover frequency (0.41 Hz) in the latter case (10% rear shift), with negligible change in the gain margin.The result is a slightly larger amplitude of the short-period oscillations, whose natural frequency moves from 1.76 Hz to 1.34 Hz for the system controlled by the inner loop, while the effect of the outer loop on the rate of climb brings the same parameter down to about 1 Hz, as visible in the δ e and α plots of Fig. 11.It is worth noting that the reduction of control activity on ailerons and rudder realized by Controller 2 is a positive feature since high command rates cause considerable power consumption in the servos of small UAVs.
Controller performances with inactive EKF are compared in more detail in Fig. 13, where the L 2 -norm of the variations of control angles, and α and β with respect to their trim values for the two considered c.g. positions, normalized with respect to the norms calculated in the case of Controller 1 and nominal c.g. position, are shown.The reduction of α variations is realized by Controller 2 with an elevator activity similar to that of Controller 1.The decrease in the norm of δ e for both controllers is a result of the improved controllability associated with the lower static margin, while the effects on the other variables are negligible.

C. DISTURBANCE REJECTION
Response to wind disturbances is studied using, again, the full model of the UAV that includes the filter.During the simulation, in which the stochastic wind components in the NED frame are generated according to the low altitude turbulence model reported in [42] with an average wind  intensity of 6 m/s, the autopilot has the Command/Hold function engaged on the altitude (selected value h = 400 m), speed (V = 30 m/s), and heading (χ = 0 deg).Figure 14 shows that, in the presence of high-frequency disturbances, Controller 2 is more effective than Controller 1 since smaller tracking errors on altitude and heading are apparent, with a reduction in control effort at least for the elevator channel.
The L 2 -norms of perturbations (w.r.t.trim values) of the same variables, normalized with respect to the norms calculated for the implementation of Controller 1 without the filter (light blue line with unit values), are reported in Fig. 15.The aim is also to illustrate the effect of EKF on control performance since the filter is not considered in the design model and tuning process of Controller 2. The reduction of δ e control activity for Controller 2 in the case with EKF is confirmed along with the reduction of rudder and aileron control actions (blue vs. red line).Regarding the aerodynamic angle perturbations, a significant decrease of β is observed, while the norm of α is very close to the value obtained with Controller 1.This is explained when referring to the metrics in Eqs.(26) that penalize the infinite norms of aerodynamic angles, considering also that the lateral controller uses the a y acceleration component to manage (and limit) the values of sideslip angle.Of course, the effect of the optimal tuning on the angle of attack is somewhat hidden by the significant variation in α required for the prescribed maneuvers.
When reference is made to the Controller 2 performance in the case without EKF (orange line), higher L 2 -norms on δ a and δ r , and a lower value of the norm of δ e are apparent.The different behavior of Controller 2 in the two configurations is related to the reduction of the high-frequency component of turbulence realized by the filter on the roll rate signal (on which the error e of the inner loop in Fig. 6 depends), which limits the excitation of the inner loops and, consequently, the lateral control activity.On the contrary, the normal acceleration, i.e., the reference input of the longitudinal inner loop (Fig. 5), is not filtered, and the phase shift due to the EKF results in degrading the controller performance on the elevator action.Note that, as far as the outer loops are concerned, the EKF is also active in limiting high-frequency variations of the reference commands, since the altitude, (h), rate of climb (RC), heading (χ), and roll angle (φ) in Fig. 8 are all filter states.It is also worth noting that the longitudinal control activity is reduced for Controller 2 with little change in the L 2 -norm of the angle of attack according to the LQR tuning, where a limited control effort is searched for (Eq.12).On the other hand, despite the large weights on aileron and rudder commands resulting from the optimal LQR tuning for the lateral inner controller visible in Table 11, the requirement for sideslip angle minimization prevails, leading to the reduction of the β norm at the cost of an increased lateral control activity.
Figure 16 presents the results of a simulation performed with the objective of analyzing the system response under a condition where the static margin is as high as 1.21, which requires an elevator angle δ e = −19.5 deg to trim the UAV model at the initial velocity of 18 m/s.At t 0 = 10 s a step downward gust of 11 m/s occurs which decays as t 0 /t.In terms of instantaneous response, the disturbance causes a relevant reduction in the angle of attack and an increase in flight speed, resulting in intense control activity on the elevator and throttle, which, respectively, saturate at -25 deg and zero in a few seconds, trying to limit changes of V and h.Thereafter, a strong increment of the thrust is noted, as the throttle saturates at the maximum value (δ t = 1) in response to the significant reduction of flight speed, along with a 20 deg increment of δ e .Once velocity is recovered at about t = 25 s at the cost of a relevant increase in altitude (errors on V are corrected by throttle commands), the time histories show a poorly damped oscillation of longitudinal states during which the elevator control action is used primarily to balance the pitching moment due to propeller thrust.The strong coupling with the lateral degrees of freedom (see the large variations of heading χ and roll angle φ) is caused by the propeller torque.It is worth noting that, despite the expected degradation of performance, the UAV control is retained in a severe off-design situation where the c.g. is near the forward limit and the longitudinal commands are saturated.

D. MONTE CARLO SIMULATIONS
The evaluation of FCS performance, with particular attention to the effectiveness of the linear control laws implemented in the nonlinear model of the UAV, is also carried out through an extensive Monte Carlo (MC) campaign, in which a number of simulations are carried out for randomly generated inputs and/or parameters, and the outputs are assessed in terms of statistical properties or maximum/minimum values.Each of the 1,000 simulations starts with the model in a steadystate level flight condition, at an altitude h = 100 m, with speed randomly scattered between 16 and 40 m/s.Step inputs for the outer loops on altitude, heading, and velocity are assigned at t = 10 s, with amplitudes randomly chosen in the intervals 0 ≤ h ≤ 200 m, −180 ≤ χ ≤ 180 deg, and 16 ≤ V ≤ 40 m/s, respectively.By realizing large variations of the velocity vector in a wide region of the flight envelope, the relevant dynamics are excited for different values the of system parameters and, therefore, the evaluation of appropriate metrics provides a reliable and consistent representation of controller performance.
The two cases of the model with and without EKF are discussed to examine in more detail the effect of the filter on the behavior of the optimal controller.
Figure 17 shows the L 2 -norm and L ∞ -norm of the differences between time history and trim value of α and β, together with the overall control action for δ e , δ a , and δ r , evaluated for Controller 2 with filter active.The norms are averaged over all runs and normalized with respect to the same metrics computed when using Controller 1.Control performance in terms of L 2 -norm (Fig. 17(a)) is substantially improved by Controller 2, particularly with regard to the 63% decrease in sideslip angle along with the 21% and 22% reductions in control effort for ailerons (δ a ) and rudder (δ r ), respectively, while smaller changes are apparent on α and δ e .The more limited improvement of the L 2 -norm of longitudinal variables deserves comment: the variations of α and δ e are largely driven by the specified profile of flight speed so the advantage provided by the optimal controller is less obvious.Note also that the outer-loop logic on the flight speed requires elevator commands each time the throttle is varied, because of the pitching moment resulting from the offset of the thrust line with respect to the c.g.
The improvements of Controller 2 are more evident when considering the L ∞ -norms in Fig. 17(b) because, in terms of worst cases, the maximum values of β, δ a and δ r are reduced by 71%, 76%, and 69%, respectively.In addition, Controller 2 is able to limit the peaks of α and δ e by 35% and 31%, respectively, compared with Controller 1.When EKF is not present, slight increases in the above values, within the range 122268 VOLUME 11, 2023 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply. of 6%, are observed in the comparative performance of the two controllers.
Further insight into the characteristics of Controller 2 regarding, in particular, the behavior of outer loops is provided by Fig. 18, where rise time (RT), settling time (ST) and percentage overshoot (PO) are shown, for the response to step inputs at t = 10 s on velocity (Fig. 18(a)), altitude (Fig. 18(b)) and heading (Fig. 18(c)).The metrics reported in the figure are averaged over the MC runs and normalized with the results on the same quantities obtained by Controller 1.It is apparent that Controller 2 has a 35% increment of PO on speed response, while the two designs provide very close results on ST and RT.This can be explained by the fact that on one hand, the two controllers share the same outer loop structure on the velocity channel, but on the other hand, having vertical acceleration as the reference command of the inner loop of Controller 2, the response is slower.Consequently, the proportional gain of the velocity loop of Controller 2 (first row in Table 12) must be increased by 30% compared to that of Controller 1, which results in a higher PO.Note also that the vertical acceleration is an output of the IMU, not processed by the EKF, while the input variables of the longitudinal inner loops of Controller 1 are all filtered.
Controller 2 achieves a slightly smoother response on altitude (barely visible in the simulation of Fig. 11) albeit with 12% and 5% increases in RT and ST, respectively, and shows a faster and more accurate response on the heading (27% and 8% reductions of RT and ST, respectively) with a smaller (5%) increase in PO.The results for the case with off-line EKF are shown in Fig. 19 for the flight speed and altitude, as the changes in the same metrics for heading are negligible.As noted above, the performance of the two controllers on the speed channel is closer, while RT and PO on altitude response are slightly higher (3% and 14% increments, respectively), compared with the situation with EKF on).
To study the robustness of the optimal controller to model uncertainty, a second campaign of 1,000 MC simulations is conducted by scattering inertial and aerodynamic parameters along with the static margin, as reported in Table 13.The flight task is a combined climb of h = 50 m and right turn of χ = 90 deg at constant velocity V = 30 m/s. Figure 20 shows the L 2 -norm and L ∞ -norm of the variations of α, β, δ e , δ a , and δ r with respect to the trim values, normalized as mentioned above.It appears that Controller 2 is more robust than Controller 1 to the large variations in the parameters considered, although the latter is still able to maintain control of the vehicle at the cost of much higher values of maximum aerodynamic angles and significantly more control activity.This is consistent with the higher stability margins of Controller 2 already observed in Figs. 9 and 10.In particular, the results shown in Fig. 20(a) demonstrate the improvement of Controller 2 in terms of lateral control activity and sideslip angle reduction, with a negligible change (−2%) in elevator activity and α norm, as the behavior of angle of attack is somewhat prescribed in the steady-state sections of the considered sequence of maneuvers.The L ∞ -norms of δ e , δ a , and δ r in Fig. 20(b) present a reduction of 30%, 75%, and 68%, respectively, for Controller 2, with α and β maximum reduced by 45% and 74%, respectively.

V. CONCLUSION
In this paper, an optimal tuning procedure has been proposed with the aim of improving the performance and robustness of the control system of a lightweight UAV, designed according to the methods of robust linear quadratic servo linear regulator (RSLQR) and static projective control (SPC) while maintaining low system complexity, consistent with the type of application envisaged for small, low-cost fixed-wing unmanned systems.
The tuning is based on a genetic algorithm (GA) to find the weights for solving the LQR problem.The fitness function is specified in terms of a set of appropriately defined performance metrics, evaluated directly by nonlinear simulation of the flight of a high-fidelity UAV model along a complex trajectory.The reference inputs of the outer loops are specified so that the performance, dynamics, and response characteristics of the vehicle and flight control systems, upon which the cost function depends, are taken into account in wide areas of flight and maneuver envelopes.
The effectiveness and suitability of the proposed procedure have been analyzed through a comparative evaluation of the GA-tuned control system and the UAV PID controller.Specific simulations have been performed to analyze the control response characteristics and wind disturbance rejection.The results show that the optimal controller provides improvements in terms of stability and performance robustness as well as reducing tracking errors when the vehicle operates in turbulent wind conditions.The FCS is also able to maintain control of the vehicle under limiting conditions with longitudinal control saturation.
Monte Carlo analyses have been conducted, in which a rather complex and representative mission has been simulated, spanning several points of the flight envelope and presenting a series of maneuvers in the vertical and horizontal planes, taking into account the effects of initial flight speed, autopilot controls, and large modeling errors, such as a 10%c backward shift of the c.g. position, and variations up to ±30% in the inertial parameters (mass and moments of inertia) and aerodynamic coefficients.The test confirms the overall improvement of the closed-loop performance and, in particular, the comparative analysis shows that the lateral control activity is significantly reduced and the maximum values of aerodynamic angles are limited.The optimally tuned and robust control system again achieves superior performance compared with the current PID-based controller in the presence of model uncertainty and is less sensitive to the effects of sampling at different rates and filtering of measured feedback variables for both inner and outer control loops performed in the real FCS.
The proposed GA optimization scheme provides a highly effective tuning solution for RSLQR design and appears suitable for reducing the problems and burden of trialand-error manual procedures often adopted for the design of linear controllers for low-cost lightweight UAVs.The methodology requires the GA to be performed offline, and the controller does not include adaptive features at this stage.The computational cost of the control algorithm is identical to that of a controller adjusted by traditional techniques, and the autopilot, including the EKF, is implemented and runs smoothly at 50 Hz on a Teensy® 4.1 Developer Board by PJRC.
The design method allows the solution of the tuning problem to be automated, using an inner loop synthesis technique that can handle model uncertainty better than PIDs, and can be easily applied to different airframes provided that a realistic simulation model of the vehicle is available, and a number of cost function parameters are specialized for the performance characteristics of the vehicle.

APPENDIX: LATERAL SERVOMECHANISM MODEL
The SM model for the lateral controller synthesis, developed under the assumption that (1− I 2 xz I x I z ) ≃ 1, is written as Eq. ( 28), shown at the top of the next page, where the symbols for dimensional derivatives are standard [41,Ch. 4], and 122270 VOLUME 11, 2023 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
are 30 deg and −25 deg for elevator and rudder, and 25 deg and −20 deg for ailerons, while the angular rate of all servos saturates at 50 deg/s.The sensor suite is composed of an absolute pressure sensor (Bosh ® BPM 280) with an integrated digital thermometer used as a barometric altimeter, a Honeywell ® differential pressure sensor transducer with ±5 inH 2 O range for the indicated airspeed (IAS), an Xsense ® 28A54G35 122256 VOLUME 11, 2023

FIGURE 3 .
FIGURE 3. Sketch of the simulation model architecture.TABLE 5. Inner loop requirements for Controller 1.
τ )dτ = e I x e I e I − K x lon x lon
[a y , p, r, δ a , δa , δ r , δr ] T , where the symbols have the known meaning.The state-space form of the lateral SM is reported in the Appendix, and the inner loop uses the error on roll rate e lat = p − p cmd to generate the commands δ cmd a and δ cmd r on ailerons and rudder, respectively.The SPC method gives the control law as δ cmd a of δ cmd r of T = −K y lat y lat (17) where y lat = e lat p r a y T = C lat z lat , with C lat = [I 4×4 0 4×4 ] and z lat = e lat x T lat T .The gain matrix combined descent (− h) and left turn (− χ) at V HS .Figure7shows (left) the plots of the commanded (red dashed lines) and computed through simulation (blue continuous lines) values of the reference variables V , h, and χ, together with (right) the trajectory flown by the UAV model.The maneuver parameters are h = 50 m, χ = 90 deg, V LS = 16 m/s, V HS = 40 m/s and, for the initial times of the different phases: t

FIGURE 7 .
FIGURE 7. Flight profile for controller tuning: (left) commanded (red dashed lines) and computed (continuous blue lines) values of reference variables; (right) computed trajectory.

FIGURE 8 .
FIGURE 8. Sketch of the outer loops for Controller 2.
B. COMMAND TRACKINGIn Fig.11the responses to commanded altitude and course variations of 50 m and 90 deg, respectively, at t = 10 s, are shown for the two controllers.A constant flight speed 122264 VOLUME 11, 2023

FIGURE 11 .
FIGURE 11.Response to commanded altitude and heading variations in the nominal case and with 10% c backward shift of the c.g.: Controller 1 (light blue and blue lines, respectively) and Controller 2 (orange and red lines, respectively).

FIGURE 13 .
FIGURE13.L 2 -norm of control activity and aerodynamic angles in response to commanded altitude and heading variations; EKF is off-line.

FIGURE 14 .
FIGURE 14. Response to wind disturbances: time histories of state and control variables for Controller 1 (blue line) and Controller 2 (red line) with EKF.

FIGURE 15 .
FIGURE 15.Response to wind disturbances: L 2 -norm of control activity and aerodynamic angles in response to the atmospheric turbulence.

FIGURE 16 .
FIGURE 16.Controller 2: response to a gust disturbance with a forward shift of the c.g. (K N = 1.21).

FIGURE 17 .
FIGURE 17. L 2 -norm (a) and L ∞ -norm (b) of control activity and aerodynamic angles from the MC campaign with EKF: Controller 1 (blue line), Controller 2 (orange line).

FIGURE 18 .
FIGURE 18. Normalized response to step inputs (t = 10 s) on V , h, and χ from the MC campaign with EKF: settling time (ST), percentage overshoot (PO), and rise time (RT) for Controller 1 (blue line) and Controller 2 (orange line).

FIGURE 19 .
FIGURE 19.Normalized response to step inputs (t = 10 s) on V , h, and χ from the MC campaign without EKF: settling time (ST), percentage overshoot (PO), and rise time (RT) for Controller 1 (blue line) and Controller 2 (orange line).

FIGURE 20 .
FIGURE 20.L 2 -norm (a) and L ∞ -norm (b) of control activity and aerodynamic angles for MC simulations with scattered model and EKF parameters.
Y r P r + Y p P p ; A r = Y r R r − u e Y v + Y p R p ; A R = Y r R R + Y p P R ;

TABLE 2 .
Constant coefficients in the aerodynamic model.

TABLE 3 .
Error model parameters: First set.

TABLE 4 .
Error model parameters: Second set.

TABLE 9 .
Reference values and parameters for performance metric evaluation.

TABLE 10 .
Controller 2: Elements of Q matrix and gains for the longitudinal control loop.

TABLE 11 .
Controller 2: Elements of Q matrix and gains for the lateral control loops.

TABLE 13 .
Nominal values and scattering range of selected parameters.