## 3 Dynamic Window Approach
### Improvement of the DWA Algorithm  
When the robot and the dynamic obstacle are in close proximity to each other or their trajectories intersect at the same point at a certain moment, the robot may opt to take a longer detour in order to avoid the dynamic obstacle, resulting in a deviation from the original heading. This behavior not only lowers the robot's path planning accuracy but also may have an impact on its overall operational efficiency. Therefore, in order to effectively address this issue, an improved dynamic window method is proposed, which introduces the concept of a \"stop-and-wait state\". In this state, the robot halts its advancement and gives priority to the passage of moving obstacles, thereby avoiding unnecessary yawing caused by sharp turns or detours.  
The improved algorithm constrains the range detection of the robot by setting distance and angle thresholds to ensure that the robot can respond in a timely manner when the obstacle is close and there is a risk of collision. Specifically, the distance threshold \(\mathrm{d}=2\) and the angle threshold \(\mathrm{\theta}=45^{\circ}\) are set as judgment conditions, as shown in Figure 2. When a moving obstacle enters this detection range, the robot automatically enters the stop-and-wait state, halts its advancement and waits for the obstacle to pass, thereby reducing the risk of collision.  
As shown in Figures 3a,b and 4a,b, the black squares represent known static obstacles, the gray squares represent unknown static obstacles, the yellow squares represent dynamic obstacles, the blue triangle represents the robot's starting point, and the blue circle represents the robot's endpoint. As shown in Figure 3a, when the robot and the dynamic obstacle coincide with the path point at a certain moment, the traditional dynamic window method will deviate from the original heading and go further and further in order to bypass the dynamic obstacle. However, in the enhanced dynamic window approach shown in  
Figure 2: Parking-and-waiting strategy.  
Figure 2(b), the robot will halt and wait until the moving obstacle passes, and then the robot initiates movement.  
Due to the limitations of the traditional dynamic window approach (DWA) in handling complex environments, especially when encountering U-shaped obstacles, the robot often falls into a local optimal solution, as shown in Figure 3(a). For this purpose, this study designed an improved algorithm that utilizes the current position information of the robot along with the direction angle and simultaneously combined it with ultrasonic sensors to identify possible trap regions by predicting the grid nodes in the forward direction of the robot and detecting whether these nodes are occupied by obstacles.  
By identifying and circumventing these local optimal solutions, the robot is capable of replanning its path, as shown in Figure 3(b), thereby enhancing the global optimality and operational efficiency of the overall path planning. The application of this method in complex dynamic environments demonstrates stronger adaptability, especially in the face of dense or irregular obstacle environments, which helps to greatly increase the stability and versatility of the robot's navigation system.