*5.1.1 Measurement data*

The data measured by the sensors are obtained by driving the robo-mower on a field with long lawn grasses and short lawn grasses as well as without lawn grasses. The actual remote-controlled robo-mower is shown in **Figure 7**. The remote-control system through Bluetooth communication is incorporated in the robo-mower by mounting a mini-PC and running an ROS on it. The mini-PC can also handle the collected sensor data.

**Figure 7.** *Remote-controlled driving of Robo-mower.*

The collected data are manually categorized into long and short lawn grass datasets according to the height of the grass cutter from the ground. If the length of lawn grasses exceeds the height of the grass cutter, the lawn grass length is defined as long and otherwise, short. When the heights of lawn grasses and grass cutter are equal, a human operator determines whether the lawn grass is long or short according to the operating sound of the grass cutter. The measurement data are collected within a total time of 2.3 h. All data are collected on flatlands on sunny days.

consists of two stages. The first stage is used to estimate whether an area is with or without lawn grasses. In the second stage, an area is further estimated whether it has long or short lawn grasses when it is estimated to have lawn grasses. In the testing, four kinds of evaluation criteria are used. These are defined below [20].

*AI-Based Approach for Lawn Length Estimation in Robotic Lawn Mowers*

*DOI: http://dx.doi.org/10.5772/intechopen.97530*

**Predictions Positive** *TP FP*

*Accuracy* <sup>¼</sup> *TP* <sup>þ</sup> *TN*

*Precision* <sup>¼</sup> *TP*

*Recall* <sup>¼</sup> *TP*

*<sup>F</sup>* � *Measure* <sup>¼</sup> <sup>2</sup> <sup>∗</sup> *Presision* <sup>∗</sup> *Recall*

where *TP*,*TN*, *FP,* and *FN* denote "True Positive," "True Negative," "False

Seven combinations of sensor data used are shown in **Table 4**. These combinations cover all possible cases. Using the measurement data from **C1** to **C7**, the best combination of sensor data is determined based on the above-mentioned evaluation

1.Select the sensor data corresponding to the cases shown in **Table 4** collected in three ground conditions, that is, "Long Lawn Grasses," "Short Lawn Grasses,"

Determine the subset of sensor data (1) and partition it to configure the binary decision trees and to test the RF algorithm according to the number of the time

1.Accuracy

2.Precision

3.Recall

4.F-Measure

*5.1.4 Evaluation results*

criteria.

**131**

Positive," and "False Negative," respectively.

The procedure of experiments is as follows.

and "Not Lawn Grasses."

frames shown in **Table 3**.

**Actuals**

**Negative** *FN TN*

*TP* <sup>þ</sup> *FP* <sup>þ</sup> *FN* <sup>þ</sup> *TN* (1)

*TP* <sup>þ</sup> *FP* (2)

*TP* <sup>þ</sup> *FN* (3)

*Precision* <sup>þ</sup> *Recall* (4)

**Positive Negative**

#### *5.1.2 Features for classifying data*

Statistical features of input data f g *xi* ð Þ *i* ¼ 1, 2, ⋯, *q* for classification are calculated, including (i) maximum value, (ii) minimum value, (iii) average value, (iv) median value, (v) standard deviation value, (vi) kurtosis value, and (vii) skewness value. The values of seven feature types are normalized into the interval [˗1,1]. These features are used in configuring binary decision trees, and they are calculated for each time frame obtained approximately every 3.2 s over 2.3-h measurement data. The details of the collected data are shown in **Table 2**. Even if the total time for data collection is less than 2.3 h because of, for example, some issues with measurement devices, the obtained data are used.

In the experiments, a subset of time frames obtained from each field data is used for configuring the binary decision trees, and the completed forest is applied to the remaining test data. Then, classification performance of the RF algorithm is evaluated.

The number of time frames (training data) used to configure the binary decision trees in each group is chosen at random from the measurement data. The remaining time frames are used as test data for evaluating the RF's performance. These are shown in **Table 3**.

#### *5.1.3 Evaluation criteria*

Each of the time frame data has its label, that is, long lawn grasses, short lawn grasses, and not lawn grasses, and the estimation can be verified. This process


**Table 2.**

*Specifications of measurement data for evaluating RF algorithm.*


**Table 3.**

*Number of time frames for training and testing RF algorithm.*

#### *AI-Based Approach for Lawn Length Estimation in Robotic Lawn Mowers DOI: http://dx.doi.org/10.5772/intechopen.97530*

consists of two stages. The first stage is used to estimate whether an area is with or without lawn grasses. In the second stage, an area is further estimated whether it has long or short lawn grasses when it is estimated to have lawn grasses. In the testing, four kinds of evaluation criteria are used. These are defined below [20].


1.Accuracy

The collected data are manually categorized into long and short lawn grass datasets

Statistical features of input data f g *xi* ð Þ *i* ¼ 1, 2, ⋯, *q* for classification are calculated, including (i) maximum value, (ii) minimum value, (iii) average value, (iv) median value, (v) standard deviation value, (vi) kurtosis value, and (vii) skewness value. The values of seven feature types are normalized into the interval [˗1,1]. These features are used in configuring binary decision trees, and they are calculated for each time frame obtained approximately every 3.2 s over 2.3-h measurement data. The details of the collected data are shown in **Table 2**. Even if the total time for data collection is less than 2.3 h because of, for example, some issues with

In the experiments, a subset of time frames obtained from each field data is used for configuring the binary decision trees, and the completed forest is applied to the remaining test data. Then, classification performance of the RF algorithm is evaluated. The number of time frames (training data) used to configure the binary decision trees in each group is chosen at random from the measurement data. The remaining time frames are used as test data for evaluating the RF's performance. These are

Each of the time frame data has its label, that is, long lawn grasses, short lawn grasses, and not lawn grasses, and the estimation can be verified. This process

**Groups Number of time frames**

Long Lawn Grasses 2,356 Short Lawn Grasses 1,575 Not Lawn Grasses 3,374 Total 7,305

**Groups Number of time frames**

Long Lawn Grasses 1,686 670 Short Lawn Grasses 904 671 Not Lawn Grasses 2,705 669 Total 5,295 2,010

**For training For testing**

according to the height of the grass cutter from the ground. If the length of lawn grasses exceeds the height of the grass cutter, the lawn grass length is defined as long and otherwise, short. When the heights of lawn grasses and grass cutter are equal, a human operator determines whether the lawn grass is long or short according to the operating sound of the grass cutter. The measurement data are collected within a total

time of 2.3 h. All data are collected on flatlands on sunny days.

measurement devices, the obtained data are used.

*Specifications of measurement data for evaluating RF algorithm.*

*Number of time frames for training and testing RF algorithm.*

*5.1.2 Features for classifying data*

*Robotics Software Design and Engineering*

shown in **Table 3**.

**Table 2.**

**Table 3.**

**130**

*5.1.3 Evaluation criteria*

$$Accuracy = \frac{TP + TN}{TP + FP + FN + TN} \tag{1}$$

2.Precision

$$Precision = \frac{\text{TP}}{\text{TP} + \text{FP}} \tag{2}$$

3.Recall

$$Recall = \frac{TP}{TP + FN} \tag{3}$$

4.F-Measure

$$F-Measure = \frac{2 \ast Precision \ast Recall}{Precision + Recall} \tag{4}$$

where *TP*,*TN*, *FP,* and *FN* denote "True Positive," "True Negative," "False Positive," and "False Negative," respectively.

#### *5.1.4 Evaluation results*

Seven combinations of sensor data used are shown in **Table 4**. These combinations cover all possible cases. Using the measurement data from **C1** to **C7**, the best combination of sensor data is determined based on the above-mentioned evaluation criteria.

The procedure of experiments is as follows.

1.Select the sensor data corresponding to the cases shown in **Table 4** collected in three ground conditions, that is, "Long Lawn Grasses," "Short Lawn Grasses," and "Not Lawn Grasses."

Determine the subset of sensor data (1) and partition it to configure the binary decision trees and to test the RF algorithm according to the number of the time frames shown in **Table 3**.


"TreeBagger" included in "Statics and Machine Learning Toolbox" in MATLAB [21] is used for implementing the RF algorithm. The processing time for configuring 1,000 binary decision trees is less than ten minutes on a PC with the standard performances. The completed forest is applied to the testing data whose size is approximately 700 in each of the three ground conditions shown in **Table 3**. The estimating time is negligibly small, and this is no issue in the actual Hybrid Twin approach. **Table 5** shows the performance of the algorithm according to different sensor data combinations. Seven cases are evaluated with respect to the measurement criteria in each ground condition. The most important performance is the accuracy, and it increases when the built-in sensor data are used. Particularly, **C6** and **C7**, excluding the built-in horizontal or vertical angle sensor, have higher accuracy. It seems reasonable that the battery status and motor rotation conditions contribute to higher performance because the rotation of the motor becomes high when it encounters long lawn grasses. On the other hand, the load on both the grass cutting motor and traveling motor is reduced when the robo-mower travels on a ground without lawn grasses. From the evaluation results, **C6** is desirable among

*AI-Based Approach for Lawn Length Estimation in Robotic Lawn Mowers*

*DOI: http://dx.doi.org/10.5772/intechopen.97530*

1. the accuracy is high, with a difference of only 0.1 points from maximum

Especially, the low recall ratio of Short Lawn Grasses means that the probability of incorrectly recognizing short lawn grasses as long lawn grasses or a ground other than lawn grasses is high. Then, the traveling speed of the robo-mower is reduced, and the rotation of the grass cutting motor is increased. This would increase the working time and waste electric energy. Moreover, when a short lawn grass area is incorrectly classified as a ground without lawn grasses, the robo-mower will not move on the areas and will not cut lawn grasses. Therefore, it would be concluded that **C6** is the best combination in this evaluation results. Sensor data, including the acceleration and angular acceleration values obtained using the 9-axis IMU attached inside the robo-mower; the voltage, current, and power of the battery; the rotation

**Combinations of sensor data C1 C2 C3 C4 C5 C6 C7 Accuracy** 75.84 77.52 86.32 90.92 91.58 92.18 92.28 **Long Lawn Grasses Precision** 77.06 70.70 92.68 92.60 91.46 92.66 91.04

**Short Lawn Grasses Precision** 72.66 73.84 87.30 90.48 92.12 89.40 92.04

**Not Lawn Grasses Precision** 77.06 86.34 80.24 89.70 91.34 94.40 93.72

**Average of Precision, Recalls, and F-measures** 75.56 77.20 86.35 90.89 91.58 92.17 92.25

**Recall** 73.02 67.70 93.46 93.60 93.64 93.44 93.56 **F-measure** 74.99 69.17 93.07 93.10 92.54 93.05 92.28

**Recall** 60.88 68.28 70.06 82.00 83.26 87.08 85.58 **F-measure** 66.25 70.95 77.73 86.03 87.47 88.22 88.69

**Recall** 93.60 96.60 95.46 97.20 97.90 96.08 97.70 **F-measure** 84.53 91.18 87.19 93.30 94.51 95.23 95.67

2. the recall ratio of Short Lawn Grasses, 87.08%, is the highest.

seven cases. The reason is that

92.28%,

**Table 5.**

**133**

*Evaluation results for sensor fusions.*

The number of binary decision trees, that is, the size of the forest is set to 1,000. Each binary decision tree is configured using the seven features mentioned in 5.1.2 until each leaf coincides with one of three ground conditions. An example of an actually constructed binary decision tree is shown in **Figure 8**. Here, the feature, median value, obtained from built-in vertical angle sensor data with its threshold 370.75, is used for classifying the input data on the root node. The class


#### **Table 4.**

*Combinations of sensor data.*

**Figure 8.** *Example of binary decision tree in RF algorithm.*

## *AI-Based Approach for Lawn Length Estimation in Robotic Lawn Mowers DOI: http://dx.doi.org/10.5772/intechopen.97530*

"TreeBagger" included in "Statics and Machine Learning Toolbox" in MATLAB [21] is used for implementing the RF algorithm. The processing time for configuring 1,000 binary decision trees is less than ten minutes on a PC with the standard performances. The completed forest is applied to the testing data whose size is approximately 700 in each of the three ground conditions shown in **Table 3**. The estimating time is negligibly small, and this is no issue in the actual Hybrid Twin approach. **Table 5** shows the performance of the algorithm according to different sensor data combinations. Seven cases are evaluated with respect to the measurement criteria in each ground condition. The most important performance is the accuracy, and it increases when the built-in sensor data are used. Particularly, **C6** and **C7**, excluding the built-in horizontal or vertical angle sensor, have higher accuracy. It seems reasonable that the battery status and motor rotation conditions contribute to higher performance because the rotation of the motor becomes high when it encounters long lawn grasses. On the other hand, the load on both the grass cutting motor and traveling motor is reduced when the robo-mower travels on a ground without lawn grasses. From the evaluation results, **C6** is desirable among seven cases. The reason is that


Especially, the low recall ratio of Short Lawn Grasses means that the probability of incorrectly recognizing short lawn grasses as long lawn grasses or a ground other than lawn grasses is high. Then, the traveling speed of the robo-mower is reduced, and the rotation of the grass cutting motor is increased. This would increase the working time and waste electric energy. Moreover, when a short lawn grass area is incorrectly classified as a ground without lawn grasses, the robo-mower will not move on the areas and will not cut lawn grasses. Therefore, it would be concluded that **C6** is the best combination in this evaluation results. Sensor data, including the acceleration and angular acceleration values obtained using the 9-axis IMU attached inside the robo-mower; the voltage, current, and power of the battery; the rotation


#### **Table 5.** *Evaluation results for sensor fusions.*

2.Configure the binary decision trees.

*Robotics Software Design and Engineering*

**Sensors Mounting**

9-axis Inertial Measurement

Unit

**Table 4.**

**Figure 8.**

**132**

*Example of binary decision tree in RF algorithm.*

*Combinations of sensor data.*

criteria.

3.Evaluate the performances of the RF algorithm based on the evaluation

370.75, is used for classifying the input data on the root node. The class

**positions**

The number of binary decision trees, that is, the size of the forest is set to 1,000. Each binary decision tree is configured using the seven features mentioned in 5.1.2 until each leaf coincides with one of three ground conditions. An example of an actually constructed binary decision tree is shown in **Figure 8**. Here, the feature, median value, obtained from built-in vertical angle sensor data with its threshold

> Angular Acceleration

> Angular Acceleration

Built-In Battery Voltage √√√√√

**Measurements C1 C2 C3 C4 C5 C6 C7**

Current √√√√√ Power √√√√√

√√ √√√√

√ √√

Inside of Body Acceleration √√ √√√√

Surface of Body Acceleration √ √√

Rotation of Grass Cutting Motor √√√√√ Rotation of Traveling Motor √√√√√

Horizontal/Vertical Angles √√√

speed of the grass cutting and traveling motors obtained using built-in sensors, are used in **C6**.
