# Inverse Optimal Design for Position Control of a Quadrotor
## 3 Design of Inverse Optimal Position Controller
### Position Control of a Quadrotor Based on Altitude Control  
In this section, to realize the position control of a quadrotor, we define the variable \(\widetilde{u_{1}}\), using the actual altitude control input \(u_{1}\), as follows:  
\[\widetilde{u_{1}}=T_{1}(\phi(t),\theta(t))u_{1}=\frac{\cos\phi\cos\theta}{m}v_ {1}+g. \tag{30}\]  
To design the position control of a quadrotor, the dynamics of a quadrotor (5) can be rewritten in state-space form using the following states:  
\[x_{1}=X,\ x_{2}=\dot{X},\ x_{3}=Y,\ x_{4}=\dot{Y}\]  
We obtain the \((x,\ y)\) position state-space equations of a quadrotor as follows:  
\[\left\{ \begin{array}{l}\dot{x_{1}}=x_{2}\\ \dot{x_{2}}=u_{1}\big{(}cos\phi sin\theta cos\psi+sin\phi sin\psi\big{)}/m\\ \dot{x_{3}}=x_{4}\\ \dot{x_{4}}=u_{1}\big{(}cos\phi sin\theta sin\psi-sin\phi cos\psi\big{)}/m\\ \end{array} \right. \tag{31}\]  
Rearranging these equations, we finally obtain the following position dynamics (7) of a quadrotor as follows:  
\[\left\{ \begin{array}{l}\dot{P}=V\\ \dot{V}=u_{1}/m\begin{bmatrix}u_{x}\\ u_{y}\\ \end{bmatrix}\\ \end{array} \right. \tag{32}\]  
where \(P\) and \(V\) are defined as \(P:=[X\ Y]^{T}\) and \(V:=\dot{P}\), respectively, \(u_{x}\) and \(u_{y}\) are the effective control inputs are defined by  
\[ \begin{bmatrix}u_{x}\\ u_{y}\\ \end{bmatrix} = \begin{bmatrix}cos\phi sin\theta cos\psi+sin\phi sin\psi\\ cos\phi sin\theta sin\psi-sin\phi cos\psi\\ \end{bmatrix} . \tag{33}\]  
To express (32) in a form like that of (8), substituting the altitude input (30) of a quadrotor into the position dynamics (32) of a quadrotor and using the transformation matrix \(T_{2}(\chi_{z}(t),\phi(t),\theta(t),\psi(t))\) given by  
\[T_{2}(\chi_{z}(t),\phi(t),\theta(t),\psi(t))=\widetilde{u}_{1} \begin{bmatrix} \cos\psi&\sin\psi\\ \sin\psi&-\cos\psi\\ \end{bmatrix} , \tag{34}\]we obtain the matrix-type position dynamics of a quadrotor as follows:  
\[\dot{P} =V\] \[\dot{V} =\widetilde{u}_{1} \begin{bmatrix}\cos\psi&\sin\psi\\ \sin\psi&-\cos\psi\end{bmatrix}\begin{bmatrix}\tan\theta\\ \sec\theta\cdot\tan\phi\end{bmatrix} \] \[=T_{2}(\chi_{z}(t),\phi(t),\theta(t),\psi(t)) \begin{bmatrix}u_{ 11}\\ u_{22}\end{bmatrix} , \tag{35}\]  
where \(u_{11}=\tan\theta\) and \(u_{22}=\sec\theta\cdot\tan\phi\). The states \(P\) and \(V\), which are related to the position of a quadrotor, can be rewritten as the state \(\chi_{p}\), as follows:  
\[\chi_{p}= \begin{bmatrix}P-P_{d}\\ V-V_{d}\end{bmatrix} , \tag{36}\]  
where \(P_{d}\) is the reference value of the position, \(V_{d}=\dot{P}_{d}\) is the reference velocity value along the \(X\) and \(Y\) axes. Differentiating \(\chi_{p}\) with respect to time, we have  
\[\chi_{p}=A_{p}\,\chi_{p}+B_{p}(\chi_{z}(t),\phi(t),\theta(t),\psi(t))\,\,u_{p}, \tag{37}\]  
where \(A_{p}\) and \(B_{p}(\chi_{z}(t),\phi(t),\theta(t),\psi(t))\) are defined as \(A_{p}:= \begin{bmatrix}0_{2\times 2}&I_{2\times 2}\\ 0_{2\times 2}&0_{2\times 2}\end{bmatrix} \) and \(B_{p}(\chi_{z}(t),\phi(t),\theta(t),\psi(t)):= \begin{bmatrix}0_{2\times 2} \\ T_{2}(\chi_{z}(t),\phi(t),\theta(t),\psi(t))\end{bmatrix} \), respectively, and \(u_{p}:= \begin{bmatrix}u_{11}\\ u_{22}\end{bmatrix} \). The parameters, \(\chi_{z}(t),\phi(t),\theta(t)\), and \(\psi(t)\) are function of time, so we can express (37) as follows:  
\[\chi_{p}=A_{p}\,\chi_{p}+B_{p}(t)\,\,u_{p}. \tag{38}\]  
where we denote \(B_{p}(t):=B_{p}(\chi_{z}(t),\phi(t),\theta(t),\psi(t))\) with a slight abuse of notation. For the system (38), we also propose the following inverse optimal \((x,\,y)\) position control input \(u_{p}\) of a quadrotor:  
\[u_{p}=-k_{p}(\chi_{z},\phi,\theta,\psi)\cdot\chi_{p}, \tag{39}\]  
where \(k_{p}\) is given by  
\[k_{p}(\chi_{z},\phi,\theta,\psi)=\Gamma_{p}^{-1}(t)\cdot B_{p}^{T}(t)\cdot P_{ p}. \tag{40}\]  
where we denote \(\Gamma_{p}(t):=\Gamma_{p}(\chi_{z}(t),\phi(t),\theta(t),\psi(t))\) with a slight abuse of notation.