Discrete Integral Optimal Controller for Quadrotor Attitude Stabilization: Experimental Results

: The Unmanned Aerial Vehicle (UAV) attitude stabilization problem has been dealt with in many previous works through applying a vast range of philosophies of control strategies. In this paper, a discrete controller based on a Linear Quadratic Regulator (LQR) plus integral action is synthesized to stabilize the attitude and altitude of a quadrotor helicopter. This kind of control strategy allows us to reduce the energy consumption rate, and the desired UAV behavior is properly achieved. Experimental tests are conducted with external disturbances such as crosswinds deliberately added to affect the performance of the aerial vehicle. This provides experimental evidence that the integral part considered in the proposed control strategy contributes to improving the performance of the vehicle under external disturbances. In fact, a comparative analysis of potential and kinetic energy consumption is developed between the Optimal Integral Controller (OIC) and a Proportional Integral Derivative Controller (PID), allowing us to determine the level of improvement of the closed-loop system when the discrete Integral Optimal Controller is applied.


Introduction
In recent years, several works have been reported in the literature addressing the application of optimal control of quadrotors [1,2].However, this issue remains interesting to the scientific community because it represents a current challenge from the point of view of control theory and engineering (mainly its real-time applications).Many techniques related to optimal control philosophy have been applied to UAVs, but this paper proposes to add an integral action to Linear Quadratic Regulator, in order to improve the performance of the closed-loop system.Moreover, both the mathematical model and synthesized control strategy are obtained in discrete time domain, ensuring a better representation to be programmed in a microcontroller such that Rabbit 4300.In this sens, recent reported works have demonstrated that it is possible to ensure the stability in discrete-time domain for multi-input-multi-output (MIMO) systems.This has been achieved through a generalization of the Letov formula, as mentioned in [3].
A typical control strategy with integral action is the Proportional-Integral-Derivative (PID) controller, which is widely used in industrial processes and devices because it can be heuristically tuned independently of the mathematical model of the system and can be used in both linear and nonlinear systems.However, there also exist many graphical and theoretical methods to tune it considering the dynamical behavior or the mathematical model of system.
It is well known that the integral action of a PID controller provides a correction for steady-state tracking error even in the presence of uncertainties [4], providing some degree of robustness to the control loop.Although this three-action controller is a powerful idea, sometimes it is not efficient or appropriate for a specific tasks.Then, it can be improved by modifying the control parameters with an adaptive scheme or by adding a nonlinear part.
This contribution uses the advantages of the integral action of the PID controller combined with modern control techniques through regulation via optimal control in order to improve the performance of a quadrotor when it executes an attitude and altitude stabilization task.Integral control applied to Unmanned Aerial Vehicles has been explored in some reported works.An integral predictive and nonlinear robust control strategy was synthesized in [5], wherein the authors solve the path-following problem for a quadrotor helicopter.The proposed control structure has a hierarchical scheme consisting of a model predictive controller to track the reference trajectory together with a nonlinear H ∞ controller to stabilize the rotational movements of the considered vehicle; satisfactory simulation results were presented.In [6], an Integral Backstepping controller and motion planning are combined to stabilize the helicopter using point-to-point steering stabilization.Simulation results were presented to test the performance of the closed-loop system and its robustness.The same technique was presented in [7]: the goal of this work was to stabilize the attitude, altitude, and position of the vehicle.Satisfactory results for autonomous take-off, hover, landing and collision-avoidance tasks were presented, and all were validated on the OS4 simulation platform.
In addition, a comparison between PID, Linear Quadratic Regulator (LQR) and nonlinear controllers (Adaptive Integral Backstepping Controller) was exposed in [8].A nonlinear control approach was proposed based on a recursive Lyapunov methodology using the Backstepping technique and an adaptive scheme.Satisfactory simulations and real-time experiments were conducted.In [9], LQR continuous control was used to stabilize the attitude and altitude of an Octocopter.Numerical simulations demonstrated the effectiveness of the control strategy under nominal conditions, and the authors improved the LQR by adding integral action to the altitude controller.In [10], once again an LQR methodology and integral state augmentation were adopted to achieve the desired performance of the control system.The unmeasured state variables were estimated by means of a reducedorder observer.Satisfactory simulation results for the UAV helicopter were presented.Toledo et al. [11] conducted similar work in which they used a control scheme based on Integral Backstepping with sliding modes applied to a multi-rotor vehicle.This control methodology was experimentally tested using the vision system Optitrack.Results were reported for the altitude z and displacement on the xand y-axes.However, no analysis of energy consumption was presented, nor were real-time tests with external disturbances conducted and reported.In [12], Elkhatem published LQR and LQR-PI controllers that are applied to a quadcopter.The high performance and robustness of the Linear Quadratic Regulator controllers ensure the ability to reduce deviations in state trajectories with minimal control effort.In this work, the weighting matrices are automatically adjusted through a novel method using the full state of the flying robot.Feasibility and performance of the closed-loop system is only tested by simulation routines.
In the literature, it is possible to find documents in which the LQR technique is combined with other types of controllers, such as fuzzy controllers.For example, in [13], Malik presents the development of a longitudinal controller design for an autonomous unmanned aerial vehicle (UAV).In this work, the researchers proposed a dual-loop (innerouter loop) control method based on intelligent algorithms.The inner feedback loop of controller uses a Linear Quadratic Regulator (LQR) to ensure adaptive stability.Meanwhile, the outer loop controller employs a Fuzzy-PID algorithm for deal with the trajectory tracking task.
Moreover, neuro-fuzzy controllers have also been recently used for the control of UAVs.In [14], Jinjun Rao et al. developed a position control approach for a quadrotor using a cascade Fuzzy Neural Network (FNN).This approach requires offline neural network training, combining the benefits of fuzzy systems and neural networks.According to authors, this fuzzy control strategy demonstrated its ability to minimize the overshoot and the settling time.This was tested by conducting flight simulations and real-time flights using a DJI Tello quadrotor UAV, showing an acceptable position control performance.In fact, one of advantages of neuro-fuzzy controllers is their ability to handle nonlinear systems, which offers better adaptability.Particularly, the controller architecture proposed in that work allows to optimize the use of the robot's energy resources and also providing robustness to the control loop.Also, this produces a balance between adaptability and efficiency, making it particularly useful for UAV applications where energy efficiency and robust control are crucial.That type of controller can also be used in other fields such as the study of seismic structural control.In this field, the contributions reported works by Abbas and his collaborators in [15][16][17] should also be mentioned, they use neuro-fuzzy controllers and a PID controllers to tackle both stabilization and trajectory tracking task for aerial robots.
In this contribution, UAV stabilization is tackled using a controller that combines an optimal strategy (LQR) with the integral action.A difference from other reported works such as [5,9,10,12] is that this optimal synthesized controller is tested in a real-time setting, providing experimental results for the altitude stabilization problem in a fourrotor helicopter.To control the position and orientation of the vehicle, the system was subdivided into four subsystems, as was proposed in [18], and the integral action is added as an additional state variable [4] in the four subsystems.A previous exact linearization was performed on the dynamical model in order to remove the Coriolis terms and transform the rotational dynamics in the second-order differential equation depending on external torque inputs.So for control of the altitude and attitude of the UAV, four optimal controls with integral action are proposed: one for each subsystem.The controllers for rotational dynamics are synthesized using the assumption that pitch, roll and yaw are inside a bounded region around the origin, which is an equilibrium point for this aerial vehicle.The proposed optimal control strategy assumes that all state variables are available.Our proposal is experimentally tested in takeoff and altitude stabilization tasks.An Optitrack vision system is used to obtain the whole state of the vehicle, and satisfactory results are obtained when the optimal discretized controller with integral action is applied.
So the main contributions of this work are: 1. Synthesis, analysis and implementation of Optimal Integral Control (OIC) tuned under the QR approach and applied to trajectory tracking of takeoff and hover flight of UAVs.

2.
Experimental validation of the OIC by real-time tests in the presence of induced crosswind disturbances applied during the trajectory tracking of takeoff and hover flight of a UAV, allowing the analysis of the robustness of the closed loop with the proposed control scheme.

3.
Comparison of the kinetic and potential energy between the PID and the Optimal Integral Control when a trajectory tracking task is executed for the take-off and hover-flight phases of the UAV in the presence of induced crosswind.
The paper is organized as follows: The nomenclature and symbols used throughout this document are presented in Section "Nomenclature", while the introduction is reported in Section 1.Moreover, Section 2 is devoted to showing the mathematical model of the UAV together with the synthesis of the proposed control law.In Section 3, the experimental platform is shown.Real-time experimental results are displayed in Section 4, and finally, the conclusion and discussion are reported in Section 5.

Control Strategy
In this section, we synthesize the proposed optimal controller with integral action added.Firstly, some basic concepts about integral control are briefly recalled in order to set up a discrete time control strategy to be applied to a quadcopter.

Integral Control
Consider the nonlinear system: where the state x ∈ R n , and the vector control u ∈ R p .The variables f and h are continuously differentiable functions in a domain D x × D u ⊂ R n × R p , and y ∈ R p is the controlled output.Let y R ∈ R p be a constant reference; the integral control is a feedback state such that Assume that the controlled output y can be measured.Note that for our case y = x because when using the Optitrack vision system, the complete state is measurable and therefore available.The regulation task will be achieved by stabilizing the system at an equilibrium point where y = y R .In order to maintain it in that equilibrium condition, there exists a pair (x ss , u ss ) ∈ D x × D u such that: Assume that these equations have a unique solution (x ss , u ss ).Now, the integral action is included as follows: consider the tracking error e = y − y R .Then, the following equivalence is defined .σ = e = y − y R , So control will be obtained as a feedback function of x and σ such that in the closed loop there is an equilibrium point (x, σ) with x = x ss .Assuming that the system is linearizable around x ss , σ, u ss , it follows that: . with Assume that the pair (A, B) is controllable and Then (A, B) is controllable [4].Then, design a matrix K such that A + BK is Hurwitz [4].Consider the partition for the matrix K as [K 1 K 2 ].The control signal is then defined by: It is not difficult to verify that the closed-loop nonlinear system has a unique equilibrium point (x ss , σ ss ) [4].As is demonstrated in [4], the equilibrium point (x ss , σ ss ) is exponentially stable, and all solutions starting close enough to this equilibrium point approach it as t tends to infinity.Then y(t) − y R → 0 as t → ∞.Following these ideas, in this contribution, the matrix K is designed using the optimal control approach.For altitude, we take advantage of the fact that in the mathematical model for the altitude of the quadrotor, it can be stabilized by exact linearization, and then, it is not necessary to linearize the nonlinear dynamics.The integral action is used to minimize the effects of external disturbances on vehicle performance.Figure 1 shows the basic scheme for the control of integral action.

Mathematical Model of the Quadrotor
The following assumptions are considered in this paper to obtain a simplified version of the mathematical model of a vehicle [7,18] 1.
The quadcopter is a rigid and symmetric body.

2.
The center of gravity of the vehicle coincides with the origin of the body frame.

3.
The propellers are rigid and have a fixed pitch.

4.
At low velocities, aerodynamic effects can be neglected.
The dynamical model considered is that reported in [19,20] with the following structure: where x and y are the displacements in the horizontal plane, z is the vertical position, ψ is the yaw angle around the z-axis, θ is the pitch angle relative to the y-axis, and φ is the roll angle around the x-axis.The control inputs are: u, τ φ , τ θ , and τ ψ , with u the collective throttle generated by the four motors to lift the UAV; τ φ , τ θ , and τ ψ are the torques generated around the axes x, y, and z, respectively.
Here, the authors have assumed that there exists a previous controller τ = C(η, η) η + Jτ (see the mathematical model given by Equations (2.4) and (2.5), p. 34 of [18]), where η = (φ, θ, ψ) T is the angular position vector, C(η, η) is the Coriolis terms matrix, and J is the inertia matrix.With this control, we arrive at the last three equations of the mathematical model given by (2), which define the resulting rotational dynamics τ = (τ φ , τ θ , τ ψ ) T .Figure 2 shows a schematic representation of the positions and angles of the quadrotor.Now, in order to obtain a discrete space state representation of the mathematical model of a flying robot, the following state variables are defined: and discretizing the related continuous model by applying the Euler approximation considering a sampled period T, it becomes: All of the above was performed in order to apply a digital version of a synthesized optimal controller with integral action to a quadrotor helicopter.

Discrete Model and Integral Control
As mentioned previously, the mathematical model can be subdivided into four subsystems: subsystem z(k), ψ(k), x(k) − θ(k) and y(k) − φ(k).For subsystem z(k), we have: Now, we use an exact linearization as follows: with these control laws for each subsystem, which are linear and are defined as: where , and e 2z (k) x 2z (k) − x 2zR (k); these are the errors for x 1z (k) and x 2z (k), respectively, and x 1zR (k) and x 2zR (k) are the references.The augmented system for the subsystem z(k) is: It is not a difficult task to verify that the pair (A z , B z ) is controllable in a finite number of steps.Define the following performance index: where Q z is a semidefinite positive matrix of appropriate dimensions and R z is a real positive number.As the pair (A z , B z ) is controllable, there exists an unique solution to the Riccati equation given by: and the solution P z describes the optimal control for the subsystem z(k) given by: The discrete model for ψ(k) is given by: Let x 11 (k) x 1ψ (k) and x 12 (k) x 2ψ (k); then, the subsystem ψ(k) can be rewritten as: , where x 1ψR (k) and x 2ψR (k) are the given references for the variables x 1ψ (k), x 2ψ (k), respectively.Then, the augmented vector for the subsystem ψ(k): The space state representation of the augmented system is: where: Consider the performance index: with an appropriate dimension matrix Q ψ ≥ 0 and a real R ψ > 0. As the pair (A ψ , B ψ ) is controllable in a finite number of steps, the optimal control law with integral action is given by: where matrix P ψ is the unique solution to the algebraic equation: For the subsystem y-φ(k): The control u(k) was defined as an exact linearization, and the optimal control u * 1 (k); then, the second equation is given by but u * 1 (k) tends to zero when k tends to infinity.Then, there exists n ∈ Z + such that for all k ≥ nT, u * 1 (k) is bounded and neglected; it follows that: Let there be a control law τ φ (k) that guarantees that tan x 7 (k) ≈ x 7 (k); therefore, x 4 (k + 1) = gTx 7 (k) + x 4 (k).Having this idea in mind, consider the following definition: with this definition, the space state representation of the linearized system is: In order to use the discrete integral control, define the errors: where x 1yR (k), x 2yR (k), x 3φR (k) and x 4φR (k) are the references for the variables x 1y (k), x 2y (k), x 3φ (k) and x 4φ (k), respectively.Then, the augmented state vector for the subsystem y-φ is given by: where C yφ = TI 2 .As the pair (A yφ , B yφ ) is controllable, there exists an optimal control law τ * φ (k) which minimizes: where matrix Q yφ ≥ 0 has appropriate dimensions and the real R yφ > 0. The matrix P yφ is the unique solution to the algebraic equation: A similar procedure is used to obtain the optimal control τ * xθ (k) for the subsystem x-θ: where: The augmented vector is: and the following performance index is minimized: where Q xθ ≥ 0, R xθ > 0 and P xθ is the solution to the algebraic Riccati equation: and These controllers were tested on an experimental platform described in the next section.
Remark 1.The OIC strategy combines two advantages of the PID and LQR control approaches: the integral part of the error and the penalization of the energy consumption and convergence of the state, respectively.In contrast to the suboptimal nonlinear discrete control approach [21], which penalizes the energy consumption and convergence of the state with state feedback plus an offset, the OIC substitutes the offset part by the integral part, which provides more robustness in a closed loop in the presence of external disturbances.

Experimental Platform
As shown in Figure 3, the experimental platform setup uses an Optitrack Flex 3 vision system to compute the UAV's position and orientation.The UAV has 6 markers, which are looked at by 12 cameras; the information generated by the cameras is sent to Motive software using the USB protocol.This information is sent to Visual C++ software from Motive software using sockets; it allows to compute in C++ lenguage the integral control laws applied to stabilize the UAV at hover.The PC and UAV are communicated via RS-232 wireless protocol through two Xbee Pro S1 modems at 38,400 bits per second.Furthermore, a Futaba RF radio control is used for manual wireless control of the quadcopter, acting as emergency control if a risk situation occurs in the UAV.
Figures 3 and 4 show how a Parrot's frame was used to build the platform's quadrotor.The UAV has an embedded Rabbit module RCM4300, one inertial measurement unit (IMU)3DM-GX3 from MicroStrain, one radio receiver and one Xbee Pro S1 modem.
The vision system obtains the position and orientation of the UAV: x(k), y(k), z(k), θ(k), φ(k) and ψ(k).The velocity of each variable is estimated using Visual C++.Integral control laws are computed in the same way: u PC (k) (height control computed by the PC), τ φPC (k) (roll control computed by the PC) and τ θPC (k) (pitch control computed by the PC); these control signals are sent from the PC to the Rabbit microcontroller via RS232 wireless protocol using Xbee modems.The Futaba RF radio generates calibration signals u c (k), τ φc (k), τ θc (k) and τ ψc (k); the first one gives an offset of the z(k) position to compensate for gravity; the last ones give orientation offsets of the UAV's θ(k), φ(k) and ψ(k), respectively.In this way, the UAV's orientation and height position are calibrated.RF radio signals are

Experimental Results
Two experiments were conducted: The first considers the trajectory tracking problem during takeoff and hover flight using an OIC controller in the UAV.The second one addresses the trajectory tracking problem during takeoff and hover flight by applying the PID and OIC controllers and incorporating crosswind disturbances to the UAV.

Implementation of Optimal Integral Control Algorithm in the UAV
By combining the Linear Quadratic Regulator (LQR) controller and the Integral Controller (IC), which is the main idea presented in this research work, an Optimal Integral Controller (OIC) is generated.The aforementioned is possible by applying an exact linearization to the model of the Unmanned Aerial Vehicle (UAV) presented in [20].The process corresponding to this step is described in detail separately in Section 2.3 from a mathematical perspective.As can be seen, a discrete representation of the model is required for each subsystem of the aerial robot.
The mathematical model of the robot described in Section 2.2 is divided into four subsystems.For each of these subsystems z(k), ψ(k), x(k) − θ(k) and y(k) − φ(k), the integral control structure shown in Section 2.3 is applied, and the Riccati-type algebraic equation is numerically solved for every discretized subsystem.This is done considering the augmented penalty matrices Q and R, which have been assigned as bellow.
For the system z(k), the two matrices are defined by while matrices used to penalize the subsystem ψ(t) are chosen as: For the subsystems y-φ and x-θ, the penalization matrices are: 9 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 To test the OIC (Integral Optimal Control) algorithm, it is applied in a controlled environment to the UAV.Tracking a takeoff trajectory and maintaining hover flight with the UAV is described by the following conditions: The experiments consider a sampling period of T = 50 ms, set points of translation positions are selected at x re f (t) = y re f (t) = 0 m, and altitude |z(t)| is chosen as z re f = 0.45t until 0.3 m; once this altitude value is reached, the helicopter then remains there.Set points related to orientation are fixed at θre f = φre f = ψre f = 0 deg.
The figures shown below were obtained from the real-time experimentation.Firstly, Figure 6 shows the translational position x(t), y(t), z(t) behavior versus their respectively set points when the Integral Optimal Controller is applied to the quadrotor helicopter.Errors in those translational variables are shown in Figure 7.Moreover, the translational velocities related to each of the axes are shown in Figure 8.The pitch, roll and yaw orientations are shown in Figure 9; angular rates for all orientation variables are shown in Figure 10.The torque control signals are shown in Figure 11, the force control signal is shown in Figure 12, and these control signals are calculated using the integral control algorithm in the discrete quadcopter model.The quadrotor trajectory is shown in Figure 13; this trajectory was subdivided into three trajectories for takeoff, flight and landing of the UAV.In the blue line, one can observe the UAV's takeoff, while the hover flight of the robot is represented in dark green, and the landing phase is visualized in light green.Each set of points signifies the division of the overall trajectory into these three phases: takeoff, flight, and landing.

Robustness Test under Crosswind Conditions
Additional experiments were conducted to test the robustness of the integral control strategy.This experiment allows to evaluate how the robustness provided by the integral action affects the UAV's flight performance.So, a fan is used to apply a crosswind to aerial platform with a velocity of 4.3 m/s (at 19 • C).This external disturbance was supplied to the system from 50 to 150 s.These conditions were used for both PID and OIC controllers.Figure 14 shows the translational position behavior of the vehicle under this crosswind condition.
Moreover, Figure 15 shows the position errors experienced by the four-rotor rotorcraft, and Figure 16    Force u(t) (N) u(t) . Force control signal u(t) using the OIC applied when the quadcopter was disturbed.

Comparative Analysis of Energy Consumption between OIC and Conventional PID Controller
This experimental protocol enables a detailed evaluation of the efficacy of the integral control algorithm within an LQR control system applied to UAVs, providing empirical evidence of its performance, robustness and energy efficiency compared to a conventional PID controller.Total energy consumption was computed using potential and kinetic energies.This calculation was performed for both the tuned heuristic PID controller and the OIC optimal controller proposed in this research work.The total energy behavior for each scenario is illustrated in Figure 18.Furthermore, Table 1 presents the electrical energy savings comparison between the controllers.These data were derived from a series of 30 experiments.
As evident in Table 1, the OIC (Optimal Integral Controller) improved the electrical energy consumption by 53.05% compared to a conventional PID controller.This proves that the use of a LQR (Linear Quadratic Regulator) controller in conjunction with integral action can save energy in a four-rotor aerial robot.In addition, it provides robustness to the control loop, enabling it to absorb unmodeled dynamics or external disturbances, as has been demonstrated in Section 4.2.Although these experiments were conducted in a controlled environment, it is clear that the control algorithm will work efficiently in outdoor flights, proving that the robot state approximation is accurate and the robot model is correctly parameterized.

Conclusions
Satisfactory experimental results using integral control are obtained.So, can be stated that the Optimal Integral Controller (OIC) improves the LQR controller behavior, because it includes an integral term.Moreover, the tuning of integral action can be optimally conducted by solving the discrete Riccati Algebraic Equation associated to LQR problem, allowing to penalize the energy consumption and the convergence rate of the state.According to optimal control theory, the exact linearization applied to the altitude and yaw subsystems allows for stability of the closed loop, and then it is guaranteed.For the subsystems y-φ and x-θ, although the optimal control obtained was synthesized using a linearized model, the experimental tests show the robustness of the controller, and the real-time results show an important energy savings rate.So using this strategy, it is possible to achieve proper UAV stabilization for both attitude and position.As future work, it is intended to apply this control strategy in external environments to verify the robustness and efficiency of the algorithm in outdoor flights.This will be carried out on a UAV with the same configuration as proposed in this investigation.Other future work includes experiments in a wind tunnel to evaluate the discharge time of the battery in order to compare the performance of the controllers more accurately.

Figure 2 .
Figure 2. Positions and angles of the UAV.

Figure 9 .Figure 10 .
Figure 9. Numerical approximations of pitch, roll and yaw angles of the UAV when using the OIC.

Figure 11 .Figure 12 .
Figure 11.Numerical approximations of torque control signals using the OIC.

Figure 13 .
Figure 13.Full 3D path of the UAV using the OIC.
depicts the control signals applied in real time.The magnitude of the control signals shows the feasibility of integral control.Finally, Figure17 shows the force generated by the control signal u(t) (corresponding to the collective throttle) when the flying platform was subjected to wind disturbances.

Figure 15 .Figure 16 .
Figure 15.Numerical approximations of position errors of the quadcopter when it was disturbed.

Figure 18 .
Figure 18.Total energy consumption comparison using a PID controller and the OIC.
Numerical approximations of the position errors e x (t), e y (t), e z (t) when the OIC was applied to the UAV.