# Ellipsoidal Path Planning for Unmanned Aerial Vehicles
## 2 Approximating the Distance Function with Neural Networks
The desired distance will be between the minimum and the maximum distances and it will depend on the orientation of the ellipses. The positions of the UAV and obstacles are difficult to normalize. If we normalize using common techniques like max-min or the standard normalization the neural network could output strange values for ellipsoid outside this normalization. To avoid this situation, we will code the relative position with a normalized vector from the UAV center to the obstacle center \((u_{x},u_{y},u_{z})\). Figure 3: Minimum and maximum distance between ellipses. Instead of doing regression with the real distance between the ellipsoids, we just estimate a correction variable \(\delta\) if we subtract this value from the centers distance of the ellipsoids, we can calculate the distance between ellipsoids, as we show in (3):  
\[dist(E_{1},E_{2})=||\text{Center}_{1}-\text{Center}_{2}||_{2}-\delta. \tag{3}\]  
The \(\delta\) correction factor depends only on the relative position of the obstacle ellipsoid and the UAV ellipsoid and their orientations. We can approximate this correction factor with a neural network. In Figure 4, we present the normalized input vector and the neural network architecture. We generate 185,000 random examples that took one day to calculate. We distribute these samples the following way: 149,850 samples for training, 16,650 for validating and hyper-parameter tuning, and 18,500 for testing. We trained this neural network for 50 epochs. In Figure 5, we show the training and validation evolution on the mean squared error (MSE). We got 0.0016 final MSE for training and 0.0017 final MSE for validation. In Table 2, we present the training results. In particular, we present the \(R^{2}\)-score where the best possible value is one, we also show the mean absolute error (MAE) and the median absolute error (MedianAE), in order to give a good sense of the capabilities of the neural network. Figure 4: Neural network architecture. Figure 5: Neural Network Training Results. The neural network achieves a high performance in predicting the correction factor and by using (3), we can accurately calculate the distance between the UAV and the obstacle ellipsoids. The Network was programmed on Keras/Tensorflow, then the network natively can run on a graphical process unit (GPU) for high performance. After testing, we can calculate the distance between a UAV ellipsoid and 200 obstacles in a mean time of 0.1208 s (We use a RTX 2060 GPU). With this result, we can assure that the application of path planning over ellipsoidal maps is computationally affordable. Finally, we run an experiment on a virtual environment by placing the UAV in a grid position and calculating the minimum distance to the closest object. In Figure 6, we show the result of the experiment. The warmer colors represent greater distances. Notice that the neural network can calculate an accurate map that is compact in memory and rich in information. In the next section, we develop the path planning algorithm based on this neural network by using a bio-inspired algorithm with a greedy approach.