Welcome to DOFBOT Pro repository
7. Voice Control Yolov11 Garbage Recognition Sorting
Voice Control Yolov11 Garbage Recognition Sorting
This course is specifically for Orin board. Jetson-Nano board cannot run this function due to insufficient performance. Before running the function, you need to close the App and large programs. For the closing method, refer to [4. Preparation] - [1. Manage APP control services].
1. Function Description
After the program starts, voice commands are issued to sort garbage. The program will recognize garbage label blocks in the image according to the command, calculate their positions in the world coordinate system, then control the robotic arm to grasp them, classify them according to the recognized garbage label names, and place them at the designated corresponding positions. At the same time, it will announce what type of garbage the grasped garbage label block is.
2. Startup and Operation
2.1. Startup
Orin board opens the terminal and inputs the following commands,
#Start camera and inverse kinematicsros2 launch dofbot_pro_info camera_arm_kin.launch.py#Start speech recognition and broadcastros2 launch yahboom_speech speech.launch.py#Start image conversion programros2 run dofbot_pro_voice_ctrl msgToimg#Start yolov11 sorting programros2 run dofbot_pro_voice_ctrl yolov11_sortation_VC#Start yolov11 recognition program (startup may be slow)python3 /home/jetson/dofbot_pro_ws/src/dofbot_pro_voice_ctrl/dofbot_pro_voice_ctrl/Yolov11/yolov11_VC.py2.2. Operation Steps
After all programs are running, place four wooden blocks with garbage labels in the image. Say "Hello, yahboom" to the speech recognition module, and the speaker will broadcast "here". Then say "Start garbage sorting" to the speech module. The speech module will reply "OK". The robotic arm will grasp garbage blocks and place them at corresponding positions, and the speech module will announce what garbage it is and the type of garbage. After placement is completed, it will announce "Placement complete" and the robotic arm returns to the recognition posture.

3. Core Code Analysis
3.1. Robotic Arm Grasping Node yolov11_sortation_VC
Source code path: ~/dofbot_pro_voice_ctrl/dofbot_pro_voice_ctrl/Yolov11/yolov11_sortation_VC
Mainly explains how to publish voice broadcast topics.
x#Create publisher for voice broadcast topicself.pub_playID = self.create_publisher(Int8, "player_id", qos_profile=10)#In the grasp function, determine the type and name of the current garbage label block being sorted according to self.name, then publish corresponding voice broadcast topic message, and determine the value of self.set_joint according to the garbage type, which is the placement position.if self.name in self.recyclable_waste: print("This is recyclable_waste.") if self.name == "Newspaper": self.play_id.data = 96 self.pub_playID.publish(self.play_id) if self.name == "Zip_top_can": self.play_id.data = 94 self.pub_playID.publish(self.play_id) if self.name == "Book": self.play_id.data = 97 self.pub_playID.publish(self.play_id) if self.name == "Old_school_bag": self.play_id.data = 95 self.pub_playID.publish(self.play_id) self.set_joint = [140, 20, 90, 3, 50.0,140]elif self.name in self.wet_waste: print("This is wet_waste.") if self.name == "Fish_bone": self.play_id.data = 102 self.pub_playID.publish(self.play_id) if self.name == "Watermelon_rind": self.play_id.data = 103 self.pub_playID.publish(self.play_id) if self.name == "Apple_core": self.play_id.data = 104 self.pub_playID.publish(self.play_id) if self.name == "Egg_shell": self.play_id.data = 105 self.pub_playID.publish(self.play_id) self.set_joint = [165, 38, 60, 2, 90.0,140]elif self.name in self.toxic_waste: print("This is toxic_waste.") if self.name == "Syringe": self.play_id.data = 98 self.pub_playID.publish(self.play_id) if self.name == "Expired_cosmetics": self.play_id.data = 100 self.pub_playID.publish(self.play_id) if self.name == "Expired_tablets": self.play_id.data = 101 self.pub_playID.publish(self.play_id) if self.name == "Used_batteries": self.play_id.data = 99 self.pub_playID.publish(self.play_id) self.set_joint = [38, 20, 90, 2, 90.0,140] elif self.name in self.dry_waste: print("This is dry_waste.") if self.name == "Toilet_paper": self.play_id.data = 109 self.pub_playID.publish(self.play_id) if self.name == "Disposable_chopsticks": self.play_id.data = 106 self.pub_playID.publish(self.play_id) if self.name == "Cigarette_butts": self.play_id.data = 107 self.pub_playID.publish(self.play_id) if self.name == "Peach_pit": self.play_id.data = 108 self.pub_playID.publish(self.play_id) self.set_joint = [12, 38, 60, 0, 90.0,140]#In the move function, publish voice broadcast message topic data, the broadcast voice is "Placement complete"play_id = Int8()play_id.data = 81self.pub_playID.publish(play_id)3.2. yolov11 Recognition Program yolov11_VC.py
Source code path: ~/dofbot_pro_voice_ctrl/dofbot_pro_voice_ctrl/Yolov11/yolov11_VC.py
xxxxxxxxxx#Create subscriber for speech recognition result topicself.sub_voice = self.create_subscription(Int8,"voice_result",self.getVoiceResultCallBack,1)#Create publisher for voice broadcast topicself.pub_playID = self.create_publisher(Int8, "player_id", qos_profile=10)#When the speech recognition result topic data is 108, it means the voice command is "Start garbage sorting", then publish voice broadcast topic data, the broadcast voice is "OK", then modify self.start_flag value to True, indicating that garbage label block information can be published.def getVoiceResultCallBack(self,msg): if msg.data == 108: play_id = Int8() play_id.data = 45 self.pub_playID.publish(play_id) time.sleep(3.0) self.start_flag = True print("Start sorting garbage.")