Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include <sound_play/sound_play.h>
00036 #include <unistd.h>
00037
00038 void sleepok(int t, ros::NodeHandle &nh)
00039 {
00040 if (nh.ok())
00041 sleep(t);
00042 }
00043
00044 int main(int argc, char **argv)
00045 {
00046 ros::init(argc, argv, "sound_play_test");
00047
00048 ros::NodeHandle nh;
00049 sound_play::SoundClient sc;
00050
00051 sleepok(1, nh);
00052
00053 while(nh.ok())
00054 {
00055 sc.say("Hello world!");
00056 sleepok(2, nh);
00057
00058 const char *str1 = "I am annoying.";
00059 sc.repeat(str1);
00060 sleepok(4, nh);
00061 sc.stopSaying(str1);
00062
00063 sc.playWave("/usr/share/xemacs21/xemacs-packages/etc/sounds/boing.wav");
00064 sleepok(2, nh);
00065
00066 const char *str2 = "/usr/share/xemacs21/xemacs-packages/etc/sounds/piano-beep.wav";
00067 sc.startWave(str2);
00068 sleepok(4, nh);
00069 sc.stopWave(str2);
00070
00071 sc.play(sound_play::SoundRequest::NEEDS_UNPLUGGING);
00072 sleepok(2, nh);
00073
00074 sc.start(sound_play::SoundRequest::BACKINGUP);
00075 sleepok(4, nh);
00076 sc.stop(sound_play::SoundRequest::BACKINGUP);
00077
00078 sleepok(2, nh);
00079 sound_play::Sound s1 = sc.waveSound("/usr/share/xemacs21/xemacs-packages/etc/sounds/boing.wav");
00080 s1.repeat();
00081 sleepok(1, nh);
00082 s1.stop();
00083
00084 sleepok(2, nh);
00085 sound_play::Sound s2 = sc.voiceSound("This is a really long sentence that will get cut off.");
00086 s2.play();
00087 sleepok(1, nh);
00088 s2.stop();
00089
00090 sleepok(2, nh);
00091 sound_play::Sound s3 = sc.builtinSound(sound_play::SoundRequest::NEEDS_UNPLUGGING_BADLY);
00092 s3.play();
00093 sleepok(1, nh);
00094 s3.stop();
00095
00096 sleepok(2, nh);
00097 sound_play::Sound s4 = sc.waveSoundFromPkg("sound_play", "sounds/BACKINGUP.ogg");
00098 s4.play();
00099 sleepok(1, nh);
00100 s4.stop();
00101 }
00102 }