1. Introduction
With the continuous development of intelligent animal husbandry, the research and application of intelligent robots in animal husbandry are receiving increasing attention from various countries and have achieved fruitful results [
1]. The natural grassland area and livestock range in Inner Mongolia pastoral areas are large, and the economic benefits of animal husbandry are great. But at this stage, there are problems such as labor shortages, and low mechanization and scale in animal husbandry [
2]. To reduce human resources, improve animal husbandry efficiency, and accurately and digitally monitor feeding behaviors and intake of herds, intelligent grazing robots have been applied in the animal husbandry process to replace manual monitoring. The geography of the grassland is complex, with rugged roads, gullies, and numerous mountain slopes, which have strong nonlinear characteristics. As a result, when the grazing robotic vehicles operate, they are easily affected by the terrain environment and lose stability. This places high demands on the motion control performance of robotic vehicles in grassland environments, such as the dynamic characteristics of the steering system, the accuracy and stability of the speed control system, and other aspects.
In recent years, with the rapid development of artificial intelligence and mobile robot technology, the research and development of intelligent robots used in animal husbandry has attracted wide attention, and their achievements have gradually been applied to the production and lives of farmers. L. Peng et al. developed an intelligent pig feeding system based on PLC, which has three parts: automatic feeding, environmental control, and an upper computer control interface; real-time control was achieved through the interface, which greatly improves the efficiency of pig feeding [
3]. Mosquera et al. developed an automatic feeding system for dairy cows based on PLC that used multiple sensors and robotic arms for precise feeding, while also optimizing the feed ratio based on the weight of the milk [
4]. C. Long et al. designed a mobile monitoring robot for livestock and poultry houses that monitored the breeding environment through various sensors and livestock using cameras and infrared temperature measuring devices. The collected data were uploaded to Alibaba Cloud for storage and viewing using Wi-Fi modules [
5]. Usher et al. developed a mobile robot for poultry house management based on an Nvidia Jetson TX1 controller. It used an OpenCV algorithm to identify and transport eggs and chicken carcasses, and could monitor poultry growth status and environmental information [
6]. Q. Feng et al. designed an epidemic prevention and disinfection robot, supporting both fully automated operation and remote-control operation, which can move along geomagnetic and RFID tags, and tested the sprayer. The nozzle sprayed droplets with a diameter of up to micrometers at a flow rate of 400–1200 mL/min [
7]. Chanprakon et al. developed a UV disinfection robot for indoor disinfection based on the Raspberry Pi embedded platform [
8].
Depending on the different control targets, the motion control of mobile robots can be divided into longitudinal speed control and lateral angle control [
9]. Longitudinal motion control mainly refers to the precise control of the robot’s running speed or expected distance through the coordination of drivers and brakes [
10]. In longitudinal motion control, PID control is the most widely used method, which does not require a specific system model and relies only on input deviations for control [
11]. J. Han et al. proposed a fuzzy-gain PID controller based on the dynamic characteristics of hybrid robots based on traditional PID controllers, which enabled robots to achieve better control performance in any operating state [
12]. Horizontal control can be divided into two parts: path tracking control and trajectory tracking control, with diverse control algorithms. Singhal designed an adaptive fractional order parallel fuzzy PID controller (AFO-PFPID) to achieve trajectory tracking control of a non-holonomic wheeled mobile robot (WMR) system due to the high degree of uncertainty in its motion state [
13]. P. Shi et al. proposed a hybrid PID control theory based on improved model predictive control to increase the accuracy of intelligent vehicle path tracking. In lateral control, a relaxation factor was introduced based on traditional MPC to constrain the front wheel lateral deviation and improve the stability of vehicle control; in longitudinal control, a hybrid PID controller was designed for different road conditions to ensure the accuracy and real-time performance of the longitudinal control [
14]. Abhijit et al. designed a hybrid fuzzy embedded PID control method for the stability and path planning of humanoid robots moving on uneven surfaces. To verify the performance of the controller, the parameters of the designed fuzzy PID controller were compared with those of the previously proposed method and showed improvements, a shorter adjustment time, and reduced overshoot [
15]. Q. Xu et al. constructed a fuzzy PID controller to solve the problem of wheel deflection control of agricultural vehicles with four-wheel independent steering and conducted simulation experiments and field tests. The results showed that their steering control strategy has good real-time performance and effectively improves steering stability [
16].
From the research of the above scholars, we can see that the selection of improved methods based on the traditional PID to control a mobile robot’s motion in a complex working environment can meet the requirements of stable and real-time control. However, the intelligent robots used in animal husbandry are mainly concentrated in tasks involving animal feeding, animal management and environmental monitoring, epidemic prevention, and disinfection and sterilization [
17], while the intelligent robots applied for grazing are rarely studied. Therefore, the research on grazing robots can not only fill the gaps in the related research fields, but also provide key technical equipment for grassland animal husbandry, promoting the development of animal husbandry towards intelligence, increased welfare and scale, and gradually becoming an important way to ensure the sustainable development of animal husbandry.
The overall design goal of the grazing robotic vehicle is to autonomously identify livestock and recognize obstacles in the wild environment, make path decisions and plans based on this information, or achieve remote semi-autonomous control through wireless communication modules and human-machine interaction interfaces. After receiving commands from these two parts, the bottom controllers perform motion control to follow the livestock or use devices such as horns to drive them away. In order to enhance the practicality of the robotic vehicle, a set of ecological environment monitoring systems was designed, which collect and store environmental information during the following process and make reasonable animal husbandry decisions based on this information. The underlying motion control of the robotic vehicle determines the real-time and stable motion control of the entire vehicle, therefore, the focus of this study is on the design and implementation of an intelligent control system for grazing robotic vehicles, including the design and implementation of various controllers and executing mechanisms, as well as the research and implementation of intelligent control algorithms.
Among the current motion control approaches for agricultural vehicles, the PID control method is the most widely used. It does not require the establishment of a specific system model and can only be controlled by the input deviation. However, it is difficult to adapt to complex systems and scenarios with large external disturbances. The core of fuzzy control is to use established fuzzy rules to control the system, which have good adaptability and can effectively improve the stability and real-time performance of the control system. This study combined fuzzy control with traditional PID control to optimize the motion control of grazing robotic vehicles.
In this paper, an intelligent control system for a grazing robotic vehicle was built for the complex and changing terrain of the grassland grazing environment. By designing a lateral adaptive fuzzy PID controller and a longitudinal PID constant speed controller, the problems of poor stability and real-time performance of steering and unstable speed changes in grassland environments can be solved. The simulation and field test results show that the designed control system can meet the control requirements and provide a reference for the control system design of intelligent robots in grassland grazing environments.
3. Motion Mechanism Design
3.1. Design of the Steering Mechanism
The steering mechanism mainly consists of a steering controller, stepper motor push rod, steering linkage, displacement sensor, and limit sensor, as shown in
Figure 4.
A stepper motor push rod as the steering drive, which is connected to the steering linkage for steering, and the displacement of the push rod is measured by a linear displacement sensor and converted to an angle in real-time within the controller. At this point,
Figure 4 can be simplified to the structure shown in
Figure 5.
The XOY coordinate system is established with point O as the origin; the AC section is the total stroke of the stepper motor push rod, and its displacement is set as 2L; and are the steering angles of the robotic vehicle; and and are the steering angles of the wheel. During the steering process, when the push rod is in position A, the displacement of the push rod is 0, and the vehicle body is at the maximum left turn angle. When the push rod is in position B, the stretch of the push rod is half of its stroke, the displacement is L at this point, and the steering angle of the vehicle body is 0°. When the motor push rod is in position C, the stretch of the push rod reaches its maximum stroke, and the displacement is 2L; at this point, the vehicle body is at the maximum angle of a right turn. After actual measurement, the maximum turning angles on both sides of the vehicle body were 32°, that is, , and half of the push rod stroke is L = 75 mm.
By correcting the steering angle in
Figure 5 to ensure that when the steering angle is 0°, the wheels are on the central axis. When the steering angle is −32°, the wheels are at the maximum left-turn value. When the steering angle is +32°, the wheels are at the maximum right-turn value. The final steering angle calculation method is shown in Equation (1):
where
is the angle value calculated internally by the processor (°);
H is the distance of the OB section,
H = 120 mm; and
is the displacement measured by the displacement sensor (mm). ‘
’ indicates the steering angle is to the left; ‘
’ indicates the steering angle is to the right.
After the above analysis, the LongXiang BJXL stepper motor push rod gear reducer with a stroke of 150 mm was selected as the actuator, equipped with a 42-stepper motor with a working voltage of 9–36 V and a maximum thrust of 500 N. To obtain real-time angles during the movement of the robotic vehicle, a Hermitt KTC-150 mm linear displacement sensor was used in conjunction with a stepper motor push rod for angle measurement; its working voltage is 0–24 V with conventional analog output. A proximity switch was used to limit the travel of the actuator; the specific type is the Omron TL-Q5MB1-Z DC 3-wire PNP normally open type.
Using the DMA method of the internal ADC interface of the STM32 microprocessor for the acquisition of the displacement sensor output data, the data are calculated using Equation (2):
where
is the voltage value of the displacement sensor (V);
is the data of the ADC interface measured by the microprocessor; and
is the reference voltage,
.
Due to the accuracy of the linear displacement sensor, its output voltage value is not strictly linear with the displacement value, so curve fitting is necessary. The voltage value and actual displacement value of the displacement sensor are collected multiple times, and curve fitting tools are used to fit the output curve of its displacement changing with voltage, and the relationship between the final displacement
The voltage value
can be calculated as shown in Equation (3):
After obtaining the displacement , the angle value can be calculated according to Equation (1) above.
3.2. Design of the Longitudinal Speed Regulation Mechanism
The longitudinal speed regulation mechanism refers to a system used to drive the grazing robotic vehicle to achieve forward, backward, and acceleration or deceleration functions; it included a DC motor, motor controller, encoder, and a rear wheel differential mechanism. Its design diagram is shown in
Figure 6.
In this paper, a brushless DC motor with a rated voltage of 48 V, a power of 1 kW, and a rated speed of 3000 rpm was selected, together with a matching 1 kW motor driver and an Omron 1000-line EB62-CWZ1X linear incremental photoelectric encoder for speed measurements.
The encoder mode of the STM32 microprocessor’s internal timer (TIM) was used to capture the encoder output pulses by the quadruple frequency method to obtain the motor speed, and the direction of rotation of the motor can be obtained by the sequence of the AB two-phase pulse outputs. The calculation method for the motor’s real-time speed
(r/min) is shown in Equation (4):
where
is the amount of pulse between two readings, and
is the time factor.
Due to the speed ratio of the motor to the wheel being four and the radius R of the wheel being known, the running speed
(m/s) of the robotic vehicle can be calculated using Equation (5):
4. Motion Controller Design
In order to cope with the impact of complex terrain on the robotic vehicle and achieve smooth operation, the entire vehicle control of the robotic vehicle is decomposed into lateral and longitudinal controls. Based on the characteristics of the two motion mechanisms, a lateral adaptive fuzzy PID controller and a longitudinal constant-speed PID controller were designed.
4.1. Design of the Longitudinal Constant Speed PID Controller
The longitudinal speed control structure of the robotic vehicle is simple, and using a traditional PID control strategy can achieve a good control effect. The encoder is used to collect the real-time speed of the robotic vehicle, and the deviation between the real-time speed obtained and the target speed is used as the input of the longitudinal constant speed PID controller. The controller calculates and outputs pulses with different duty ratios in real-time as the input signal of the motor controller, thereby changing the speed of the motor and achieving real-time speed regulation The design diagram of the controller is shown in
Figure 7.
The composition of the speed control mechanism is simple and does not have integral components, so a positional PID controller is used for speed control, which is discretized into Equation (6):
where
is the output of the PID controller at time
k;
is the deviation at time
k; and
is the deviation at time
k − 1.
The motor speed changes with the control voltage input to the motor controller, and the voltage signal input to the motor controller is digital in nature and is determined by the duty cycle of the PWM pulse output from the microcontroller. The microcontroller output PWM pulse frequency was set to 100 kHz, and the duty cycle varies within [−9000, 9000], corresponding to a voltage value variation range of [0, 3.3] V. When the microprocessor detects a negative duty cycle, it controls the motor to reverse by controlling the relay’s engagement.
Using the Z-N method for PID parameter tuning, and after multiple practical tests, was set to 5, was set to 2.2, and was set to 0.
4.2. Design of the Horizontal Adaptive Fuzzy PID Controller
The grazing robotic vehicle often runs in complex and open outdoor environments with rugged roads and strong non-linear characteristics. To ensure stable operation and precise control of the robotic vehicle, real-time adjustment of control parameters is required during operation to cope with the impact of constantly changing external terrain. Once the parameters of traditional PID controllers are determined, they are difficult to change during operation, resulting in poor adaptability and control effectiveness, making it difficult to meet the control requirements in complex and ever-changing environments [
18]. Therefore, this study designed an adaptive fuzzy PID controller to improve the above problems.
The adaptive fuzzy PID controller designed in this study is a fuzzy logic control structure with 2 inputs, 3 outputs, and 49 fuzzy control rules [
19]. The control system design structure is shown in
Figure 8.
The deviation e and deviation change rate ec between the target angle of the robotic vehicle and the actual measurement angle of the linear displacement sensor are used as input variables for the controller; after quantification and fuzzification, they correspond to the parameters of the fuzzy domains E and EC. Then, based on the 49 established fuzzy control rules, fuzzy inference is used to obtain the fuzzy output variables
, and
. These parameters are output to the PID controller after defuzzification, and the final control parameters are synthesized through a linear relationship with the initial parameters of the PID controller, achieving online adjustment of the PID control parameters [
20]. Finally, the output “u” is obtained and transmitted to the steering controller for angle control. The variables and values defined to implement the above process are shown in
Table 2.
The triangular membership function is used as the middle segment function of the input and output variables, and Gaussian functions are used on both sides to enhance the adaptability of the controller. The membership function curves are shown in
Figure 9. The three-dimensional output surface of the fuzzy control variables
, and
are shown in
Figure 10. After summarizing the technical knowledge of engineering personnel or experts [
21,
22] and combining it with practical testing, the fuzzy rules for the three output variables of the adaptive fuzzy PID controller were obtained and are shown in
Table 3,
Table 4 and
Table 5.
After obtaining the output of the fuzzy controller at a certain moment, the output parameters cannot be directly used to correct the PID parameters. Instead, the self-tuning gain correction parameters need to be obtained by multiplying them by the corresponding proportional factor. The control parameters are synthesized using linear relationships with the initial parameters of the PID controller. Finally, the control parameters are inputted to the PID controller for control, and the final parameter self-tuning formula [
23] is shown in Equation (7):
where
,
, and
are the final outputs of the adaptive fuzzy PID controller;
,
, and
are the quantification factors; and
,
, and
are the initial parameters of the PID controller, which need to be obtained according to the relevant methods.
4.3. Simulation and Analysis
By sending a certain steering angle command to the steering control system and obtaining its response, the input and output data of the steering system angle are collected. Using the System Identification toolbox of MATLAB software to identify the approximate transfer function of the system and then combining experiments and testing to modify the obtained transfer function, the transfer function of the steering system was obtained and is shown in Equation (8):
The input of this transfer function is the deviation between the target steering angle and the actual value, and the output is the steering angle.
Using the Fuzzy toolbox and Simulink simulation tool of MATLAB software and based on the design of the adaptive fuzzy PID controller mentioned above, a simulation model of the traditional PID controller and the adaptive fuzzy PID controller was built, and a comparison was made between the two controllers. The simulation model is shown in
Figure 11.
Using the Z-N method and combined with actual testing, the initial PID parameters of the controller were set to be
,
, and
. During the simulation, the sampling time was set to 1 ms, and a step signal with an amplitude of 1 was the input. At the 5th second, a step signal with an amplitude of 0.5 was added to simulate the interference signal. The simulation results are shown in
Figure 12.
By comparing the simulation waveforms of the two controllers, it can be seen that the designed lateral adaptive fuzzy PID controller had basically the same rise time as the traditional PID controller, but had an increase of 0.4 s in adjustment time, a decrease of 1% in steady-state error control, and a decrease of 5% in overshoot control. At the same time, compared to traditional PID controllers in terms of anti-interference performance, it can quickly return to the stable state.
From the simulation result, it can be seen that selecting an adaptive fuzzy PID controller as the steering controller for the grazing robotic vehicle can meet the control requirements of stable and fast control.