# Discrete Integral Optimal Controller for Quadrotor Attitude Stabilization: Experimental Results
## 2 Control Strategy
### Discrete Model and Integral Control
\right],\ C_{\psi}=TI_{2},\]  
Consider the performance index:  
\[\mathcal{J}_{\psi}=\sum_{k=1}^{\infty}\ (x_{\psi}^{T}(k)\mathcal{Q}_{\psi}x_{ \psi}(k)+\tau_{\psi}^{2}(k)\mathcal{R}_{\psi})\]  
with an appropriate dimension matrix \(\mathcal{Q}_{\psi}\geq 0\) and a real \(R_{\psi}>0\). As the pair \((\mathcal{A}_{\psi},\mathcal{B}_{\psi})\) is controllable in a finite number of steps, the optimal control law with integral action is given by:  
\[\tau_{\psi}^{*}(k)=-(\mathcal{R}_{\psi}+\mathcal{B}_{\psi}^{T}\mathcal{P}_{ \psi}\mathcal{B}_{\psi})^{-1}\mathcal{B}_{\psi}^{T}\mathcal{P}_{\psi} \mathcal{A}_{\psi}x_{\psi}^{*}(k),\]  
where matrix \(\mathcal{P}_{\psi}\) is the unique solution to the algebraic equation:  
\[\mathcal{P}_{\psi}=\mathcal{A}_{\psi}^{T}\mathcal{P}_{\psi}\mathcal{A}_{\psi} -\mathcal{A}_{\psi}^{T}\mathcal{P}_{\psi}\mathcal{B}_{\psi}(\mathcal{R}_{ \psi}+\mathcal{B}_{\psi}^{T}\mathcal{P}_{\psi}\mathcal{B}_{\psi})^{-1} \mathcal{B}_{\psi}^{T}+\mathcal{Q}_{\psi}.\]  
For the subsystem \(y\)-\(\phi(k)\):  
\[x_{3}(k+1) = Tx_{4}(k)+x_{3}(k),\] \[x_{4}(k+1) = T\bigg{[}\frac{u(k)}{m}\cos(x_{9}(k))\sin(x_{7}(k))\bigg{]}+x_{ 4}(k),\] \[x_{7}(k+1) = Tx_{8}(k)+x_{7}(k)\] \[x_{8}(k+1) = T\tau_{\psi}(k)+x_{8}(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  
\[x_{4}(k+1)=T(u_{1}^{*}(k)+g)\tan x_{7}(k)+x_{4}(k),\]  
but \(u_{1}^{*}(k)\) tends to zero when \(k\) tends to infinity. Then, there exists \(n\in\mathbb{Z}^{+}\) such that for all \(k\geq nT\), \(\big{|}u_{1}^{*}(k)\big{|}\) is bounded and neglected; it follows that:  
\[x_{4}(k+1)=gT\tan x_{7}(k)+x_{4}(k).\]  
Let there be a control law \(\tau_{\psi}(k)\) that guarantees that \(\tan x_{7}(k)\approx x_{7}(k)\); therefore, \(x_{4}(k+1)=gTx_{7}(k)+x_{4}(k)\). Having this idea in mind, consider the following definition:  
\[x_{3}(k)\triangleq x_{1y}(k),\ x_{4}(k)\triangleq x_{2y}(k)\]  
\[\tau_{\psi}^{*}(k)=-(\mathcal{R}_{\psi}+\mathcal{B}_{\psi}^{T}\mathcal{P}_{ \psi}\mathcal{B}_{\psi})^{-1}\mathcal{B}_{\psi}^{T}\mathcal{P}_{\psi} \mathcal{A}_{\psi}x_{\psi}^{*}(k),\]0  
with this definition, the space state representation of the linearized system is:  
The augmented vector is:  
\[\xi_{x\theta}(k)=\big{[} \begin{array}{cc}x_{1x}(k)&x_{2x}(k)&x_{3\theta}(k)&x_{4 \theta}(k)&\sigma_{1x}(k)&\sigma_{2x}(k)&\sigma_{3\theta}(k)&\sigma_{4\theta}(k )\end{array} \big{]}^{T},\]  
and the following performance index is minimized:  
\[\mathcal{J}_{x\theta}=\sum_{k=1}^{\infty}\big{(}\xi_{x\theta}^{T}(k)\mathcal{ Q}_{x\theta}\xi_{x\theta}(k)+\tau_{x\theta}^{2}(k)\mathcal{R}_{x\theta}\big{)}\]  
where \(\mathcal{Q}_{x\theta}\geq 0\), \(\mathcal{R}_{x\theta}>0\) and \(\mathcal{P}_{x\theta}\) is the solution to the algebraic Riccati equation:  
\[\mathcal{P}_{x\theta}=\mathcal{A}_{x\theta}^{T}\mathcal{P}_{x\theta}\mathcal{ A}_{x\theta}-\mathcal{A}_{x\theta}^{T}\mathcal{P}_{x\theta}\mathcal{B}_{x \theta}(\mathcal{R}_{x\theta}+B_{x\theta}^{T}\mathcal{P}_{x\theta}\mathcal{ B}_{x\theta})^{-1}B_{x\theta}^{T}+\mathcal{Q}_{x\theta}\]  
where  
\[\mathcal{A}_{x-\theta}=\left[ \begin{array}{cc}A_{x\theta}&0\\ C_{x\theta}&I_{2}\end{array} \right],\,\mathcal{B}_{x\theta}=\left[ \begin{array} []{c}B_{x\theta}\\ 0\end{array} \right]\]  
and  
\[A_{x\theta}=\left[ \begin{array}{cccc}1&T&0&0\\ 0&1&-gT&0\\ 0&0&1&T\\ 0&0&0&1\end{array} \right],\,B_{x\theta}=\left[ \begin{array}{c}0\\ 0\\ T\end{array} \right],\]  
\[C_{x\theta}=TI_{2}.\]  
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.