# Discrete Integral Optimal Controller for Quadrotor Attitude Stabilization: Experimental Results
## 2 Control Strategy
### 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.
5. The angles are restricted: \(-\pi/2<\phi<\pi/2,-\pi/2<\theta<\pi/2\) and \(\psi=0\).  
The dynamical model considered is that reported in [19; 20] with the following structure:  
\[\begin{array}{c}m\,\ddot{x}=-u\sin\theta\\ m\,\ddot{y}=u\cos\theta\sin\phi\\ m\,\ddot{z}=u\cos\theta\cos\phi-mg\\ \ddot{\phi}=\tau_{\phi}\\ \ddot{\theta}=\tau_{\phi}\\ \ddot{\psi}=\tau_{\phi},\end{array} \tag{2}\]  
where \(x\) and \(y\) are the displacements in the horizontal plane, \(z\) is the vertical position, \(\psi\) is the yaw angle around the \(z\)-axis, \(\theta\) is the pitch angle relative to the \(y\)-axis, and \(\phi\) is the roll angle around the \(x\)-axis. The control inputs are: \(u\), \(\tau_{\phi}\), \(\tau_{\phi}\), and \(\tau_{\phi}\), with \(u\) the collective throttle generated by the four motors to lift the UAV; \(\tau_{\phi}\), \(\tau_{\phi}\), and \(\tau_{\phi}\) are the torques generated around the axes \(x\), \(y\), and \(z\), respectively.  
Here, the authors have assumed that there exists a previous controller \(\hat{\tau}=C(\eta,\hat{\eta})\hat{\eta}+J\tau\) (see the mathematical model given by Equations (2.4) and (2.5), p. 34 of [18]), where \(\eta=(\phi,\theta,\psi)^{T}\) is the angular position vector, \(C(\eta,\hat{\eta})\) 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 \(\hat{\tau}=(\tau_{\phi},\tau_{\phi},\tau_{\psi})^{T}\). Figure 2 shows a schematic representation of the positions and angles of the quadrotor.  
Figure 1: Integral control scheme [4].  
Now, in order to obtain a discrete space state representation of the mathematical model of a flying robot, the following state variables are defined:  
\[x_{1}=x,\ x_{2}=\dot{x},\ x_{3}=y,\ x_{4}=\dot{y},\] \[x_{5}=z,\ x_{6}=\dot{z},\ x_{7}=\phi,\ x_{8}=\dot{\phi},\] \[x_{9}=\theta,\ x_{10}=\dot{\theta},\ x_{11}=\dot{\psi},\ x_{12}= \dot{\psi},\]  
and discretizing the related continuous model by applying the Euler approximation considering a sampled period \(T\), it becomes:  
\[x_{1}(k+1) =Tx_{2}(k)+x_{1}(k)\] \[x_{2}(k+1) =-\frac{T}{m}u(k)\sin(x_{9}(k))+x_{2}(k)\] \[x_{3}(k+1) =Tx_{4}(k)+x_{3}(k)\] \[x_{4}(k+1) =\frac{T}{m}u(k)\cos(x_{9}(k))\sin(x_{7}(k))+x_{4}(k)-Tg\] \[x_{5}(k+1) =Tx_{6}(k)+x_{5}(k)\] \[x_{6}(k+1) =\frac{T}{m}u(k)\cos(x_{9}(k))\cos(x_{7}(k))+x_{6}(k)-Tg\] \[x_{7}(k+1) =Tx_{8}(k)+x_{7}(k)\] \[x_{8}(k+1) =T\tau_{\phi}(k)+x_{8}(k)\] \[x_{9}(k+1) =Tx_{10}(k)+x_{9}(k)\] \[x_{10}(k+1) =T\tau_{\theta}(k)+x_{10}(k)\] \[x_{11}(k+1) =Tx_{12}(k)+x_{11}(k)\] \[x_{12}(k+1) =T\tau_{\psi}(k)+x_{12}(k)\]  
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.  
Figure 2: Positions and angles of the UAV.