Welcome to ROSMASTER X3 Plus repository
3. Voice control car movement
3. 3. Voice control car movement
3. 3. Voice control car movement3.1. Description 3.2. Start function3.2.1. function package path 3.2.2. start 3.3. Voice control car 3.3.1. Movement state 3.3.2. Light strip effect
3.1. Description
Realize voice control car forward, backward, parking, turn left, turn right and light strip effects.
3.2. Start function
3.2.1. function package path
~/yahboomcar/src/yahboomcar_voice_ctrl/ 3.2.2. start
x#You need to enter docker first, perform this step more#If running the script to enter docker fails, please refer to 07.Docker-orin/05, Enter the robot's docker container~/run_docker.shroslaunch yahboomcar_voice_ctrl voice_ctrl_yahboomcar.launch 
Core code analysis:
- import the library of speech recognition
xxxxxxxxxxfrom Speech_Lib import Speech from Rosmaster_Lib import Rosmaster 2) Create speech recognition objects and drive control objects
xxxxxxxxxxspe = Speech() car = ROsmaster() - read the content recognized by the voice
xxxxxxxxxxspeech_r = spe.speech_read()- send voice broadcast content
xxxxxxxxxxspe.void_write(speech_r) Program flow chart:

The specific code can refer to
xxxxxxxxxx~/yahboomcar/src/yahboomcar_voice_ctrl/scripts/voice_Ctrl_Mcnamu_driver.py 3.3. Voice control car
Say "Hi Yahboom" to ROSMASTER.
Waiting until the voice module reply "Hi , I'm here.".
We can control the car according to the commands in the table below.
3.3.1. Movement state
| function word | Speech Module Recognition Results | Voice broadcast content |
|---|---|---|
| Robot stop | 2 | OK , I'm stop. |
| Go ahead | 4 | OK , let's go. |
| Back | 5 | OK , I‘m back. |
| Turn left | 6 | OK , I‘m turning left. |
| Turn right | 7 | OK , I‘m turning right. |
| Enter A mode | 8 | OK, I‘m working on A mode. |
| Enter B mode | 9 | OK, I‘m working on B mode. |
3.3.2. Light strip effect
| function word | Speech Module Recognition Results | Voice broadcast content |
|---|---|---|
| Close light | 10 | OK, light is closed. |
| Red light up | 11 | OK, red light is on. |
| Green light up | 12 | OK, green light is on. |
| Blue light up | 13 | OK, blue light is on. |
| Yellow light up | 14 | OK, yellow light is on. |
| light A | 15 | OK, light A is on. |
| light B | 16 | OK, light B is on. |
| light C | 17 | OK, light C is on. |
| Display battery value | 18 | OK, battery value has been display. |