/* program to take several pictures, move, and beep single-robot version */ #include "MyroC.h" #include "eSpeakPackage.h" #include // needed for sleep function #include // needed for printing to terminal /* Musical notes in the scale, as they correspond to beep frequency */ const int pitchA4 = 440; const int pitchBf4 = 466; const int pitchAs4 = 466; const int pitchB4 = 493; const int pitchC5 = 523; const int pitchDf5 = 554; const int pitchCs5 = 554; const int pitchD5 = 587; const int pitchEf5 = 622; const int pitchDs5 = 622; const int pitchE5 = 659; const int pitchF5 = 698; const int pitchGf5 = 739; const int pitchFs5 = 739; const int pitchG5 = 783; const int pitchAf5 = 830; const int pitchGs5 = 830; const int pitchA5 = 880; const int pitchBf5 = 932; const int pitchAs5 = 932; const int pitchB5 = 987; /* play first phrase of Spirit Song by John Dunbar */ void playSongPhrase1 () { eSpeakTalk ("play first phrase of song"); rBeep (1, pitchA5); /* robot beeps with the pitch A5 (references to 880 Hz.) for beat4 seconds. */ rBeep (0.75, pitchB5); rBeep (0.25, pitchA5); rBeep (1, pitchG5); rBeep (0.75, pitchE5); rBeep (0.75, pitchF5); rBeep (0.25, pitchA5); rBeep (0.75, pitchG5); rBeep (0.25, pitchF5); rBeep (1.25, pitchE5); } /* play second phrase of Spirit Song by John Dunbar */ void playSongPhrase2 () { eSpeakTalk ("play second phrase of song"); rBeep (1, pitchA5); rBeep (0.75, pitchB5); rBeep (0.25, pitchA5); rBeep (1, pitchG5); rBeep (0.75, pitchE5); } /* play third phrase of Spirit Song by John Dunbar */ void playSongPhrase3 () { eSpeakTalk ("play third phrase of song"); rBeep (0.75, pitchF5); rBeep (0.25, pitchE5); rBeep (0.75, pitchD5); rBeep (0.25, pitchC5); rBeep (1.0, pitchC5); } int main () { // initialization rConnect ("/dev/rfcomm0"); eSpeakConnect(); /* take and display first picture looking ahead */ playSongPhrase1 (); Picture pic = rTakePicture (); rDisplayPicture (&pic, 3.0, "camera view"); /* second picture on the right */ rTurnRight (0.5, 1.0); // turn right for 0.5 seconds at full speed playSongPhrase2 (); pic = rTakePicture (); rDisplayPicture (&pic, 3.0, "camera view"); /* third picture on the left */ rTurnLeft (1.0, 1.0); // turn left for 1.0 seconds at full speed playSongPhrase3 (); pic = rTakePicture (); rDisplayPicture (&pic, 3.0, "camera view"); // finish up eSpeakTalk ("Finishing up"); rDisconnect (); eSpeakDisconnect (); return 0; }