## 9 Algorithms, AI Models and Digital Twins
### Algorithms in Agricultural UGVs  
Algorithms are crucial for enhancing the operational efficiency and precision of UGVs. This include navigation, target detection and recognition, sensor data noise reduction, and actuator control (though this work does not focus on the latter). UGVs equipped with cameras and sensors use image processing algorithms to analyze visual data and make informed decisions:  
* Edge Detection algorithms, such as Canny and Sobel, are used to identify the boundaries of objects within images. This is crucial for tasks like crop row detection [96], the diagnosis of plant health issues, and discrimination between crops, weeds, and the soil background.
* Image segmentation algorithms assign each pixel to a class in order to partition the image content at a fine grade level and simplify analysis. Techniques like k-means clustering and watershed segmentation help to isolate plants from the background for precise monitoring.
* Feature Extraction techniques identify specific characteristics within an image, such as texture, shape, and color. These features are then used to diagnose plant health, check growth, detect pest infestations, or recognize weeds. The most common are the Scale Invariant Feature Transform (SIFT) algorithm [104], Hough transform, and Otsu method [105]. When multispectral images are acquired, the Normalized Difference Vegetation Index (NDVI) and its variations could be used to estimate the plant growth and vegetation phase, combining near-infrared and red channels acquired by sensors [106]. Other authors, as in [107], use data generated by LiDAR sensors to compute the Leaf Area Index (LAI) on detected plants. Environment features are detected by methods like FAST, ORB, VINS, and BASALT in SLAM navigation to estimate orientation and movement [108].  
In order to accomplish their complex tasks in the most accurate and efficient way, agricultural UGVs embed multiple sensors and combine the generated data to enhance the accuracy and reliability of the information collected. As reported by [109], by using different types of sensors, it is possible to improve accuracy and overcome the limitations of each sensor type. However, due to the harsh environmental conditions, the data provided by sensors are commonly affected by noise, so the data must be cleaned before being used; algorithms like Kalman filter (and its variations) allow for estimates of unknown variables by processing a series of measurements over time, even when the measurements contain noise and inaccuracies. This is also used with UGVs to fuse data from GNSS, IMU, and other sensors [110; 111]. Control algorithms govern the movements and actions of UGVs based on sensor inputs and desired outcomes. The main types are as follows:  
* Proportional-Integral-Derivative (PID) controllers, which are widely used in UGVs for maintaining the desired speed, direction, and stability. They adjust the control inputs to minimize the error between the desired and actual states [112].
* Fuzzy logic controllers, which handle uncertainties and imprecisions in UGV operations by using fuzzy set theory. They are applied in scenarios where traditional control methods may struggle, such as variable terrain and crop conditions, or for collision avoidance [113].
* Adaptive Fuzzy PID (AFPID) controllers: these systems modify their parameters in real-time to cope with changing environmental conditions and uncertainties [114]. Such adaptability is crucial for UGVs operating in dynamic agricultural fields with a dynamic environment.  
Algorithms are the backbone of agricultural UGVs, enabling them to perform complex tasks, from path planning and image processing to sensor fusion and control. Continued advancements in algorithm development will further enhance the effectiveness and reliability of UGVs, contributing to more sustainable and productive farming practices [115].