Welcome to DOFBOT SE repository
4.Memory Learning Mode
Memory Learning Mode
1. Function Description
Achieve action learning and execution through voice commands.
2. Startup and Operation
2.1 Startup
Open the terminal and enter the following command to start:
xxxxxxxxxxpython3 ~/dofbot_voice/scripts/learnning_model.py
2.2 Operation Steps
After the program runs successfully, the voice module will broadcast "I'm here", then say "Hi, yahboom" to the voice module. The voice module replies "I'm here" indicating successful wake-up.
2.2.1 Learning Actions
Move the robotic arm to the desired pose, then say "Record it" to the voice module. If fewer than 20 groups of actions have been input, the voice module will reply "OK". If 20 groups of actions have already been input, the voice module will reply "Too many actions, I Can't record them". If you want to end the input, say "Over" to the voice module, and the voice module will reply "ok".
2.2.2 Playing Actions
Say "Display actions" to the voice module, the voice module will reply "ok", and the robotic arm will move to the learned poses sequentially.
2.2.3 Clearing Actions
Say "Clear actions" to the voice module, the voice module will reply "ok", then you can proceed to the next learning session.
3. Core Code Analysis
Source code path: ~/dofbot_voice/scripts/learnning_model.py
# Call function to get voice recognition resultresult = mySpeech.speech_read()# If the voice recognition result is 55, it means learning and recording the current robotic arm pose is requiredif result == 55: time.sleep(.1) Arm.Arm_Action_Study() time.sleep(.5) num = Arm.Arm_Read_Action_Num() print(num) time.sleep(.5) # If less than 20 groups of actions, broadcast "OK, please input the next group of actions" if num < 20: mySpeech.void_write(55) # If greater than or equal to 20 groups of actions, broadcast "More than 20 groups of actions, recording ended" elif num >= 20: mySpeech.void_write(56)# If the voice recognition result is 56, it means ending the action learning recordingelif result == 56: mySpeech.void_write(57) Arm.Arm_Button_Mode(0)# If the voice recognition result is 57, it means playing the learned actionselif result == 57: mySpeech.void_write(58) Arm.Arm_Action_Mode(1)# If the voice recognition result is 58, it means clearing actions in the action listelif result == 58: mySpeech.void_write(59) Arm.Arm_Clear_Action()