Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
As far as setting up an LED to test the voice command, could you give me some instruction on how to do that?
I just need to know if uploading the compiled hex file from AVR Studio is a proper way to program the Axon II.
I dont know how to upload a screenshot here.
//allows for printing with features, but uses more memory#define RPRINTF_FLOAT#define RPRINTF_COMPLEX#include "hardware.h"#include "VR_library.h" //voice recognition library// Initialise the hardwarevoid appInitHardware(void) { initHardware();}// Initialise the softwareTICK_COUNT appInitSoftware(TICK_COUNT loopStart){ servosDisconnect(&bank1); delay_ms(1200);//Axon II bootup time rprintf("\n\nAxon Initiated\n"); VR_Module_init(); return 0;}// This is the main loopTICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) { int8_t voice_command=-2; //start voice recognition (note: it times out) VR_Module_start_recognition(VR_group);//group B while(voice_command == -2) voice_command = VR_Module_get_result(); if(voice_command >= 0) { rprintf("\nvoice command is: "); //turn on servos (I turn off to prevent noise interference) act_setConnected(&wheel_left, TRUE); act_setConnected(&wheel_right, TRUE); //swap languages - not used in this example, as both languages are set to do the same if(VR_group==1 && voice_command==0) { rprintf(" THAI"); VR_group=2; } else if(VR_group==2 && voice_command==0) { rprintf(" ENGLISH"); VR_group=1; } //other commands else if(voice_command==1) { act_setSpeed(&wheel_left,127); act_setSpeed(&wheel_right,-127); rprintf(" LEFT"); delay_ms(500); } else if(voice_command==2) { act_setSpeed(&wheel_left,-127); act_setSpeed(&wheel_right,127); rprintf(" RIGHT"); delay_ms(500); } else if(voice_command==3) { act_setSpeed(&wheel_left,127); act_setSpeed(&wheel_right,127); rprintf(" FORWARD"); delay_ms(1500); } else if(voice_command==4) { rprintf(" DANCE"); //forward act_setSpeed(&wheel_left,127); act_setSpeed(&wheel_right,127); delay_ms(600); //reverse act_setSpeed(&wheel_left,127); act_setSpeed(&wheel_right,127); delay_ms(600); //spin right act_setSpeed(&wheel_left,-127); act_setSpeed(&wheel_right,127); delay_ms(1200); //spin left act_setSpeed(&wheel_left,127); act_setSpeed(&wheel_right,-127); delay_ms(1200); } else if(voice_command==5) rprintf(" WAI PRA"); else if(voice_command==6) rprintf(" WORSHIP"); else if(voice_command==7) rprintf(" ARM"); else if(voice_command==8) rprintf(" ATTACK"); else if(voice_command==9) { rprintf(" SHUTDOWN"); servosDisconnect(&bank1); } else if(voice_command==10) { rprintf(" POWER_UP"); servosConnect(&bank1); } else if(voice_command==11) { LED_off(&statusLED); rprintf(" LED"); delay_ms(2000); LED_on(&statusLED); } else if(voice_command==12) { act_setSpeed(&elbow,80); rprintf(" UP"); } else if(voice_command==13) { act_setSpeed(&elbow,-80); rprintf(" DOWN"); } else if(voice_command==14) { act_setSpeed(&gripper,-50); rprintf(" GRAB"); } else if(voice_command==15) { act_setSpeed(&gripper,50); rprintf(" RELEASE"); } //stop further motion and turn off servos act_setSpeed(&wheel_left,0); act_setSpeed(&wheel_right,0); act_setConnected(&wheel_left, FALSE); act_setConnected(&wheel_right, FALSE); } rprintf("\n"); delay_ms(100); return 0;}/*Group 1: 0 PASA_THAI1 LEFT2 RIGHT3 FORWARD4 DANCE5 WAI PRA6 WORSHIP7 ARM8 ATTACK9 SHUTDOWN10 POWER_UP11 LED12 UP13 DOWN14 GRAB15 RELEASEGroup 2:0 PASA_ANGRIT1 LEO_SAI2 LEO_KWA3 DTRONG_BAI4 DTEN LOY5 WAI PRA6 KOWROP BUUCHAA7 KAEN8 HAA REUNG9 BID FAI10 BERD FAI11 LED12 KEUN13 LONG14 JAB MAN15 BLOY MAN*/
//VR Recognition Module for Axon#define DEFAULT_LANGUAGE 'A'//set to English//when you program voice commands in the VRbot,//make sure Thai (or whatever) is in the first group (1)//and English is in the second group (2)uint8_t VR_group=2;//default GroupMAKE_WRITER(writerVoice_Recognition) { return Voice_RecognitionSendByte(byte); }//set language for SI recognition//Language (A = English, B = Italian, C = Japanese, D = German) void VR_Module_change_language(char lang) { //transmit data to VR module, store previous UART setting Writer old = rprintfInit(&writerVoice_Recognition); rprintf("l");//change language rprintf("%c",lang); while(Voice_RecognitionGetByte() != 'o')//wait until language changed delay_ms(20); rprintfInit(old);//use default output method }//initialization, put in software initvoid VR_Module_init(void) { //bufferFlush(&rx_Voice_Recognition_Buf); //bufferFlush(&tx_Voice_Recognition_Buf); uartFlushReceiveBuffer(Voice_Recognition); uartFlushTransmitBuffer(Voice_Recognition); rprintf("\nvoice recognition initializing ..."); delay_ms(1000);//required boot up delay //transmit data to VR module, store previous UART setting Writer old = rprintfInit(&writerVoice_Recognition); //wake up while(Voice_RecognitionGetByte() != 'o') { rprintf("b"); delay_ms(300); } rprintfInit(old);//use default output method rprintf(" initialized"); //transmit data to VR module, store previous UART setting rprintfInit(&writerVoice_Recognition); //ask for firmware id (not required) //rprintf("x"); //while(Voice_RecognitionGetByte() != 'x'); //set language VR_Module_change_language(DEFAULT_LANGUAGE); rprintfInit(old);//use default output method rprintf("\nDefault language changed."); //transmit data to VR module, store previous UART setting rprintfInit(&writerVoice_Recognition); //set timeout to 5 seconds rprintf("o"); rprintf("F"); while(Voice_RecognitionGetByte() != 'o')//wait until changed delay_ms(20); rprintfInit(old);//use default output method rprintf("\nTiming set."); //transmit data to VR module, store previous UART setting rprintfInit(&writerVoice_Recognition); //change knob rprintf("k"); rprintf("A");//A to E, E being fewer valid results while(Voice_RecognitionGetByte() != 'o')//wait until changed delay_ms(20); //change level rprintf("v"); rprintf("B");//B to F, F gives least false positives while(Voice_RecognitionGetByte() != 'o')//wait until changed delay_ms(20); rprintfInit(old);//use default output method rprintf("\nSensitivity set."); //transmit data to VR module, store previous UART setting rprintfInit(&writerVoice_Recognition); rprintfInit(old);//use default output method rprintf("\n.....initialized."); }//start voice recognition (0-3)void VR_Module_start_recognition(uint8_t group) { char number='B'; rprintf("\nvoice recognition activating..."); //transmit data to VR module, store previous UART setting Writer old = rprintfInit(&writerVoice_Recognition); if(group==0)//trigger number='A'; else if(group==1)//1-15, generic number='B'; else if(group==2) number='C'; else if(group==3) number='D'; else if(group==16)//16, password number='Q'; rprintf("d"); rprintf("%c",number); rprintfInit(old);//use default output method rprintf("\n..... group %d activated.",group); }//gets result of voice recognition// -1 = timed out, no word detected// -2 = no word detected yet within time limit// any other value represents detect word//note: may take several seconds before result is returnedint8_t VR_Module_get_result(void) { char data = Voice_RecognitionGetByte(); //no data received if ((uint8_t)data == -1) return -2; //if positive result else if (data == 'r') { rprintf("\ngot positive result"); //transmit data to VR module, store previous UART setting Writer old = rprintfInit(&writerVoice_Recognition); rprintf(" "); rprintfInit(old);//use default output method //wait for returned result data = Voice_RecognitionGetByte(); while((int8_t)data == -1) data = Voice_RecognitionGetByte(); return data - 'A'; } //timed out else if (data == 't') { rprintf("\nvoice detection timed out"); return -1; } else if (data == 'e') { char error_code=0; data=-1;//reset value Writer old = rprintfInit(&writerVoice_Recognition); //get error code rprintf(" "); while((int8_t)data == -1) data = Voice_RecognitionGetByte(); error_code = (data - 'A') * 16; rprintf(" "); while((int8_t)data == -1) data = Voice_RecognitionGetByte(); error_code = error_code + (data - 'A'); rprintfInit(old);//use default output method //note that manual actually specifies error codes rprintf("\nvoice error detected: %c", error_code); return -1; } return -2; }