2.4.2. Path Extraction

The boundary contour data are extracted from the fence point cloud using the point cloud vector method. First, the fence point cloud and its adjacent points projected on the XY plane are fitted with straight lines. Then, a point *P* in the fence point cloud is selected, and its adjacent point cloud is set *Pk* = {*P*0, *<sup>P</sup>*<sup>1</sup> ... *Pk*−1}, a straight line is set *u*·*x* + *v*·*y* = *c u*<sup>2</sup> + *v*<sup>2</sup> = 1 , and the LSM is used to fit the straight line. At this time, the vector *q*(*u*, *v*) is the normal vector of the point *P*. Then, referring to the content of the literature, the method where the maximum angle between adjacent points is greater than the set threshold is used to extract the fence outline point cloud, and the fence outline point cloud is recorded as the point set *U* = {*d*0, *d*<sup>1</sup> ... *dn*−1}. Finally, the positional relationship between the fence line and the fence outline data points is judged by Equation (7). After removing the data outside the fence line, the point cloud data inside the fence line are divided into the left point set (*UL*) and the right point set (*UR*).

$$\begin{cases} \begin{aligned} d\_{li} &= \frac{|k\_{l} \cdot \mathbf{x}\_{i} + b\_{l} - y\_{i}|}{\sqrt{k\_{l}^{2} + b\_{l}^{2}}} \\ d\_{ri} &= \frac{|k\_{r} \cdot \mathbf{x}\_{i} + b\_{r} - y\_{i}|}{\sqrt{k\_{r}^{2} + b\_{r}^{2}}} \\ \mathcal{U}\_{L} &= \left\{ (k\_{l} \cdot \mathbf{x}\_{i} + b\_{l} - y\_{i}) \cdot (k\_{r} \cdot \mathbf{x}\_{i} + b\_{r} - y\_{i}) < \right. \\ &0 \cap d\_{li} - d\_{ri} < 0 |d\_{i}(\mathbf{x}\_{i}, y\_{i}) \in \mathcal{U} \\ \mathcal{U}\_{R} &= \left\{ (k\_{l} \cdot \mathbf{x}\_{i} + b\_{l} - y\_{i}) \cdot (k\_{r} \cdot \mathbf{x}\_{i} + b\_{r} - y\_{i}) < \right. \\ &0 \cap d\_{li} - d\_{ri} > 0 |d\_{i}(\mathbf{x}\_{i}, y\_{i}) \in \mathcal{U} \end{aligned} \end{cases} \tag{7}$$

In the formula, *dli* and *dri* are the distance between the fence outline point *di*(*xi*, *yi*) and the left and right fence lines, m; *i* is the index number of the point set, *i* = 0, 1, 2, ... , *n*−1; *n* is the number of point clouds of fence outline.

When the cows have been feeding for a period of time, the cows will push the forage to the outside at will, causing part of the forage to enter the area where they cannot eat, and the shape of the forage pile becomes irregular and the thickness of the pile becomes uneven. Therefore, the pusher robot is operated along the outermost part of the no-eating area, and the forage in the no-eating area is pushed to the eating area. As shown in Figure 5, during the operation of the pushing robot, the sideline of the auger always coincides with the inner boundary of the inaccessible area. The initial path is approximated by the translation transformation of the fence line fitted by the two methods. In this study, the intercept (*b*1) of the initial path was used as the index, the width of the edible area was 70 cm, and the length of the auger of the pushing robot was 110 cm.

$$b\_1 = b\_0 + m\_1 + \frac{1}{2}m\_2\tag{8}$$

where *b*<sup>0</sup> is the intercept of the fence line, *m*<sup>1</sup> is the width of the edible area, and *m*<sup>2</sup> is the length of the auger of the pushing robot.

**Figure 5.** Working diagram of grass pushing robot.
