## 2 Quadrotor UAV: Modeling and Control
### System Description and Modeling of a QUAV  
As shown in Figure 1, to describe the motion of QUAV in 3D space, this requires the definition of two frames: the inertial World frame, \(W\), and the Body frame, \(B\). The first is a fixed coordinate system on Earth with \(x_{W}\)-\(y_{W}\)-\(z_{W}\) and the second is fixed on the structure of the vehicle, denoted by \(x\)-\(y\)-\(z\). The QUAV is a complex structure, and it involves different physical effects from aerodynamics and mechanic forces. The model developed assumes the following:  
* The structure of the system is rigid and symmetrical. * The gravity center and the \(B\) frame origin are coincident. * Propellers are rigid. * The attitude dynamics are limited to small angles and consequently slight variations of linear and angular velocities. The absolute position of QUAV is defined as the coordinates in the \(B\) frame in regard to coordinates in the \(W\) frame, represented by position vector \(\mathbf{r}=[x,y,z]^{T}\). The angular position, defined by the \(Euler\) angles \((\phi,\theta,\psi)\), represent the orientation of the QUAV with respect to the \(W\) frame, these angles define the rotations of _yave, roll_ and _pitch_, they indicate how the \(B\) frame (which initially is aligned with the \(W\) frame) must be rotated to align with \(W\) frame again. The rotation matrix from \(B\) to \(W\), is given by \({}^{W}R_{B}=\ ^{c}R_{B}\ ^{aR}R_{c}\ ^{W}R_{a}\), where \({}^{c}R_{B}\), \({}^{a}R_{c}\), \({}^{W}R_{a}\), represents rotations about \(X\), \(Y\) and \(Z\) axis, respectively, in that order, as shown in Figure 2.  
\[{}^{c}R_{B}=\left( \begin{array}{ccc}\cos(\psi)&\sin(\psi)&0\\ -\sin(\psi)&\cos(\psi)&0\\ 0&0&1\end{array} \right)\]  
Figure 1: The QUAV and the reference frames. \[{}^{a}R_{c}=\left( \begin{array}{ccc}\cos(\theta)&0&-\sin(\theta)\\ 0&1&0\\ \sin(\theta)&0&\cos(\theta)\end{array} \right)\]  
\[{}^{W}R_{a}=\left( \begin{array}{ccc}1&0&0\\ 0&\cos(\phi)&\sin(\phi)\\ 0&-\sin(\phi)&\cos(\phi)\end{array} \right)\]  
\[{}^{W}R_{B}=\left( \begin{array}{ccc}\cos(\theta)\cos(\psi)&\cos(\psi)\sin( \theta)\sin(\phi)-\cos(\phi)\sin(\psi)&\cos(\psi)\cos(\phi)\sin(\theta)+\sin( \psi)\sin(\phi)\\ \cos(\theta)\sin(\psi)&\cos(\psi)\cos(\phi)+\sin(\theta)\sin(\psi)\sin(\phi) \cos(\phi)\sin(\theta)+\sin(\psi)\sin(\phi)\\ -\sin(\theta)&\cos(\theta)\sin(\phi)&\cos(\theta)\cos(\phi)\end{array} \right)\]  
Before presenting the movement equations, we establish the relation between velocities in \(W\), \((\dot{\phi},\dot{\theta},\dot{\psi})\), and velocities in \(B\), \((p,q,r)\), from transformation vectors:  
\[{}^{W}R_{a}\ {}^{a}R_{c}\ {}^{c}R_{B}=\left( \begin{array}{c}-s(\theta)\\ c(\theta)s(\phi)\\ c(\theta)c(\phi)\end{array} \right),\]  
\[{}^{W}R_{a}\ {}^{a}R_{c}=\left( \begin{array}{c}0\\ c(\phi)\\ -s(\phi)\end{array} \right),\]  
\[{}^{W}R_{a}\ =\left( \begin{array}{c}1\\ 0\\ 0\end{array} \right),\]  
the rotational transform matrix is \(R_{r}\)  
\[R_{r}=\left( \begin{array}{ccc}1&0&-s(\theta)\\ 0&c(\phi)&c(\theta)s(\phi)\\ 0&-s(\phi)&c(\theta)c(\phi)\end{array} \right),\]  
then, we can define the angular velocity in the body, \(\omega_{B}\), as the relation  
\[\omega_{B}=\left( \begin{array}{c}p\\ q\\ r\end{array} \right)=R_{r}\left( \begin{array}{c}\dot{\phi}\\ \dot{\theta}\\ \dot{\psi}\end{array} \right),\]  
by using a small angle approximation, we get  
\[\left( \begin{array}{c}\dot{\phi}\\ \dot{\theta}\\ \dot{\psi}\end{array} \right)=\left( \begin{array}{c}p+r\cos(\phi)\tan( \theta)+q\sin(\phi)\tan(\theta)\\ q\cos(\phi)-r\sin(\phi)\\ r\cos(\phi)\sec(\theta)+q\sin(\phi)\sec(\theta)\end{array} \right)\approx \left( \begin{array}{c}p\\ q\\ r\end{array} \right).\]  
Applying, Newton-Euler formulation, equations of motion are given by (1) and (2).