mirror of
https://github.com/Jieshoudaxue/ros_senior.git
synced 2026-08-29 08:34:43 +08:00
[fix] up it
This commit is contained in:
@@ -33,18 +33,21 @@ public:
|
||||
|
||||
bool ok = client_.call(req, resp);
|
||||
if (ok) {
|
||||
printf("send str2voice service success: %s\n", req.data.c_str());
|
||||
geometry_msgs::Twist msg;
|
||||
msg.linear.x = linear_x;
|
||||
msg.angular.z = angular_z;
|
||||
cmd_pub_.publish(msg);
|
||||
printf("send str2voice service success: %s, and pub cmd_vel\n", req.data.c_str());
|
||||
for (int i = 0; i < 10; i ++) {
|
||||
geometry_msgs::Twist msg;
|
||||
msg.linear.x = linear_x;
|
||||
msg.angular.z = angular_z;
|
||||
cmd_pub_.publish(msg);
|
||||
sleep(0.5);
|
||||
}
|
||||
} else {
|
||||
ROS_ERROR("failed to send str2voice service");
|
||||
}
|
||||
}
|
||||
|
||||
void ChatterCallbback(const std_msgs::String::ConstPtr &msg) {
|
||||
ROS_INFO("i received: %s", msg->data.c_str());
|
||||
printf("i received: %s\n", msg->data.c_str());
|
||||
|
||||
int ret = -1;
|
||||
std::string voice_txt = msg->data;
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
static void InitSpeech() {
|
||||
VoiceDetector::voice_txt_ = "";
|
||||
|
||||
printf("Start Listening...\n");
|
||||
printf("clear cache, start Listening...\n");
|
||||
}
|
||||
|
||||
static void EndSpeech(int reason) {
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
}
|
||||
|
||||
/* demo 15 seconds recording */
|
||||
sleep(15);
|
||||
sleep(10);
|
||||
|
||||
ret = sr_stop_listening(&iat);
|
||||
if (ret) {
|
||||
@@ -148,6 +148,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
std::string voice_txt = VoiceDetector::get_voice_txt_();
|
||||
if (voice_txt == "") {
|
||||
printf("voice_txt is empty\n");
|
||||
continue;
|
||||
} else if (voice_txt.find("结束") != std::string::npos) {
|
||||
break;
|
||||
@@ -156,6 +157,8 @@ int main(int argc, char* argv[]) {
|
||||
std_msgs::String msg;
|
||||
msg.data = voice_txt;
|
||||
str_pub_.publish(msg);
|
||||
|
||||
sleep(10);
|
||||
}
|
||||
|
||||
ros::spin();
|
||||
|
||||
Reference in New Issue
Block a user