# Quadrotor Stabilization and Tracking Using Nonlinear Surface Sliding Mode Control and Observer
## 2 Quadrotor Dynamic Modeling  
The quadrotor, which can take off and land vertically, is composed of four motors. Figure 1 describes two pairs of propellers \((\Omega_{1},\Omega_{3})\) and \((\Omega_{2},\Omega_{4})\), which rotate in opposite directions. Two diagonal motors \((\Omega_{1},\Omega_{3})\) rotate in a clockwise direction, while the other two \((\Omega_{2},\Omega_{4})\) rotate in a counterclockwise direction. A quadrotor can change its direction rapidly by its two pairs of motors [31]. We can acquire different positions and attitudes of the quadrotor by adjusting the velocity of the four propellers. Figure 1 also shows the earth-fixed frame and rigid body model of a quadrotor. In this paper, the dynamic model of the quadrotor is represented based on Newton-Euler equations. The Newton-Euler equations demonstrate the combined translational and rotational dynamics of a rigid body frame. The angles \((\phi,\ \theta,\ \psi)\), which represent roll, pitch, and yaw, respectively, are obtained from the rotation of the quadrotor's body frame in the \(x\)-, \(y\)-, and \(z\)-axes. \[ \begin{array}{l}\ddot{\phi}=\frac{I_{y}-I_{z}}{I_{x}}\dot{\theta}\dot{\psi}+ \frac{I_{x}}{I_{x}}\dot{\theta}\Omega+\frac{I}{I_{x}}u_{1}+d_{\phi},\\ \ddot{\theta}=\frac{I_{y}-I_{z}}{I_{y}}\dot{\psi}+\frac{I_{y}}{I_{y}}\dot{\theta }\Omega+\frac{I}{I_{y}}u_{2}+d_{\theta},\\ \ddot{\psi}=\frac{I_{x}-I_{y}}{I_{z}}\dot{\phi}\dot{\phi}+\frac{I}{I_{z}}u_{3} +d_{\psi},\\ \ddot{z}=-g+\frac{1}{m}\cos\phi\cos u_{4}+d_{z},\\ \ddot{x}=\frac{1}{m}(\cos\phi\sin\theta\cos\psi+\sin\phi\sin\psi)u_{4}+d_{x}, \\ \ddot{y}=\frac{1}{m}(\cos\phi\sin\theta\sin\psi-\sin\phi\cos\psi)u_{4}+d_{y}. \end{array}  \tag{1}\]  
Here, \(I_{x,y,z}\) is the body inertia, \(J_{r}\) is the rotor inertia, \(\Omega\) is the overall rotor speed, \(l\) is the lever length, \(g\) is gravity, and \(m\) is the mass of the quadrotor. \(x,\ y\), and \(z\) are the movement distance of the quadrotor in the direction of \(x,\ y\), and \(z\) axes, respectively. As shown in Equation (1), the attitude and altitude of the quadrotor are decided by the gyroscopic effect resulted from the rigid body rotation in space and the rotor speed. The control inputs for quadrotor attitude are represented by \(u_{1},\ u_{2},\) and \(u_{3}.\) The other control input, for altitude, is represented by \(u_{4}.\) To consider the unknown disturbance in real environment, the dynamic model of Equation (1) contains the disturbance (\(d_{\phi},\ d_{\theta},\ d_{\psi},\ d_{z},\ d_{x},\) and \(d_{y}\)) which causes the error between the measurement and the estimated value of the state. The control inputs can be represented as  
\[ \begin{array}{l}u_{1}=t\left(\Omega_{4}^{2}-\Omega_{2}^{2}\right),\\ u_{2}=t\left(\Omega_{3}^{2}-\Omega_{1}^{2}\right),\\ u_{3}=d\left(\Omega_{2}^{2}+\Omega_{4}^{2}-\Omega_{1}^{2}-\Omega_{3}^{2} \right),\\ u_{4}=t\left(\Omega_{1}^{2}+\Omega_{2}^{2}+\Omega_{3}^{2}+\Omega_{4}^{2} \right),\\ \Omega=\Omega_{2}+\Omega_{4}-\Omega_{1}-\Omega_{3},\end{array}  \tag{2}\]  
where \(\Omega_{i}\) is the rotational velocity of the \(i\)-th motor, \(t\) is the thrust factor, and \(d\) is the drag factor. We can obtain the whole motor velocity as represented in Equation (2). The dynamic model in Equation (1) can be rewritten in the state-space form of \(\dot{\mathbf{x}}=\mathbf{f}(\mathbf{x},\mathbf{u})\) with the state vector \(\mathbf{x}=\left[x_{1}\cdots x_{12}\right]^{T}\). The state vector is defined as follows:  
\[ \begin{array}{l}x_{1}=\phi,\ x_{2}=\dot{\phi},\ x_{3}=\theta,\ x_{4}=\dot{ \theta},\ x_{5}=\psi,\ x_{6}=\dot{\psi},\\ x_{7}=z,\ x_{8}=\dot{z},\ x_{9}=x,\ x_{10}=\dot{x},\ x_{11}=y,\ x_{12}=\dot{y}. \end{array}  \tag{3}\]  
Figure 1: Configuration of a quadrotor. In Equation (1), the mechanical structure can be represented as  
\[