Yolov5 garbage sorting

Before starting this function, you need to close the process of the big program and APP. Enter the following program in the terminal to close the process of the big program and APP.

If you need to start the big program and APP again later, start the terminal.

 

1. Function description

After the program is started, the camera captures the image and places the garbage label code block in the image. The robotic arm recognizes the category of the garbage label code block, and the lower claw grabs the garbage label code block. According to the category of the garbage label code, it is placed in the set position. After the placement is completed, it returns to the recognized posture.

 

2. Start and operate

2.1. Start command

Enter the following command in the terminal to start,

Due to the performance differences of the motherboard, the time for different motherboards to start loading the Yolov5 recognition program is different, so you need to wait patiently for a while.

2.2, Operation process

After the program is started, place the wooden block with the garbage label code in the middle of the image. The wooden block needs to be straightened and the icon needs to be in the same direction as the robot arm (forward, Y axis direction). Press the space bar to start recognition. The robot arm will grasp the wooden block and place it in the corresponding position according to the type of garbage it recognizes.

 

3. Program flow chart

yolov5.py

yolov5_sortation.py

 

4. Core code analysis

4.1. msgToimg.py

Code path: /home/jetson/dofbot_pro_ws/src/dofbot_pro_yolov5/scripts/msgToimg.py

Import necessary libraries,

Initialize program parameters, create publishers and subscribers,

image_sub_callback callback function,

 

4.2、yolov5.py

Code path: /home/jetson/dofbot_pro_ws/src/dofbot_pro_yolov5/scripts/yolov5.py

Import necessary library files,

Initialize program parameters, create publishers and subscribers,

The callback function for subscribing to the image topic,

4.3、yolov5_sortation.py

Code path: /home/jetson/dofbot_pro_ws/src/dofbot_pro_yolov5/scripts/yolov5_sortation.py

Import necessary libraries,

Open the offset parameter table,

Initialize program parameters, create publishers, subscribers, etc.

The callback function getDetectInfoCallback of the identified spam tag result,

The callback function getDepthCallback of the depth image topic,

The callback function getSortFlagCallback that starts sorting topics.

Grasp function grasp,