# Passivity-Based Control for a Micro Air Vehicle Using Unit Quaternions
## 2 Preliminaries
### Classical Algorithm Applied to a Quad-Rotor  
The PBC strategy seen in the Section 2.2 can not be applied directly to a quad-rotor, since the vehicle is a under-actuated system. However, the approach IDA-PBC (for further details, the interested reader is referred to [27]) if can be applied. Hence the main difficulty is in the solution of complex PDEs, which often can not be computed. Also, it is only possible to stabilize the attitude of the quad-rotor.  
We briefly review a classical procedure to design a IDA-PBC algorithm to stabilize a quad-rotor without using quaternions (for further details, the interested reader is referred to [18]).  
From the Euler-Lagrange formulation the dynamic model of a quad-rotor can be expressed as  
\[\mathcal{M}(\lambda)\ddot{\lambda}+D(\lambda,\dot{\lambda})\dot{\lambda}+G=B( \lambda)u \tag{5}\]  
where the state vector \(\lambda=\left[\begin{array}{cc}p^{T}&\eta^{T}\end{array}\right]^{T}\), \(p=\left[\begin{array}{cc}x&y&z\end{array}\right]^{T}\) denotes the position of the UAV, \(\eta=\left[\begin{array}{cc}\psi&\theta&\phi\end{array}\right]^{T}\) are the Euler angles yaw, pitch and roll, respectively. The input vector \(u=\left[\begin{array}{cc}f_{\text{th}}&\tau\end{array}\right]^{T}\), \(f_{\text{th}}\) is the total thrust magnitude and \(\tau=\left[\begin{array}{cc}\tau_{x}&\tau_{y}&\tau_{z}\end{array}\right]^{T}\). The matrix \(B(\lambda)\) is given as  
\[B=\left[\begin{array}{cccccc}s_{\phi}s_{\psi}+c_{\phi}c_{\psi}s_{\theta}&c_{ \phi}s_{\theta}s_{\psi}-c_{\psi}s_{\phi}&c_{\theta}c_{\phi}&0&0&0&0\\ 0&0&1&0&0\\ 0&0&0&1&0\\ 0&0&0&0&1\end{array}\right]^{T}\]  
Matrices \(\mathcal{M}(\lambda)\), \(D(\lambda,\dot{\lambda})\) and the vector \(G\) are defined in [28]. Notice that matrix \(B(\lambda)\) is not invertible. Then, if we applied the potential energy-shaping procedure of IDA-PBC, we can get the energy-shaping term as [27]  
\[u_{\text{es}}=(B^{T}B)^{-1}B^{T}(\
abla_{\lambda}V-\
abla_{\lambda}V_{d}) \tag{6}\]  
where \(V\) denotes the potencial energy and \(V_{d}\) the desired potencial energy.  
The desired potential energy can be obtained from [27]  
\[B^{\perp}\left\{\
abla_{\lambda}V-\
abla_{\lambda}V_{d}\right\}=0 \tag{7}\]  
A popular choice for the full rank left annihilator \(B^{\perp}\) is [18]  
\[B^{\perp}=\left[\begin{array}{cccccc}0&-1&\frac{c_{\phi}s_{\phi}c_{\psi}-c_ {\psi}s_{\phi}}{c_{\phi}c_{\phi}}&0&0&0\\ -1&0&\frac{s_{\phi}s_{\psi}+c_{\phi}c_{\phi}s_{\psi}}{c_{\phi}c_{\phi}}&0&0&0 \end{array}\right]\]  
Thus, substituting the above into (7), it follows that  
\[\left\{\begin{array}{c}\
abla_{y}V_{d}-\frac{c_{\phi}s_{\phi}c_{\psi}-c_{ \psi}s_{\phi}}{c_{\phi}c_{\phi}}&(\
abla_{z}V-\
abla_{z}V_{d})=0\\ \
abla_{x}V_{d}-\frac{s_{\phi}s_{\phi}+c_{\phi}c_{\phi}s_{\psi}}{c_{\phi}c_{ \phi}}&(\
abla_{z}V-\
abla_{z}V_{d})=0\end{array}\right.\]  
The previous implies the next simple solution  
\[V_{d}(\lambda)=-V+\phi(\phi,\theta,\psi) \tag{8}\]  
where \(\phi(\phi,\theta,\psi)\) is an arbitrary differentiable function that is selected to be a quadratic function.  
Introducing (8) into (6) it can be observed that is only possible to control the attitude of the quad-rotor. Several solutions to stabilize the full dynamics can be found in the literature, for example [17], nevertheless they propose to rewrite the model in some special forms to apply their approach. Our contribution to solve this problem is to design a control strategy using a logarithmic mapping andan attitude trajectory in the quaternion space. This allows to stabilizes all the system states without any assumptions in the model.