everything seems to work together as expected

(if not perfectly)
This commit is contained in:
Pavel Lutskov
2019-01-29 12:07:17 +01:00
parent 2d0441306a
commit b6e7ab8aa4
7 changed files with 71 additions and 43 deletions

View File

@@ -25,12 +25,16 @@ class ImageConverter {
ImageConverter() :
it_(nh_)
{
// Subscrive to input video feed
ros::Rate loop_rate(0.1);
loop_rate.sleep();
// Subscribe to input video feed
image_sub_ = it_.subscribe("/usb_cam/image_raw", 1,
&ImageConverter::imageCb, this);
// Create output windows
cv::namedWindow(ARUCO_WINDOW);
ROS_INFO("ARUCO: UP");
}
~ImageConverter() {
@@ -115,6 +119,7 @@ class ImageConverter {
int main(int argc, char** argv) {
ros::init(argc, argv, "aruco_detector");
ROS_INFO("ARUCO: STARTING");
ImageConverter ic;
ros::spin();
return 0;

View File

@@ -66,13 +66,12 @@ public:
&Nao_control::speechRecognitionCallback, this);
ic = nh_.serviceClient<teleoperation::InformController>(
"/inform_controller",5);
"/inform_controller", false);
}
~Nao_control() {
ROS_INFO("Destructor");
//stopping recognition
ROS_INFO("SPEECH: DESTRUCT");
std_srvs::Empty srv;
@@ -90,8 +89,7 @@ public:
ROS_INFO("A WORD WAS RECOGNIZED");
std_srvs::Empty srv;
ROS_INFO("Confidence Value:");
std::cout << int_to_str(msg->confidence_values[0]) << std::endl;
ROS_INFO("CONFIDENCE: %lf", msg->confidence_values[0]);
for (int i = 0; i < msg->words.size(); i++) {
std::cout << msg->words[i] << std::endl;
@@ -113,7 +111,7 @@ public:
std::string say = "Ok I understood " + msg->words[0];
naoqi_bridge_msgs::SpeechWithFeedbackActionGoal s_msg;
s_msg.goal_id.id = int_to_str(this->speech_id_ctr);
s_msg.goal_id.id = stuff_to_str(this->speech_id_ctr);
this->speech_id_ctr += 1;
s_msg.goal.say = say;
this->speech_pub.publish(s_msg);
@@ -125,6 +123,9 @@ public:
if (this->ic.call(ic_msg) && ic_msg.response.permission) {
this->imitating = true;
}
else {
ROS_ERROR("SPEECH: CONTROLLER UNREACHABLE");
}
}
else if (msg->words[0] == "stop") {
ROS_INFO("SPEECH: REQUESTING STOP IMITATION");
@@ -132,6 +133,9 @@ public:
if (this->ic.call(ic_msg) && ic_msg.response.permission) {
this->imitating = false;
}
else {
ROS_ERROR("SPEECH: CONTROLLER UNREACHABLE");
}
}
}
@@ -141,7 +145,7 @@ public:
std::string say = "I did not understand. Could you repeat that please";
naoqi_bridge_msgs::SpeechWithFeedbackActionGoal s_msg;
s_msg.goal_id.id = int_to_str(this->speech_id_ctr);
s_msg.goal_id.id = stuff_to_str(this->speech_id_ctr);
this->speech_id_ctr += 1;
s_msg.goal.say = say;
this->speech_pub.publish(s_msg);
@@ -171,11 +175,12 @@ public:
else vocabulary.push_back("stop");
vocabulary.push_back("open");
vocabulary.push_back("close");
// vocabulary.push_back("kill");
naoqi_bridge_msgs::SetSpeechVocabularyActionGoal msg;
msg.goal.words = vocabulary;
msg.goal_id.id = int_to_str(speech_id_ctr);
std::cout << msg << std::endl;
msg.goal_id.id = stuff_to_str(speech_id_ctr);
std::cout << msg.goal << std::endl;
speech_id_ctr += 1;
voc_params_pub.publish(msg);
ROS_INFO("VOCABULARY INITIALIZED");
@@ -184,6 +189,16 @@ public:
void commandRecognition()
{
//recognition has to be started and ended once a valid command was found
while (true) {
ros::Rate loop_rate(4);
loop_rate.sleep();
teleoperation::InformController ic_msg;
ic_msg.request.module = "speech_recognition";
ic_msg.request.message = "recognize";
if (this->ic.call(ic_msg) && ic_msg.response.permission) {
break;
}
}
this->initializeVocabulary();
ros::Rate loop_rate(1);
loop_rate.sleep();
@@ -202,7 +217,6 @@ int main(int argc, char** argv) {
ros::init(argc, argv, "speech");
Nao_control TermiNAOtor;
//TermiNAOtor.initializeVocabulary();
ros::Rate loop_rate(1);
loop_rate.sleep();
TermiNAOtor.commandRecognition();