# The Improved A* Algorithm for Quadrotor UAVs under Forest Obstacle Avoidance Path Planning
## 2 Materials and Methods
### Improved A* Algorithm
#### 2.2.2. Heuristic Function for Adding Steering Cost  
The heuristic function utilized in the conventional A* algorithm employs a single distance approach for node selection, which can result in an increased number of turning points and subsequently impact the UAV's flight continuity and smoothness. To address this issue, a corner constraint is introduced during each node selection to decrease the number of points with large angles. Additionally, excess corners are corrected to avoid local optima. Therefore, this paper introduces the difference between the current heading angle of UAVs and the target direction angle and establishes the heuristic function containing steering cost under different angle differences.  
While the theoretical shortest distance between the current node and the target point is a straight line, obstacles will exist during the actual flight. As such, the line linking thecurrent node to the next node will form a particular angle \(\beta\in[0,\pi]\) with the line linking the current node to the target point. The degree of path fitting is enhanced as \(\beta\) decreases. In the global coordinate system, the vector \(\overrightarrow{U_{p}U_{g}}\) denotes the direction from the current position to the target position, while vector \(\overrightarrow{U_{p}U_{pi}}\) (\(i=1,2,3,4\dots\)) denotes the possible heading of the UAVs toward the next location. Figure 1 provides a visual representation of this concept, and the red star represents the target point.  
The angle \(\beta\) can be calculated using the formula for finding the angle between two vectors in the global coordinate system.  
\[\beta_{i}=\cos^{-1}\frac{\overrightarrow{U_{p}U_{g}}\cdot\overrightarrow{U_ {p}U_{pi}}}{\overrightarrow{U_{p}U_{g}}\left|\left|\overrightarrow{U_{p}U_{pi }}\right|\right|}\,i=1,2,3,4\dots \tag{4}\]  
where \(\overrightarrow{U_{p}U_{g}}=\left(x_{g}-x_{p},\ y_{g}-y_{p}\right)\); \(\overrightarrow{U_{p}U_{pi}}=\left(x_{pi}-x_{p},\ y_{pi}-y_{p}\right)\), and \(x_{g},y_{g},x_{p},y_{p},x_{pi},y_{pi},y_{pi}\) are the coordinate values of the target point \(U_{g}\), the current point \(U_{P}\), and the next possible node \(U_{pi}\) in the global coordinate system.  
Equation (5) shows the improved heuristic function of steering cost.  
\[h(\beta)=w\times\beta\times h_{d} \tag{5}\]  
where \(h(\beta)\) is the heuristic function of steering cost, \(h_{d}\) is the initial distance-based heuristic function, and \(w\) is the weight coefficient, whose value is taken to adjust the strength of the heuristic information and facilitate the calculation and selection of the optimal path, mainly determined by the grid size and the steering cost function.  
The equation of the improved heuristic function is obtained as follows:  
\[h(n)=(1+k\times\beta)\times h_{d},\ \beta\in[0,\pi] \tag{6}\]  
Based on the difference between the current heading direction of the UAV and the target position, the steering cost proportion is adjusted accordingly to minimize each steering angle and approach the target direction, thus ensuring global or relatively optimal path planning.