*2.5. Improvement of Obstacle Avoidance Strategy*

The pusher robot will inevitably encounter obstacles during the operation of the cattle farm. The obstacle avoidance module is an essential part of the pusher robot to ensure that it can pass through obstacles during mobile operations. This paper chooses the artificial potential field method as the basis of the obstacle avoidance algorithm, and improves and analyzes the situation that it falls into the local optimum point.

#### 2.5.1. Artificial Potential Field Method

Artificial Potential Field (APF) is an obstacle avoidance strategy represented by artificially defined virtual forces [31,32]. The mobile robot is assumed to be a point, which moves in a virtual force field, which is composed of the gravitational field of the target point to the robot and the repulsion field of the obstacle to the robot. The gravitational field is generated by the target point, and the repulsive force field is composed of the force field generated by all obstacles [33].

As shown in Figure 6, the repulsive force of the obstacle acting on the mobile machine is denoted as *F*rep, and the direction is from the obstacle to the mobile robot; the gravitational force of the target point acting on the mobile robot is recorded as *F*att, and the direction is from the mobile robot to the target point, then the force that the mobile robot receives at this position is the combined force of the repulsion force *F*rep and the gravitational force *F*att is *F*.

**Figure 6.** Stress diagram of artificial potential field method.

In the process of path planning, the environment of the unmanned vehicle is treated in a two-dimensional space, but the entire potential field distribution is three-dimensional. As shown in Figure 7, the gravitational potential energy leads to the generation of the third dimension, which is the main force in the process of path planning of the unmanned vehicle. The obstacles in the driving environment form peaks in the potential field distribution map. Under the action of the potential field, the unmanned vehicle can only move from the high potential energy point to the low potential energy point, so that the unmanned vehicle will not hit the obstacles, and it can safely plan the obstacle avoidance route.

**Figure 7.** Three-dimensional diagram of artificial potential field obstacle avoidance.

Let the positions of the mobile robot, the target point, and the obstacle, be denoted as *q* = (*x*, *y*) *<sup>T</sup>* and *qg* = *xg*, *yg* , respectively, and *qobs* = (*xobs*, *yobs*) is the gravitational potential field generated by the target point to the mobile robot, and *Uatt*(*q*) is the repulsive potential field generated by the obstacle to the mobile robot.

When the mobile robot is far away from the target point, the target point should generate a larger gravitational force for the mobile robot to move the mobile robot towards the target point. At the same time, when the mobile robot is at the target point, the robot should be at the zero-force point, so the gravitational potential field function is expressed as:

$$\mathcal{U}\_{att}(q) = \frac{1}{2}\mathbb{\tilde{s}}\rho^2(q, q\_{\mathcal{S}}) \tag{9}$$

where *ξ* is the gain coefficient of the gravitational field, and *ρ*(*q*, *qg*) represents the distance between the target point and the current position of the mobile robot (expressed in Euclidean distance).

#### 2.5.2. Improvement of Artificial Potential Field Method

The artificial potential field method converts the complex environmental information around the mobile robot into a simple force field model, which can achieve a relatively good obstacle avoidance effect in general [34,35]. However, due to the limitations of the definition of the gravitational potential field function and the repulsive potential field function itself, there may be situations in which the set target cannot be reached as expected and local minima appear before reaching the set target point. The reason for the above situation is mainly due to the defects brought by the definition of the gravitational potential field function and the repulsive potential field function itself. If the gravitational and repulsive forces are zero when the mobile robot reaches the target point, then the target point is the global optimal point. Considering the above problems, the distance between the target point and the robot is introduced into the repulsion function, and the repulsion field function expression is redefined:

$$\mathrm{CL}\_{\mathrm{rep}}(q) = \begin{cases} \frac{1}{2} \eta \left[ \frac{1}{\rho(\eta, q\_{\mathrm{obs}})} - \frac{1}{\rho\_0} \right]^2 \left( X - X\_{\mathrm{goal}} \right)^n, \rho(q, q\_{\mathrm{obs}}) \le \rho\_0\\ 0 \quad \qquad \qquad \qquad \rho(q, q\_{\mathrm{obs}}) > \rho\_0 \end{cases} \tag{10}$$

where (*X* − *Xgoal*) is the distance between the robot and the target, and *n* is a constant and greater than 0. Similarly, the repulsive force on the mobile robot is the negative gradient of the repulsive force field, and the repulsive force *Frep* (*q*) is expressed as:

$$F\_{rep}(q) = \begin{cases} F\_{rep1} + F\_{rep2}, \rho(q, q\_{obs}) \le \rho\_0 \\ 0 & , \rho(q, q\_{obs}) > \rho\_0 \end{cases} \tag{11}$$

$$F\_{rep1} = \eta \left[ \frac{1}{\rho(q\_\prime q\_{obs})} - \frac{1}{\rho\_0} \right] \frac{1}{\rho^2 \rho(q\_\prime q\_{obs})} \left( X - X\_{\text{goal}} \right)^n \tag{12}$$

$$F\_{\rm rep2} = \frac{n}{2} \eta \left[ \frac{1}{\rho \left( q\_{\prime} q\_{\rm obs} \right)} - \frac{1}{\rho\_0} \right]^2 \left( X - X\_{\rm gon} \right)^{n-1} \tag{13}$$

In the formula, the direction of *Frep*<sup>1</sup> is from the obstacle to the mobile robot, and the direction of *Frep*<sup>2</sup> is from the target robot to the target point.

### **3. Results Analysis**
