# Discrete Integral Optimal Controller for Quadrotor Attitude Stabilization: Experimental Results
## 4 Experimental Results
### 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)\), \(\psi(k)\), \(x(k)-\theta(k)\) and \(y(k)-\phi(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 \(\mathcal{Q}\) and \(\mathcal{R}\), which have been assigned as bellow.  
For the system \(z(k)\), the two matrices are defined by  
\[\mathcal{Q}_{z}=\begin{bmatrix}50&0&0&0\\ 0&1&0&0\\ 0&0&1&0\\ 0&0&0&1\end{bmatrix},\quad\mathcal{R}_{z}=[490]\]  
while matrices used to penalize the subsystem \(\psi(t)\) are chosen as:  
\[\mathcal{Q}_{\psi}=\begin{bmatrix}18&0&0&0\\ 0&171&0&0\\ 0&0&0.1&0\\ 0&0&0&1\end{bmatrix},\quad\mathcal{R}_{\psi}=[180]\]  
For the subsystems \(y\)-\(\phi\) and \(x\)-\(\theta\), the penalization matrices are:  
Figure 5: System variable block diagram.  
\[\mathcal{Q}_{\psi\phi}=\mathcal{Q}_{x\theta}=\begin{bmatrix}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\end{bmatrix}\]  
\[\mathcal{R}_{x\theta}=[40],\quad\mathcal{R}_{y\phi}=[31]\]  
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_{ref}(t)=y_{ref}(t)=0\) m, and altitude \(|z(t)|\) is chosen as \(z_{ref}=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 \(\theta ref=\theta ref=\eta ref=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.  
Figure 8: Numerical approximations of \(\dot{x}(t)\), \(\dot{y}(t)\), \(\dot{z}(t)\) from UAV when the OIC was used.  
Figure 10: Numerical approximations of pitch, roll and yaw angular velocities of the UAV when applying the OIC.  
Figure 9: Numerical approximations of pitch, roll and yaw angles of the UAV when using the OIC.  
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.