# Building a Realistic Virtual Simulator for Unmanned Aerial Vehicle Teleoperation
## 2 Building a Realistic UAV Simulator
### Modeling
#### 2.2.4 Generalized Forces and Torques in the Quadrotor  
The quadrotor is an under-actuated dynamic system. However, its four rotors can control its position and orientation as follows:  
\[\left\{\begin{array}{l}M_{T}(\mathbf{\ddot{\xi}})\ddot{\mathbf{\xi}}+g_{T}(\mathbf{\dot{ \xi}})=\mathbf{f}\\ M_{R}(\mathbf{\eta})\ddot{\mathbf{\eta}}+C_{R}(\mathbf{\eta},\mathbf{\dot{\eta}})\dot{\mathbf{\eta} }=\mathbf{\tau}\end{array}\right. \tag{16}\]  
where \(\mathbf{f}=[f_{x},f_{y},f_{z}]^{T}\) and \(\mathbf{\tau}=[\tau_{\varphi},\tau_{\varphi},\tau_{\varphi}]^{T}\) are respectively the vectors of forces and generalized torques that are produced by the rotational motion of the actuators.  
In \(\{B\}\), the thrust exerted by the four rotors is always vertical (collinear to axis \(z_{B}\)) and has the form:  
\[\mathbf{f}_{B}=[0,0,f_{B,z}]^{T}=[0,0,f_{1}+f_{2}+f_{3}+f_{4}]^{T} \tag{17}\]where \(f_{i}\) is the thrust related to the torque \(\tau_{i}\) of the \(i\)-th rotor. The thrust \(f_{i}\) is obtained as in (18), with \(l_{h}\) as the radial length of the propellers.  
\[f_{i}=\frac{\tau_{i}}{l_{h}},\ i=1,2,3,4 \tag{18}\]  
In turn, the torque \(\tau_{i}\) is related to the magnitude of the rotational speed \(\Omega_{i}\) of the \(i\)-th rotor as shown in (19), where \(k_{r}\) is a constant of proportionality of the same sign as \(\tau_{i}\).  
\[\tau_{i}=k_{r}\Omega_{i}^{2},\ i=1,2,3,4 \tag{19}\]  
Then, in \(\{l\}\), the generalized force \(\mathbf{f}\), applied to translational dynamics, is given by:  
\[\mathbf{f}=R_{zxy}(\phi,\theta,\psi)f_{B} \tag{20}\]  
On the other side, the components of the generalized torque \(\mathbf{\tau}\) are obtained by analyzing the possible quadrotor movements in Figure 4.  
The movement of the rotors to hold the quadrotor in a fixed position in the air requires that all the rotors rotate at the same angular velocity to generate the upward thrust force as indicated in (21) and the direction described in Figure 4a. In the same figure, it can be seen that the direction of rotation of the consecutive rotors is inverse to prevent the quadrotor from making any rotation.  
\[\Omega_{1}=\Omega_{2}=\Omega_{3}=\Omega_{4} \tag{21}\]  
The roll motion (rotation around the \(x_{B}\) axis) requires a difference in thrust produced by the rotors 3-4 concerning the rotors 1-2, as seen in Figure 4b. Then, the torque necessary to perform the roll motion is given by (22).  
\[\tau_{\phi}=\tau_{3}+\tau_{4}-\tau_{1}-\tau_{2} \tag{22}\]  
Figure 4: Independent quadrotor motions. (**a**) Vertical thrust. (**b**) Roll motion. (**c**) Pitch motion. (**d**) Yaw motion.  
Analogously, pitch motion (rotation around the \(y_{B}\) axis) requires a difference in thrust produced by the rotors 1-4 concerning the rotors 2-3, as seen in Figure 4c. Therefore, the torque necessary to perform this motion is observed in (23).  
\[\tau_{\theta}=\tau_{4}+\tau_{1}-\tau_{2}-\tau_{3} \tag{23}\]  
Finally, the yaw movement (rotation around the vertical axis or \(z_{B}\)) is related to the torque \(\tau_{i}\) perpendicular to the plane of rotation produced by all rotors, i.e., it requires a difference in thrust produced by the rotors 2-4 concerning the rotors 1-3 as seen in Figure 4d. Then the torque necessary to perform the yaw motion is given by (24).  
\[\tau_{\phi}=\tau_{1}-\tau_{2}+\tau_{3}-\tau_{4} \tag{24}\]  
The developed forms of the vectors \(f\) and \(\tau\) can be consulted in Appendix A.2.