*2.2. 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'(t) \times \triangle t,\tag{15}$$

which can be written in matrix form:

$$Ap(t+1) = Ap(t) + a\_{0\prime} \tag{16}$$

where *δ*(*t*)=(*xo*, *yo*)*<sup>T</sup>* is the coordinate of the dynamic obstacle, *p*(*t* + 1)=(*δ*(*t*), *vo*(*t*))*<sup>T</sup>* is the state vector, *A* = 1 *t* 0 1 is the state transition matrix, and *ao* = (0, *a <sup>o</sup>*)*<sup>T</sup>* is the acceleration of the dynamic obstacle. In this paper, a uniform motion model is adopted and the *ao* 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

$$\mathcal{U}\_{\upsilon}(v\_{ro}) = \begin{cases} \frac{1}{2} k\_{ro} v\_{ro}^2 & 0 \le \rho\_{cm} \le \rho\_{c\max} \cap a \in \left(-\frac{\pi}{2}, \frac{\pi}{2}\right), \\ 0, & \text{otherwise}, \end{cases} \tag{17}$$

where *kro* is a proportionality constant, *vro* = *vr* − *vo* is the relative velocity between the robot and the dynamic obstacle, *α* is the angle between the *vro* and the vector from the robot to the obstacle, *ρcmax* is the maximum range of the local map, and *ρ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 *ρ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\_{rv}) = -\nabla \left( \mathcal{U}\_v(v\_{rv}) \right), \tag{18}$$

$$F\_{\upsilon}(v\_{r0}) = \begin{cases} k\_{\upsilon 0} v\_{r0}, & 0 \le \rho\_{\text{cm}} \le \rho\_{\text{cmax}} \cap \mathfrak{a} \in \left(-\frac{\pi}{\mathfrak{T}}, \frac{\pi}{\mathfrak{T}}\right) \\ 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 \left( \frac{1}{\rho\_{cm}} - \frac{1}{\rho\_{cmax}} \right), & \rho\_{cm} \le \rho\_{cmax} \\ 0, & \rho\_{cm} > \rho\_{cmax} \end{cases} \tag{20}$$

where *η* = ( *<sup>ρ</sup>cminρcmax <sup>ρ</sup>cmax*−*ρcmin* ) is the distance scale factor, and *<sup>ρ</sup>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\_{\mathcal{o}} = \text{sgn}(\varepsilon \times |\upsilon\_{\mathcal{o}}| - |\upsilon\_{\mathcal{I}}|), \tag{21}$$

where *ε* is the speed scale factor, |*vo*| and |*vr*| 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 *ε* times the speed of the robot, the speed influence factor is an integer and vice versa.

(3) Danger index:

$$DI = \begin{cases} k\_{ro}(v\_r - f\_{cm}v\_o), & k\_o > 0 \cap a \in \left(-\frac{\pi}{2}, \frac{\pi}{2}\right) \cap f\_{cm} > 0, \\ k\_{ro}(v\_r + f\_{cm}v\_o), & k\_o \le 0 \cap \beta \in \left(-\frac{\pi}{2}, \frac{\pi}{2}\right) \cap f\_{cm} > 0, \\ 0, & \text{otherwise}, \end{cases} \tag{22}$$

where *kro* is a proportionality constant, *fcm* is the distance influence factor, *α* is the angle between the (*vr* − *fcmvo*) and the vector from the robot to the obstacle. *β* is the angle between the (*vr* + *fcmvo*) and the vector from the obstacle to the robot.

The novel danger index includes distance influence factor and speed influence factor. The robot can make smarter avoidance decisions according to the speed influence factor, i.e., the robot can move in front of the moving obstacle if the speed of the robot is not larger than *ε* times that of the dynamic obstacle, whereas the robot can move behind the moving obstacle for other situations.

If the distance between the robot and the dynamic obstacle is very close, the distance influence factor will be large, such that the robot will move parallel with the dynamic obstacle, which is to ensure the safety of the path. If the distance between the robot and the dynamic obstacle is far, the distance factor will be small, such that the robot will not over-react to the obstacle motion, which can increase the efficiency of the robot motion. Furthermore, if the moving obstacle is outside of the local map, i.e., *ρcm* > *ρcmax*, the danger index is 0, so the robot will not react to such a situation.

The danger index combines the distance influence factor and the speed influence factor to optimize the planned path to avoid dynamic obstacles. The danger index based APF (DIAPF) function is defined as

$$\mathcal{U}\mathcal{U}'(\phi) = \mathcal{U}(\phi) + \frac{1}{2}DI^2,\tag{23}$$

where *U*(*φ*) is the value returned from the DAPF function. To summarize, the whole algorithm of our proposed DIAPF approach in the dynamical environment is shown in Figure 4.

**Figure 4.** Danger Index Based Artificial Potential Field (DIAPF) based moving obstacle avoidance algorithm.
