# Smart Obstacle Avoidance Using a Danger Index for a Dynamic Environment
## 2 The Proposed Method
### Dynamic Window Based Artificial Potential Field (DAPF)  
In the artificial potential field, the robot motion is controlled by the attractive force and the repulsive force, i.e., the attractive force is generated by the distance and direction to the target point, whereas the repulsive force is generated by the distance and direction to obstacles. The forces of the robot in the artificial potential field are shown in Figure 1, where \(F_{2}\) is the repulsive force between the obstacle and the robot \(F_{1}\) is the attractive force between the target point and the robot, and \(F\) is the resultant force for controlling the robot. The attractive potential field function is defined as:  
\[U_{att}(\phi)=\frac{1}{2}k_{a}(\phi-\phi_{g})^{2}, \tag{1}\]  
where \(\phi=(x,y)^{T}\) is the coordinate of the robot, \(k_{a}\) is the coefficient constant of the attractive field, and \(\phi_{g}\) is the coordinate of the target point. The negative gradient of the attractive potential field function is defined as the attractive force function, which is:  
\[F_{att}(\phi)=-\
abla(U_{att}(\phi))=k_{a}(\phi_{g}-\phi), \tag{2}\]  
where \(F_{att}(\phi)\) is a vector directed toward to \(\phi_{g}\), which is a linear correlation with the distance from \(\phi\) to \(\phi_{g}\). Obstacles provide repulsive force and repel the robot. When the robot is far enough from obstacles, obstacles will not affect the motion of the robot. As shown in Equation (3), the repulsion potential field function can be defined as:  
\[U_{req}(\phi)= \begin{cases}\frac{1}{2}k_{r}(\frac{1}{d(\phi)}-\frac{1}{d_{max }})^{2},&d(\phi)\leq d_{max},\\ 0,&d(\phi)>d_{max},\end{cases}  \tag{3}\]  
where \(k_{r}\) is the coefficient constant of the repulsion field, \(d_{max}\) is the maximum impact extent of the single obstacle, and \(d(\phi)\) is the current distance between the robot and the obstacle. The repulsive force is the negative gradient of the repulsive potential function, which is  
\[F_{req}(\phi)=-\
abla(U_{req}(\phi)), \tag{4}\]  
\[F_{req}(\phi)= \begin{cases}k_{r}(\frac{1}{d(\phi)}-\frac{1}{d_{max}})\frac{1} {d(\phi)^{2}}\cdot\frac{\partial U(\phi)}{\partial\phi},&d(\phi)\leq d_{max}, \\ 0,&d(\phi)>d_{max}.\end{cases}  \tag{5}\]  
The total repulsive potential field is the summation of the repulsive potential fields from all obstacles. The final artificial potential field function is as follows:  
Figure 1: Definition of attractive force and repulsive force in artificial potential field. \[U(\phi)=U_{att}(\phi)+\sum U_{req}(\phi). \tag{6}\]  
The resultant force on the robot is \(F(x)=F_{att}(x)+\sum F_{req}(x)\). In some situations, the goal can be unreachable and the robot can be trapped in a local minimum region using the traditional APF approach as shown in Figure 2. For instance, the robot can not reach the target point when the target point is very close to the obstacle. In addition, the resultant force on the robot can be reduced gradually until the target point is reached. However, the resultant force of the robot is also likely to be zero or minimized, when the attractive force and repulsive force are almost equal and collinear but in the opposite direction. The robot in this situation is trapped in a local minimum region. To solve the GNRON problem, the distance between the current position and the target position can be added to the repulsion field function, such that the repulsive force can be relatively reduced when the robot closes to the target point. The improved repulsive potential field function is defined as  
\[U_{req}(\phi)= \begin{cases}\frac{1}{2}k_{r}(\frac{1}{d(\phi)}-\frac{1}{d(\phi )})^{2}(\phi-\phi_{g})^{n},&d(\phi)\leq d_{max},\\ 0,&d(\phi)>d_{max},\end{cases}  \tag{7}\]  
where \(k_{r}\) is the repulsion field coefficient constant and \(n\) is an arbitrary real number which is greater than zero. The improved repulsive force function is defined as  
\[F_{req}(\phi)= \begin{cases}F_{req1}(\phi)+F_{req2}(\phi),&d(\phi)\leq d_{max },\\ 0,&d(\phi)>d_{max},\end{cases}