# Smart Obstacle Avoidance Using a Danger Index for a Dynamic Environment
## 2 The Proposed Method
### Danger Index Based Artificial Potential Field (DIAPF) for a Dynamic Environment  
To avoid the moving obstacles, the APF must consider not only the position information of the obstacles, but also the motion information of the obstacles, e.g., the direction and magnitude of the velocity. In the paper, we define the motion model of the dynamic obstacle as:  
\[\delta(t+1) =\delta(t)+v_{o}(t)\times\triangle t, \tag{14}\] \[v_{o}(t+1) =v_{o}(t)+a_{o}^{{}^{\prime}}(t)\times\triangle t, \tag{15}\]  
which can be written in matrix form:  
\[p(t+1)=Ap(t)+a_{o}, \tag{16}\]  
where \(\delta(t)=(x_{o},y_{o})^{T}\) is the coordinate of the dynamic obstacle, \(p(t+1)=(\delta(t),v_{o}(t))^{T}\) is the state vector, \(A= \begin{bmatrix}1&\triangle t\\ 0&1\end{bmatrix} \) is the state transition matrix, and \(a_{o}=(0,a_{o}^{{}^{\prime}})^{T}\) is the acceleration of the dynamic obstacle. In this paper, a uniform motion model is adopted and the \(a_{o}\) is a zero vector. The APF should not only consider the spatial location of the dynamic obstacle, but also consider the motion state of the dynamic obstacle. Therefore, the velocity repulsive potential field is added to the dynamic window based artificial potential field function (DVAPF) to avoid dynamic obstacles, which is defined as  
\[U_{v}(v_{ro})= \begin{cases}\frac{1}{2}k_{ro}v_{ro}^{2},&0\leq\rho_{cm}\leq\rho_ {cmax}\cap\alpha\in(-\frac{\pi}{2},\frac{\pi}{2}),\\ 0,&\text{otherwise},\end{cases}  \tag{17}\]  
where \(k_{ro}\) is a proportionality constant, \(v_{ro}=v_{r}-v_{o}\) is the relative velocity between the robot and the dynamic obstacle, \(\alpha\) is the angle between the \(v_{ro}\) and the vector from the robot to the obstacle, \(\rho_{cmax}\) is the maximum range of the local map, and \(\rho_{cm}\) is the current distance between the robot and the dynamic obstacle. The velocity repulsive potential field starts to work when the dynamic obstacle enters the local map whose range is defined by the distance parameter \(\rho_{cmax}\), which can be chosen according to the sensor range. The velocity repulsive force is the negative gradient of the velocity repulsive potential function:  
\[F_{v}(v_{ro})=-\
abla(U_{v}(v_{ro})), \tag{18}\] \[F_{v}(v_{ro})= \begin{cases}k_{ro}v_{ro},&0\leq\rho_{cm}\leq\rho_{ cmax}\cap\alpha\in(-\frac{\pi}{2},\frac{\pi}{2})\\ 0,&\text{otherwise}\end{cases} . \tag{19}\]  
The DVAPF approach can handle dynamic obstacle avoidance problem when the velocity difference between the robot and the dynamic obstacle is large. The effectiveness of the velocity repulsive force can be decreased if the relative velocity is small. We here propose an improved method using a novel danger index considering relative distance and velocity between the robot and the dynamic obstacle, which includes three factors:  
(1) Distance influence factor:  
\[f_{cm}(\rho_{cm})= \begin{cases}\eta(\frac{1}{\rho_{cm}}-\frac{1}{\rho_{cmax}} ),&\rho_{cm}\leq\rho_{cmax},\\ 0,&\rho_{cm}>\rho_{cmax},\end{cases}  \tag{20}\]  
where \(\eta=(\frac{\rho_{cmin}\rho_{cmax}}{\rho_{cmax}-\rho_{cmin}})\) is the distance scale factor, and \(\rho_{cmin}\) is the minimum allowed distance between the robot and the dynamic obstacle. Distance influence factor is influenced by the distance relationship between the robot and the dynamic obstacle. The closer the distance between the robot and the dynamic obstacle, the larger the distance influence factor. (2) Speed influence factor:  
\[k_{o}=sgn(\varepsilon\times|v_{o}|-|v_{r}|), \tag{21}\]  
where \(\varepsilon\) is the speed scale factor, \(|v_{o}|\) and \(|v_{r}|\) are the magnitudes of the dynamic obstacle velocity and robot velocity, respectively, and \(sgn()\) is the sign function. Speed influence factor is influenced by the speed relationship between the robot and the dynamic obstacle. If the speed of the dynamic obstacle is \(\varepsilon\) times the speed of the robot, the speed influence factor is an integer and vice versa. (3) Danger index:  
\[DI=