# Building a Realistic Virtual Simulator for Unmanned Aerial Vehicle Teleoperation
## 2 Building a Realistic UAV Simulator
### Simulator Optimization  
The virtual teleoperated simulator developed so far includes elements that provide a feeling of realism to a certain extent. However, as mentioned before, this feature also depends on the suitable adjustment of the parameters in the teleoperation algorithm. Nevertheless, tuning these parameters is not a trivial task due to the highly non-linear relationships between the inputs and the considered movements in the quadrotor.  
For the above fact, the meta-heuristic optimization approach is used in this framework to tune the teleoperation parameters [54]. In this approach, a mathematical programming problem is stated first. Then, the problem is solved by a meta-heuristic optimizer, and the solution includes a suitable set of parameters.  
Because the simulation needs to be as close to reality as possible, the flight information of a real-world quadrotor and its interactions with the human operator is required. This information guides the search for the best teleoperation parameters. It can be acquired from the sensors included in any real-world vehicle, such as the Inertial Measurement Unit (IMU), the gyroscope, and the magnetometer, among other alternatives.  
In this framework, it is assumed that the height \(\hat{z}\), the yaw angle \(\hat{y}\), the pitch angle \(\hat{\theta}\), and the roll angle \(\hat{\phi}\) values, as well as the input control actions for the elevation \(\hat{u}_{LSV}\), the yaw movement \(\hat{u}_{LSH}\), the pitch movement \(\hat{u}_{RSV}\), and the roll movement \(\hat{u}_{RSH}\) can be acquired from the real-world quadrotor.  
Therefore, the mathematical programming problem for the optimization of the teleoperation parameters can be stated as:  
\[\textbf{min}\ _{p\in\Omega}\ J(\mathbf{p})=J_{z}(\mathbf{p})+J_{\psi}(\mathbf{p})+J_{\theta}( \mathbf{p})+J_{\phi}(\mathbf{p}) \tag{32}\]where the vector \(\mathbf{p}\) includes the parameters of the teleoperation algorithm, \(\Omega\) is the search space given by the lower and upper bounds of each parameter, and \(J_{z}(\mathbf{p})\), \(J_{\psi}(\mathbf{p})\),\(J_{\theta}(\mathbf{p})\), and \(J_{\theta}(\mathbf{p})\) are the objective functions related to the Integral Square Error (ISE) index [55] calculated over the errors \(e_{z}(t)=\hat{z}(t)-z(t)\), \(e_{\psi}(t)=\hat{\psi}(t)-\psi(t)\), \(e_{\theta}(t)=\hat{\theta}(t)-\theta(t)\), and \(e_{\theta}(t)=\hat{\phi}(t)-\phi(t)\) for \(t\in[0,t_{f}]\) as follows:  
\[J_{z}(\mathbf{p})=ISE(e_{z}(t))=\int_{t=0}^{t_{f}}(\hat{z}(t)-z(t))dt \tag{33}\]  
\[J_{\psi}(\mathbf{p})=ISE(e_{\psi}(t))=\int_{t=0}^{t_{f}}(\hat{\psi}(t)-\psi(t))dt \tag{34}\]  
\[J_{\theta}(\mathbf{p})=ISE(e_{\theta}(t))=\int_{t=0}^{t_{f}}(\hat{\theta}(t)-\theta (t))dt \tag{35}\]  
\[J_{\phi}(\mathbf{p})=ISE(e_{\phi}(t))=\int_{t=0}^{t_{f}}(\hat{\phi}(t)-\phi(t))dt \tag{36}\]  
In the above functions, \(z(t)\), \(\psi(t)\), \(\theta(t)\), and \(\phi(t)\) are obtained from the dynamic simulation of the quadrotor considering \(\hat{u}_{LSV}\), \(\hat{u}_{LSH}\), \(\hat{u}_{RSV}\), and \(\hat{u}_{RSH}\) as the inputs.  
Therefore the problem in (32) aims to find the parameters of the teleoperation algorithm that minimize the differences between the behavior of the simulated and the real-world quadrotors when both receive the same inputs. Meta-heuristic optimizers from swarm intelligence and evolutionary computation can solve this problem [56].