Welcome to DOFBOT-Ultra repository
1. Simple Voice Control
Simple Voice Control
** If using a depth camera (DABAI_DCW2), before running this example, you must first execute
ros2 run dofbot_ultra_driver calibrate_6pointto perform a six-point calibration, otherwise the robotic arm cannot accurately locate the target**.
Please ensure that the web control program backend process is not running in the background. To close it, refer to the [Get Started Quickly - 2. Access the Terminal] section in [Disable the Auto-Start Web Control Backend Process]. After closing, please restart DofbotUltra!!!
1. Startup and Operation
1.1. Startup
Before running the function, you need to shut down the web control program backend process. For the shutdown method, please refer to the [4. Preparation - 1. Manage Web control services].
Open the Raspberry Pi terminal, enter the Docker container, and input the following command to start:
python3 /home/yahboom/dofbot_ultra/2d/dofbot_voice/scripts/simple_voice_ctrl.pyFor RDK running locally, open the RDK X5 terminal and input the following command to start:
xxxxxxxxxxpython3 /home/sunrise/dofbot_ultra_ws/src/2d/dofbot_voice/scripts/simple_voice_ctrl.py1.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 |
2. Principle Introduction
This program receives voice commands through the Speech Recognition and Broadcast Module (Speech_Lib), and based on the recognition results, calls the robotic arm underlying library (Arm_Lib) to control the RGB light, buzzer, and robotic arm servos.
The program's main loop continuously polls the voice module's recognition results (speech_read()). Each voice command corresponds to a numeric code (e.g., "red light up" corresponds to 11). After matching the corresponding code, it executes the corresponding hardware operation and broadcasts a voice reply through void_write().
3. Core Code Analysis
Source code path
Raspberry Pi: /home/yahboom/dofbot_ultra/2d/dofbot_voice/scripts/simple_voice_ctrl.py
RDK X5: /home/sunrise/dofbot_ultra_ws/src/2d/dofbot_voice/scripts/simple_voice_ctrl.py
ximport Arm_Libfrom Speech_Lib import Speech
mySpeech = Speech()Arm = Arm_Lib.Arm_Device()
result = mySpeech.speech_read()
Arm.Arm_RGB_set(50, 0, 0)
Arm.Arm_Buzzer_On(1)
Arm.Arm_serial_servo_write(2, 90, 1000)
mySpeech.void_write(11)Speech()— Creates a voice recognition and broadcast object, communicating with the voice module on the I2C busspeech_read()— Reads the current voice recognition result and returns the numeric code corresponding to the commandArm_RGB_set(r, g, b)— Controls the RGB light color on the driver boardArm_Buzzer_On(n)— Controls the buzzer to beep n times (approximately 100ms each time)Arm_serial_servo_write(id, angle, time)— Controls the specified servo to rotate to the target angle within the specified timevoid_write(code)— Broadcasts the preset voice corresponding to the specified code