# Autonomous Obstacle Avoidance with Improved Deep Reinforcement Learning Based on Dynamic Huber Loss
## 4 Experimental Setup and Simulation Analysis
### Analysis of Test Results  
To evaluate the training outcomes, this paper tests the UAV's flight trajectory, success rate, and path length. The UAV flight trajectory illustrates the flight route's characteristics, while the success rate reflects task completion, calculated as follows:  
\[Sr=\frac{Number\ \ \ of\ \ \ successful\ \ \ trials}{Total\ \ \ \ trials}\times 100\% \tag{19}\]  
where \(Sr\) represents the success rate, the numerator is the number of successful trials, the denominator is the total number of trials, multiplied by 100 to get the percentage; the path length measures the distance efficiency of the flight, and its calculation formula is  
\[L_{avg}=\frac{\sum_{i=1}^{N}L_{i}}{N} \tag{20}\]  
where \(L_{avg}\) represents the average path length, \(L_{i}\) is the path length of the \(i\)-th trial, and \(N\) is the total number of trials; in this experiment, the number of trials is 2000. Through the comprehensive evaluation of these three indicators, the effectiveness of the training was comprehensively determined. Figure 7 shows the UAV flight path diagrams for different loss functions in static and dynamic environments, using both Soft and Hard updates. From the figure, it can be seen that the Dynamic Huber loss series shows better performance in all cases. As in Figure 7a, in the static environment based on the Soft update, Dynamic Huber loss can more accurately adjust the UAV's flight strategy according to the environment information, which makes the path more reasonable and efficient, so its path planning can avoid obstacles more efficiently compared with other loss functions. As in Figure 7b,c, in a dynamic environment, Dynamic Huber loss can better cope with the environment's dynamic changes, whether Soft or Hard updates. With the Hard update, although it will be disturbed by dynamic factors, its path fluctuation is relatively small compared with other loss functions, which indicates that it has strong stability and adaptability; with the Soft update, the advantage is more obvious, and it \begin{table}
\begin{tabular}{c c c c c c} \hline
**Environment** & **Update Method** & **MSE** & **Smooth L1 Loss** & **Huber Loss** & **Dynamic Huber Loss** \\ \hline Static & Soft & 1432.43 & 406.11 & 385.59 & 339.57 \\ \hline \multirow{3}{*}{Dynamic} & Hard & 646.92 & 591.95 & 482.15 & 389.47 \\  & Soft & 512.84 & 486.55 & 433.45 & 354.91 \\ \cline{1-1}  & Wind Soft & 582.30 & 525.89 & 458.59 & 406.67 \\ \hline \end{tabular}
\end{table} 
Table 3: Length of time of UAV obstacle avoidance training. can make full use of the characteristics of Soft updating to further optimize the path, reduce the unnecessary steering and detours, and adapt to the dynamic environment changes more flexibly. Figure 7d shows the flight paths of UAVs during obstacle avoidance training in a dynamic environment with wind interference and Soft updates. The wind interference increases environmental uncertainty, greatly enhancing the difficulty of UAV obstacle avoidance. However, the Dynamic Huber loss, with its characteristic of dynamically adjusting the gradient, helps the UAV better cope with the interference. Its path planning can not only avoid obstacles but also minimize the impact of wind interference on the flight trajectory, maintaining a relatively stable flight path. The Dynamic Huber loss outperforms other loss functions in path planning, coping with environmental changes, and resisting wind disturbances, demonstrating excellent performance and strong adaptability. Analyzing the success rate of the UAV obstacle avoidance test in Table 4, it can be seen that the choice of the loss function and updating method has a key impact on the success rate of UAV obstacle avoidance, with the Soft updating method and Dynamic Huber loss having a significant advantage. In the static environment, the success rate of MSE is only 0.10% when using the Soft update, which indicates that the UAV performs poorly due to its inaccurate capture of static obstacle features, resulting in frequent decision-making errors.