*2.1. 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*<sup>2</sup> is the repulsive force between the obstacle and the robot *F*<sup>1</sup> is the attractive force between the target point and the robot, and *F* is the resultant force for controlling the robot.

**Figure 1.** Definition of attractive force and repulsive force in artificial potential field.

The attractive potential field function is defined as:

$$
\hbar L\_{att}(\phi) = \frac{1}{2} k\_d (\phi - \phi\_\%)^2,\tag{1}
$$

where *φ* = (*x*, *y*)*<sup>T</sup>* is the coordinate of the robot, *ka* is the coefficient constant of the attractive field, and *φ<sup>g</sup>* 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\_{\rm att}(\phi) = -\nabla(lI\_{\rm att}(\phi)) = k\_d(\phi\_{\S} - \phi),\tag{2}$$

where *Fatt*(*φ*) is a vector directed toward to *φg*, which is a linear correlation with the distance from *φ* to *φ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:

$$\mathcal{U}\_{req}(\phi) = \begin{cases} \frac{1}{2}k\_r(\frac{1}{d(\phi)} - \frac{1}{d\_{\text{max}}})^2, & d(\phi) \le d\_{\text{max}}, \\ 0, & d(\phi) > d\_{\text{max}}. \end{cases} \tag{3}$$

where *kr* is the coefficient constant of the repulsion field, *dmax* is the maximum impact extent of the single obstacle, and *d*(*φ*) 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) = -\nabla \left( \mathcal{U}\_{req}(\phi) \right), \tag{4}$$

$$F\_{req}(\phi) = \begin{cases} k\_I \left( \frac{1}{d(\phi)} - \frac{1}{d\_{\text{max}}} \right) \frac{1}{d(\phi)^2} \cdot \frac{\partial d(\phi)}{\partial \phi}, & d(\phi) \le d\_{\text{max}}, \\ 0, & d(\phi) > d\_{\text{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:

$$\mathcal{U}(\phi) = \mathcal{U}\_{att}(\phi) + \sum \mathcal{U}\_{req}(\phi). \tag{6}$$

The resultant force on the robot is *F*(*x*) = *Fatt*(*x*) + ∑ *Freq*(*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.

**Figure 2.** Problems of a traditional artificial potential field (APF): (**a**) unreachable goals with obstacles nearby (GNRON) and (**b**) 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

$$M\_{rq}(\boldsymbol{\phi}) = \begin{cases} \frac{1}{2}k\_r(\frac{1}{d(\boldsymbol{\phi})} - \frac{1}{d\_{\max}})^2(\boldsymbol{\phi} - \boldsymbol{\phi}\_{\mathcal{S}})^n, & d(\boldsymbol{\phi}) \le d\_{\max} \\ 0, & d(\boldsymbol{\phi}) > d\_{\max} \end{cases} \tag{7}$$

where *kr* 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\_{rq}(\phi) = \begin{cases} F\_{rq1}(\phi) + F\_{rq2}(\phi), & d(\phi) \le d\_{\text{max}}, \\ 0, & d(\phi) > d\_{\text{max}} \end{cases} \tag{8}$$

where *Freq*1(*φ*) and *Freq*2(*φ*) are two components of the *Freq*(*φ*), which are defined in Equation (9) and (10):

$$F\_{req1}(\phi) = k\_r(\frac{1}{d(\phi)} - \frac{1}{d\_{max}}) \frac{1}{d(\phi)^2} (\phi - \phi\_\S)^n \cdot \frac{\partial d(\phi)}{\partial \phi},\tag{9}$$

$$F\_{\text{req2}}(\phi) = \frac{1}{2}k\_r n(\frac{1}{d(\phi)} - \frac{1}{d\_{\text{max}}})^2 (\phi - \phi\_\%)^{n-1} \cdot \frac{\partial(\phi - \phi\_\%)}{\partial \phi}. \tag{10}$$

The direction of *Freq*1(*φ*) is from the obstacle to the mobile robot, and *Freq*2(*φ*) is from the robot to the target point.

*Appl. Sci.* **2019**, *9*, 1589

For solving the local minima problem, we propose a dynamic APF approach (DAPF), which employs the dynamic window approach (DWA) to predict the local minimum region and solve the oscillations. The key idea of the DWA is to sample a number of predicted trajectories according to the current position (*xt*, *yt*), direction *θ<sup>t</sup>* and velocity *vr* as shown in Figure 3. The sampled directions *θω* are the following:

$$
\theta\_{\omega} = \theta\_t + (\omega - t) \triangle \theta,\\
\omega = (1, \dots, t, \dots, n), \tag{11}
$$

where *θ<sup>t</sup>* is the current direction of the robot, *θ* is the angular step between samples and *n* is the number of samples. Using these sampled directions, we simulate a number of positions that the robot might go as

$$
\begin{bmatrix} x'\_1 & y'\_1 \\ \dots & \dots \\ x'\_t & y'\_t \\ \dots & \dots \\ x'\_n & y'\_n \end{bmatrix} = \begin{bmatrix} x\_t & y\_t \\ \dots & \dots \\ x\_t & y\_t \\ \dots & \dots \\ x\_t & y\_t \end{bmatrix} + \begin{bmatrix} v\_r \triangle t \cos(\theta\_1) & v\_r \triangle t \sin(\theta\_1) \\ \dots & \dots \\ v\_r \triangle t \cos(\theta\_t) & v\_r \triangle t \sin(\theta\_t) \\ \dots & \dots \\ v\_r \triangle t \cos(\theta\_n) & v\_r \triangle t \sin(\theta\_n) \end{bmatrix},\tag{12}
$$

where *x* <sup>1</sup>, ..., *x <sup>n</sup>* and *y* <sup>1</sup>, ..., *y <sup>n</sup>* are coordinates of simulated positions, and *vr* is the velocity of the robot. The final choice of the position can be defined as the one whose APF cost function is minimum:

$$
\begin{bmatrix} x & y \end{bmatrix} = \min(APF(\begin{bmatrix} \mathbf{x}'\_1 & \mathbf{y}'\_1 \\ \cdots & \cdots \\ \mathbf{x}'\_t & \mathbf{y}'\_t \\ \cdots & \cdots \\ \mathbf{x}'\_n & \mathbf{y}'\_n \end{bmatrix})),
\tag{13}
$$

where *x*, *y* is the coordinate of the position whose resultant force value is minimum.

**Figure 3.** Robot trajectories simulated by a dynamic window approach (DWA).

Based on the improved APF function, the closer the robot is to the target, the smaller the resultant force value is. Before the robot enters the obstacle's influence range, it applies the DWA approach to simulate positions and calculate the resultant force for every simulated position. If the simulated position is in the obstacle range, the resultant force value is less than 0. If the simulated position is outside of the obstacle range, the resultant force of the simulated position that is closer to the target point is less than the positions that are far from the target point. Finally, the robot can obtain a simulated position that is close to the target point but not in the obstacle area, such that the local minimum region can be avoided using the DAPF approach. If the target point is within the obstacle range, the DWA method will be stopped when the distance of the robot from the target point is less than the distance from the obstacle.
