# Unmanned Aerial Vehicle Landing on Rugged Terrain by On-Board LIDAR-Camera Positioning System
## 4 Landing Site Detection
### Construction of the Cost Energy Map  
Considering the color point cloud map and the estimated UAV position, the cost energy map was established to weigh the landing possibilities at every point, as described in the following equation,  
\[C_{sum}=\lambda_{1}c_{s}+\lambda_{2}c_{f}+\lambda_{3}c_{d}, \tag{13}\]  
where \(c_{s}\), \(c_{f}\), and \(c_{d}\) represent smoothness, flatness, and distance costs, respectively, as shown in the alternative landing site detection module in Figure 1. Additionally, \(\lambda_{1}\), \(\lambda_{2}\), and \(\lambda_{3}\) are the weight parameters for each costmap with the constraints that \(\lambda_{1}+\lambda_{2}+\lambda_{3}=1\). The details of the costmap and weight parameter definitions for alternative landing site detection are described below. Smoothness costmap \(c_{s}\): Normally, the flat sites that are suitable for a UAV landing comprise similar colors visually in natural scenes. The edge contour of the image may indicate that the area is filled with various irregularly shaped objects. Because the color map is obtained during the UAV's flight, it is possible to directly calculate the map edges in the global area instead of in each image frame. A canny edge detection method was adopted to generate a binary edge map using a Gaussian filter to reduce image noise. The suitable landing sites could be identified by finding a large circle centered on a point in the edge map, where there was no edge point therein. The radius of the circle could be determined using the distance transformation method, which calculates the distance between each point and the closest edge point in the map. For each point \(x_{i}^{e}\) in the edge map, the smoothness cost was defined by the circle radius expressed as  
\[c_{s}(x_{i})=\min\quad\overline{(x_{i}-x_{k})^{T}(x_{i}-x_{k})}|Candy(x_{k})=1\quad, \tag{14}\]  
where \(Candy(x_{k})=1\) indicates that \(x_{k}\) is an edge point. Flatness costmap \(c_{f}\): After obtaining the 3D point cloud map, the geometric shape of the terrain under the UAV can be analyzed. A site that is suitable for the UAV to land is expected to be a large and flat plane. The flatness of each point in a point cloud map can be measured according to the angle between its normal \(n_{i}\) and the vertical vector \(z\):  
\[\theta_{i}=\cos^{-1}\quad\frac{n_{i}\cdot z}{|n_{i}||z|}\quad. \tag{15}\]  
The cost energy of each point was evaluated by a Gaussian kernel,  
\[fl_{i}=\exp\quad\frac{\theta_{i}-\overline{\theta}^{2}}{2\sigma_{\theta}^{2}}\quad, \tag{16}\]  
where \(\overline{\theta}\) and \(\sigma_{\theta}\) represent the mean and standard deviation of all points, respectively. Similar to the smoothness cost, the landing site was determined by finding a circle centered on a point in the normal map, where the \(fl_{i}\)'s of all points were accumulated. To increase the computational speed, the KD-tree in the Point Cloud Library (PCL) was constructed to search for the nearest neighbors of the query point within the radius and to estimate thesurface normal via principal component analysis. The flatness cost was represented by the following equation,  
\[c_{f}(p_{i})=\sum_{j\in\Re_{i}}fl_{j}, \tag{17}\]  
where \(\Re_{i}\) denotes a circle centered on the point \(p_{i}\). Energy consumption costmap \(c_{d}\): The last factor influencing the landing site selection was related to the energy consumed by the UAV to reach the landing site. It is time consuming to accurately estimate the energy consumed by the UAV from the current position along the optimal trajectory to each point on the map, and therefore, the Euclidean distance was computed to approximate this costmap:  
\[c_{d}=\|p_{i}-p_{uw}\|, \tag{18}\]  
where \(p_{uw}\) represents the current position of the UAV. Weighting parameters: Each costmap was normalized to scale its values to \([0,1]\). The flatness costmap can be used to find large flat areas most directly, so \(\lambda_{1}\) was assigned a lager value than \(\lambda_{2}\) and \(\lambda_{3}\).