Revision 498cd9cd
client/cpp/examples/random_gaze/main.cpp | ||
---|---|---|
28 | 28 |
|
29 | 29 |
#include "RobotController.h" |
30 | 30 |
#include "RobotGaze.h" |
31 |
#include <unistd.h> |
|
31 |
#include <thread> |
|
32 |
#include <chrono> |
|
32 | 33 |
|
33 | 34 |
float rand_float(float min, float max){ |
34 | 35 |
float f = (float)rand() / RAND_MAX; |
... | ... | |
68 | 69 |
} |
69 | 70 |
|
70 | 71 |
robot_controller->set_gaze_target(gaze); |
71 |
usleep(1000/50 * 1000 );
|
|
72 |
}
|
|
72 |
std::this_thread::sleep_for(std::chrono::milliseconds(1000/50));
|
|
73 |
} |
|
73 | 74 |
|
74 | 75 |
} |
client/cpp/examples/speech_test/main.cpp | ||
---|---|---|
27 | 27 |
*/ |
28 | 28 |
|
29 | 29 |
#include "RobotController.h" |
30 |
#include <unistd.h> |
|
30 |
#include <thread> |
|
31 |
#include <chrono> |
|
31 | 32 |
|
32 | 33 |
#define BLOCKING true |
33 | 34 |
|
... | ... | |
38 | 39 |
|
39 | 40 |
printf("> speech test starting.\n"); |
40 | 41 |
|
41 |
robot_controller->set_speak("i will start counting now.\n", BLOCKING);
|
|
42 |
robot_controller->set_speak("I will start counting now.\n", BLOCKING);
|
|
42 | 43 |
while(1){ |
43 | 44 |
std::string text = std::to_string(count++); |
44 | 45 |
printf("> saying '%s'\n",text.c_str()); |
45 | 46 |
robot_controller->set_speak(text, BLOCKING); |
46 |
sleep(1);
|
|
47 |
std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
47 | 48 |
} |
48 |
|
|
49 | 49 |
} |
server/src/Arbiter.cpp | ||
---|---|---|
144 | 144 |
|
145 | 145 |
//block until ani was played back |
146 | 146 |
while(incoming_animation->is_active()){ |
147 |
//printf("A"); fflush(stdout); |
|
148 |
usleep(1*1000); //1ms, save cpu cycles |
|
147 |
std::this_thread::sleep_for(std::chrono::milliseconds(1));//save cpu cycles |
|
149 | 148 |
} |
150 | 149 |
|
151 | 150 |
//ok, it finished. we can safely remove it now: |
... | ... | |
183 | 182 |
if (audio_player != NULL){ |
184 | 183 |
while(audio_player->is_playing()){ |
185 | 184 |
//save some cpu cycles: |
186 |
usleep(1*1000); //1ms
|
|
185 |
std::this_thread::sleep_for(std::chrono::milliseconds(1)); //1ms
|
|
187 | 186 |
} |
188 | 187 |
} |
189 | 188 |
|
... | ... | |
191 | 190 |
//so check now if the utterance finished as well: |
192 | 191 |
while (utterance->is_playing()){ |
193 | 192 |
//save some cpu cycles: |
194 |
usleep(1*1000); //1ms
|
|
193 |
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
195 | 194 |
} |
196 | 195 |
|
197 | 196 |
} |
server/src/AudioPlayer.cpp | ||
---|---|---|
27 | 27 |
*/ |
28 | 28 |
|
29 | 29 |
#include "AudioPlayer.h" |
30 |
#include <thread> |
|
31 |
#include <chrono> |
|
30 | 32 |
|
31 | 33 |
using namespace std; |
32 | 34 |
|
... | ... | |
49 | 51 |
|
50 | 52 |
while(playback_state != CLOSED){ |
51 | 53 |
printf("> waiting for end of audio playback\n"); |
52 |
usleep(1000);
|
|
54 |
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
53 | 55 |
} |
54 | 56 |
} |
server/src/AudioPlayerLibAO.cpp | ||
---|---|---|
27 | 27 |
*/ |
28 | 28 |
|
29 | 29 |
#include "AudioPlayerLibAO.h" |
30 |
#include <thread> |
|
31 |
#include <chrono> |
|
30 | 32 |
|
31 | 33 |
using namespace std; |
32 |
using namespace boost; |
|
33 | 34 |
|
34 | 35 |
//new audio player with gievn device type (default is pulse) |
35 | 36 |
AudioPlayerLibAO::AudioPlayerLibAO(string driver): AudioPlayer(driver){ |
... | ... | |
66 | 67 |
//check if we can play this file: |
67 | 68 |
while(playback_state != IDLE){ |
68 | 69 |
printf("> player not ready yet, waiting for 10ms\n"); |
69 |
usleep(10*1000);
|
|
70 |
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
70 | 71 |
} |
71 | 72 |
|
72 | 73 |
audio_format = extract_ao_format(audio_data); |
... | ... | |
76 | 77 |
//wait for playback to start: |
77 | 78 |
printf("> waiting for playback start...\n"); |
78 | 79 |
while(playback_requested){ |
79 |
usleep(1*1000);
|
|
80 |
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
80 | 81 |
} |
81 | 82 |
printf("> playback running.\n"); |
82 | 83 |
} |
... | ... | |
177 | 178 |
} |
178 | 179 |
|
179 | 180 |
//1ms delay to safe cpu time |
180 |
usleep(1000);
|
|
181 |
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
181 | 182 |
} |
182 | 183 |
|
183 | 184 |
//shutdown audio! |
server/src/AudioPlayerRSB.cpp | ||
---|---|---|
71 | 71 |
//check if we can play this file: |
72 | 72 |
while(playback_state != IDLE){ |
73 | 73 |
printf("> player not ready yet, waiting for 10ms\n"); |
74 |
usleep(10*1000);
|
|
74 |
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
75 | 75 |
} |
76 | 76 |
|
77 | 77 |
//ok, we can play the audio. copy/setup data: |
... | ... | |
112 | 112 |
} |
113 | 113 |
|
114 | 114 |
//add some delay to meet the delay until playback starts (FIXME: this should be determined!) |
115 |
//usleep(100*1000); //100ms
|
|
115 |
//std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
116 | 116 |
|
117 | 117 |
//ok we can now play the data |
118 | 118 |
printf("> AudioPlayer: playback started\n"); |
... | ... | |
146 | 146 |
} |
147 | 147 |
|
148 | 148 |
//1ms delay to safe cpu time |
149 |
usleep(1000);
|
|
149 |
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
150 | 150 |
} |
151 | 151 |
|
152 | 152 |
//done |
Also available in: Unified diff