# A Special Robot for Precise Grading and Metering of Mushrooms Based on Yolov5
## 3 Methods
### Hardware Establishment  
In order to improve the intelligent level of the edible fungi industry, meet the digital needs of the whole industrial chain of edible fungi and realize the collection of heterogeneous data information such as the grade and weight of mushroom products, according to the digital demand of the whole industrial chain of mushrooms, combined with the basic conditions of mushroom factories and the operation needs of mushroom picking and sorting, warehousing weighing, inventory management and other links, a special robot for mushroom measurement is designed and developed.  
The main control unit of the information acquisition system uses MSP430F5438 A single chip microcomputer, equipped with ADAM Advantech acquisition card, and connects various types of sensors such as current type, voltage type and 485 protocol. Weighing sensor, RFID module, voice module, barcode scanning module, face recognition module through the data acquisition card to RS-485 protocol and MSP4305438A master control unit achieve data information transmission and reception; the speech recognition module, speech synthesis module and display control module interact with the main control unit through the TTL interface. The main control unit of the information acquisition system communicates with the wireless data transmission terminal VTU through TCP. The TCP/IP protocol is used to realize long-distance data transmission and reception, and the information collected in the mushroom shed is sent to the server for storage.  
The robot system structure diagram is shown in Figure 1:  
Figure 1: System structure diagram.  
The specific functions are as follows:  
1. Mushroom grading: Based on the intelligent robot, the mushroom grading algorithm based on Yolov5 + OpenCV is used to identify the image and measure the size of the mushroom cap. According to the established mushroom grading measurement standard, the mushroom is graded accordingly.
2. Mushroom measurement: Mushroom measurement system is based on resistance strain gauge sensor. When the sensor undergoes elastic deformation, the resistance value of the resistance strain gauge changes, and the strain of the mushroom weight through the equivalent resistance is converted into an analog signal (1) and (2). The weight of different grades of mushrooms is converted into voltage signal output according to the linear relationship. The analog signal is processed by the detection circuit, and the amplified analog signal is converted into the weight data of mushrooms through the AD conversion sub-module.  
Analog signal output formula:  
\[U_{out}=\frac{U_{E}}{(R_{11}+R_{12})}-\frac{U_{E}}{(R_{13}+R_{14})} \tag{1}\]  
Linear relationship conversion formula:  
\[K*\varepsilon=\frac{\Delta R}{R} \tag{2}\]
3. Autonomous obstacle avoidance function: The multi-sensor fusion SLAM algorithm suitable for ROS environment is studied. The global exploration is used for path planning and autonomous navigation, and the dynamic window method is used for local obstacle avoidance. Among them, the red grid points in Figure 2 represent dynamic obstacles moving up and down, and Figure 3 represents additional unknown obstacles. The blue grid point represents the starting point; the green grid point represents the target point; the black dotted line is the global path planned before the obstacle is added; the blue solid line is the actual trajectory of the robot. The function simulation experiment is shown in Figures 2 and 3.  
Figure 2: Single-obstacle simulation experiment results.