# Quadrotor UAV Dynamic Visual Servoing Based on Differential Flatness Theory
## 3 Tracking Strategy
### Loop 3: Flatness-Based Tracking Control
#### 3.3.2 Control Strategy  
As shown in Figure 1, the control used to ensure the realization of the movements necessary for the quadrotor in order to satisfy the tracking of the vehicle (target) is based on the differential flatness. This control uses an open-loop control that linearizes the system and a closed-loop correction term that ensures the asymptotic convergence of the desired trajectory even in the presence of disturbances. Here, we replace the command \(u_{1}\) of Equation (3) in the model that describes the dynamics of the quadrotor (Equation (1)):  
\[\left\{ \begin{array}{l}\ddot{x}=(Nu_{z}+g)tan\theta cos\psi+(Nu_{z}+g)\frac{ \tan(\phi)}{cos\phi}sin\psi\\ \ddot{y}=(Nu_{z}+g)tan\theta sin\psi-(Nu_{z}+g)\frac{\tan(\phi)}{cos\phi}cos \psi\\ \ddot{z}=Nu_{z}=\ddot{z}_{d}+k_{11}\big{(}\ddot{z}_{d}-\dot{z}\big{)}+k_{12}(z_ {d}-z)\\ \ddot{\theta}=u_{2}\\ \ddot{\phi}=u_{3}\\ \ddot{\psi}=u_{4}\end{array} \right.. \tag{28}\]  
We prove that this system is flat and has flat output: \(F_{1}=z\) ; \(F_{2}=x\); \(F_{3}=y\); \(F_{4}=\psi\). Indeed, using the first and second lines of Equation (28), we can express the variables \(\theta\) and \(\phi\) in terms of the flat outputs:  
\[\left\{ \begin{array}{l}\theta=arctan\Big{(}\frac{cos(\psi)\ddot{x}+sin( \psi)\ddot{y}}{\dot{z}+g}\Big{)}\\ \phi=arcsin\Bigg{(}\frac{sin(\psi)\ddot{y}-cos(\psi)\ddot{y}}{\sqrt[3]{\dot{x }^{2}+\dot{y}^{2}}+\big{(}\ddot{z}+g\big{)}^{2}}\Bigg{)}\end{array} \right.. \tag{29}\]  
Control expressions can be written in terms of flat outputs and their derivatives:  
\[\left\{ \begin{array}{l}u_{2}=\ddot{\theta}=\frac{d^{2}}{dt}\Big{(}arctan \Big{(}\frac{cos(\psi)\ddot{x}+sin(\psi)\ddot{y}}{\dot{z}+g}\Big{)}\Big{)}\\ u_{3}=\ddot{\phi}=\frac{d^{2}}{dt}\Big{(}arcsin\Bigg{(}\frac{sin(\psi)\ddot{x} -cos(\psi)\ddot{y}}{\sqrt[3]{\dot{x}^{2}+\dot{y}^{2}}+\big{(}\ddot{z}+g\big{)} ^{2}}\Bigg{)}\end{array} \right.. \tag{30}\]  
We have just expressed all the variables of the system as a function of the dynamics of \((z,x,y,\psi)\). The system of Equation (28) is flat and has as flat outputs of \(F_{1}=z\) ; \(F_{2}=x\); \(F_{3}=y\); \(F_{4}=\psi\). To achieve the desired trajectory \((x_{d},y_{d},\psi_{d})\), generated by the trajectory generation block and using Equation (30), we can deduce the open loop control ensuring this desired trajectory:  
\[\left\{ \begin{array}{l}u_{2d}=\frac{d^{2}}{dt}\left(arctan\left(\frac{\cos(\phi_ {d})\tilde{x}_{d}+\cos(\phi_{d})\tilde{y}_{d}}{\tilde{x}_{d}+g}\right)\right)\\ u_{3d}=\frac{d^{2}}{dt}\left(arcsin\left(\frac{sin(\phi_{d})\tilde{x}_{d}-\cos( \phi_{d})\tilde{y}_{d}}{\sqrt{\tilde{x}_{d}^{2}+\tilde{y}_{d}^{2}+\tilde{(z}_{ d}+g)^{2}}}\right)\right)\\ u_{4d}=\tilde{\psi}_{d}\end{array} \right.. \tag{31}\]  
Until now, flatness has been used to calculate the commands corresponding to the open-loop trajectories of the system. If the system is intrinsically stable, it will behave appropriately and pursue the desired trajectory. For unstable systems whose purpose is to accelerate convergence, a small closed-loop correction term must be added to this open-loop control to guarantee trajectory tracking. To generate this correction term, we will consider some simplification assumptions. It should be noted here that these assumptions relate only to the development of a correction term that is considered in the vicinity of the desired trajectory. When the quadrotor joins the desired trajectory, we can assume that the angles \(\theta\), \(\phi\), and \(\psi\) become small. The expressions for the second derivative of \(\theta\) and \(\phi\) will be given by  
\[\left\{