Welcome to ROSMASTER X3 Plus repository
17.1 Voice control robotic arm movement
1. Voice control of robotic arm movements
Command word table
| command word | command word |
|---|---|
| Clamp | Up |
| Release | Down |
| Applause | Turn left |
| Nod | Right |
| Pray | Kneel |
| Fright | Initial position |
| The car moves forward | The car moves backward |
| Car turns left | Car turns right |
| The car rotates left | The car rotates right |
| Car stops | Car sleeps |
| Red light on | Green light on |
| bright blue light | bright yellow light |
| Turn on the running light | Turn on the gradient light |
| Turn on the breathing light | Display battery level |
| Buzzer alarm |
1.1. Function description
By interacting with the voice recognition module on the X3 Plus, you can not only achieve the basic control of the car and light strips in 14.3, but also control the movements of the robotic arm, including up, down, left, and right states, and some settings. Action groups, such as the robot arm "dancing", the robot arm "nodding", etc.
1.2. Start
xxxxxxxxxx#Raspberry Pi 5 master needs to enter docker first, please perform this step#If running the script into docker fails, please refer to ROS/07, Docker tutorial~/run_docker.sh1.2.1. Function package path
xxxxxxxxxx~/yahboomcar_ws/src/yahboomcar_voice_ctrl/
1.2.2. Start
xxxxxxxxxxroslaunch yahboomcar_voice_ctrl voice_ctrl_arm.launch

1.2.3. Core file voice_ctrl_arm.py
code path
xxxxxxxxxx~/yahboomcar/src/yahboomcar_voice_ctrl/scripts
Core code analysis:
1). Import related library files
xxxxxxxxxxfrom Speech_Lib import Speechfrom voice_arm_library import *from Rosmaster_Lib import RosmasterSpeech_Lib: Speech module library, reference path: ~/software/py_install_V0.0.1/py_install/Speech_Lib
voice_arm_library: Robot arm action library, reference path: ~/yahboomcar/src/yahboomcar_voice_ctrl/scripts
Rosmaster_Lib: underlying driver library, reference path: ~/software/py_install/Rosmaster_Lib
Create speech recognition objects, drive control objects and robotic arm action objects
xxxxxxxxxxspe = Speech()self.car = Rosmaster()voice_arm = Voice_Arm()3). Main function: Recognize the voice, and execute the corresponding program based on the recognized voice. Take the robot arm to return to the initial position as an example.
xxxxxxxxxxspeech_r = spe.speech_read()if speech_r!=999:print(speech_r)#print(speech_r)if speech_r == 49 :spe.void_write(45)voice_arm.init_pose()Among them, voice_arm.init_pose() is the program that needs to be executed. At this time, it will jump to the voice_arm_library library and execute the function init_pose() inside. In the init_pose() function, what programs are executed? It is explained below,
xxxxxxxxxxdef init_pose(self):self.arm_joint.joints =[90.0, 145.0, 0.0, 0.0, 90.0, 31.0]self.pubPoint.publish(self.arm_joint)Here we define the angle that each joint needs to execute, and then use TargetAngle as the topic to publish the data; then return to the main function and subscribe to the TargetAngle topic; receive the data, enter the callback function, and then pass the self.car.set_uart_servo_angle function Send it to the bottom layer to drive the steering gear.
1.3. Program flow chart
