Welcome to DOFBOT Pro repository
1.Simple Voice Control
Simple Voice Control
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].
Orin board users can directly open the terminal and enter the tutorial commands to run. Jetson-Nano board users need to enter the docker container first, then enter the tutorial commands in the docker to start the program.
1. Function Description
Control RGB lights, buzzers, and robotic arm through the voice recognition broadcast module.
2. Startup and Operation
2.1. Startup
Open the terminal and enter the following command to start:
xxxxxxxxxxpython3 ~/dofbot_voice/scripts/simple_voice_ctrl.py2.2. Operation Steps
After the program runs, the voice module will broadcast "here". Then say "Hello, yahboom" to the voice module. The voice module will reply "here" to indicate successful wake-up. Then say "red light up" to the voice module. At this time, the LED light on the driver board will light up red, and the voice module will broadcast "ok red light is on". The voice commands that this program can recognize are as follows:
| Voice Command | Effect |
|---|---|
| RED-LIGHT-UP | LED light on driver board lights up red |
| GREEN-LIGHT-UP | LED light on driver board lights up green |
| BLUE-LIGHT-UP | LED light on driver board lights up blue |
| WARNING | Buzzer beeps 3 times |
| LIFT-THE-ARM-UP | Robotic arm extends upward |
| PUT-THE-ARM-DOWN | Robotic arm extends downward |
| ARM-LEFT | Robotic arm turns left |
| ARM-RIGHT | Robotic arm turns right |
| CLAMP-THE-DIP | Gripper tightens |
| OPEN-THE-DIP | Gripper releases |
3. Core Code Analysis
Source code path:
xxxxxxxxxx#Jetson-Nano users need to enter the docker container to view~/dofbot_voice/scripts/simple_voice_ctrl.pysimple_voice_ctrl.py
x#Import robotic arm underlying control libraryimport Arm_Lib#Import voice recognition broadcast libraryfrom Speech_Lib import Speech#Create voice recognition broadcast object mySpeechmySpeech = Speech()#Create robotic arm underlying control object ArmArm = Arm_Lib.Arm_Device()#Call speech_read function to get voice recognition resultresult = mySpeech.speech_read()#Call Arm_RGB_set function to control LED light to light up redArm.Arm_RGB_set(50, 0, 0)#Call Arm_Buzzer_On function, pass parameter 1 to control buzzer to beep for 100 millisecondsArm.Arm_Buzzer_On(1)#Call Arm_serial_servo_write function, pass parameters to control servo 2 to rotate to 90 degrees position within 1000 millisecondsArm.Arm_serial_servo_write(2, 90, 1000)#Call void_write function, pass parameter 11 to broadcast corresponding audio filemySpeech.void_write(11)