Welcome to DOFBOT Pro repository
8. Voice Control Object Tracking and Grasping
Voice Control Object Tracking and Grasping
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 instruct the robotic arm to track the selected object. The program will control the robotic arm to track AprilTags and grasp the selected object when conditions are met according to the command.The width of the object should preferably not exceed 4 centimeters.
2. Startup and Operation
2.1. Startup
Users with Jetson-Nano board version need to enter the docker container and input the following commands. Orin board users can directly open the terminal and input 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 tracking and grasping object programros2 run dofbot_pro_voice_ctrl KCF_TrackAndGrap#Start KCF object selection programros2 run dofbot_pro_voice_ctrl KCF_Tracker2.2. Operation Steps
2.2.1. Select Object
After the program starts, the robotic arm will move to the tracking posture. Hold the object to be tracked and grasped and make it appear in the image. Use the mouse to draw a box around the selected object. Note that the width of the box should preferably match the width of the object to facilitate subsequent program calculation of the angle the gripper needs to open. Release the mouse to complete the selection.
2.2.2. Voice Control
After selecting the object and pressing the spacebar, say "Hello, yahboom" to the speech recognition module, and the speaker will broadcast "here". Then say "Tracking and picking up objects" to the speech module. The speaker will broadcast "OK", and the robotic arm will start tracking the selected object. Slowly move the object, and the robotic arm will follow. Wait for the robotic arm to become stationary and stop tracking. After a "beep" sound, the robotic arm will start grasping the object and place it at the designated position. Finally, the robotic arm returns to its initial posture.
3. Core Code Analysis
3.1. Tracking and Grasping Object Node KCF_TrackAndGrap
Source code path: ~/dofbot_pro_voice_ctrl/dofbot_pro_voice_ctrl/KCF/KCF_TrackAndGrap.py
x#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", 1)#Callback function, if the received speech recognition result data is 107, it means the control command is "Track and picking up objects", then change self.start_flag value to True indicating that object position information can be published and publish voice broadcast topic, the broadcast audio is "OK"def getVoiceResultCallback(self,msg): if msg.data == 107: self.start_flag = True play_id = Int8() play_id.data = 45 self.pub_playID.publish(play_id)