void Remind::run() { ros::NodeHandle n; if (!pub_set) { remind_pub = n.advertise<sound_play::SoundRequest>("robotsound", 1000); pub_set = true; } ros::ServiceClient krClient = n.serviceClient<bwi_kr_execution::UpdateFluents> ( "update_fluents" ); krClient.waitForExistence(); if (remind_pub.getNumSubscribers() == 0) return; //if the subscriber is not connected, sleep //speak sound_play::SoundRequest sound_req; sound_req.sound = sound_play::SoundRequest::SAY; sound_req.command = sound_play::SoundRequest::PLAY_ONCE; std::stringstream ss; ss << "Hi " << person_to_remind << "!\n"; ss << "You have a meeting right now.\n"; ss << "Please come to room " << room << " .\n"; sound_req.arg = ss.str(); remind_pub.publish(sound_req); ss.str(""); ss << "Hi " << person_to_remind << "!\n"; ss << "This is a friendly reminder that you have a meeting right now: \n"; ss << "Meeting name: " << meeting << "\n"; ss << "Meeting room: " << room; vector<string> options; options.push_back("Okay, I'll come soon."); CallGUI remindPerson("remindPerson", CallGUI::CHOICE_QUESTION, ss.str(), 60.0, options); remindPerson.run(); bwi_kr_execution::UpdateFluents uf; bwi_kr_execution::AspFluent fluent; fluent.timeStep = 0; fluent.variables.push_back(person_to_remind); fluent.variables.push_back(meeting); fluent.name = "inmeeting"; uf.request.fluents.push_back(fluent); krClient.call(uf); CallGUI thank("thank", CallGUI::DISPLAY, "Thank you!"); thank.run(); done = true; }
void AskPerson::run() { ros::NodeHandle n; if (!pub_set) { ask_pub = n.advertise<sound_play::SoundRequest>("robotsound", 1000); pub_set = true; } if (ask_pub.getNumSubscribers() == 0) return; //if the subscriber is not connected, sleep ros::ServiceClient krClient = n.serviceClient<bwi_kr_execution::UpdateFluents> ( "update_fluents" ); krClient.waitForExistence(); //speak sound_play::SoundRequest sound_req; sound_req.sound = sound_play::SoundRequest::SAY; sound_req.command = sound_play::SoundRequest::PLAY_ONCE; stringstream ss; ss << "Hi " << person_to_ask << "! "; ss << "Do you know where " << person_to_know << " is?"; sound_req.arg = ss.str(); ask_pub.publish(sound_req); vector<string> options; options.push_back("Yes! " + person_to_know + " is in GDC and I know exactly where."); options.push_back("No, I have no idea."); CallGUI askPerson("askPerson", CallGUI::CHOICE_QUESTION, "Hi " + person_to_ask + "! Do you know where " + person_to_know + " is?", 60.0, options); askPerson.run(); int response = askPerson.getResponseIndex(); if (response < 0) { bwi_kr_execution::UpdateFluents uf; bwi_kr_execution::AspFluent fluent; fluent.timeStep = 0; fluent.variables.push_back(person_to_ask); fluent.variables.push_back(person_to_know); fluent.name = "-know"; uf.request.fluents.push_back(fluent); krClient.call(uf); } if (response == 1) { sound_req.arg = "OK, thank you anyway!"; ask_pub.publish(sound_req); CallGUI thank("thank", CallGUI::DISPLAY, "OK, thank you anyway!"); thank.run(); bwi_kr_execution::UpdateFluents uf; bwi_kr_execution::AspFluent fluent; fluent.timeStep = 0; fluent.variables.push_back(person_to_ask); fluent.variables.push_back(person_to_know); fluent.name = "-know"; uf.request.fluents.push_back(fluent); krClient.call(uf); } if (response == 0) { bool know = false; int count = 0; sound_req.arg = "Great! Please tell me the room number."; CallGUI *askPerson = new CallGUI("askPerson", CallGUI::TEXT_QUESTION, "Great! Please tell me the room number.", 60.0); while ((! know) && (count < 3)) { ask_pub.publish(sound_req); askPerson->run(); if ((askPerson->getResponseIndex() == -3) && (askPerson->getResponse() != "")) { bwi_kr_execution::UpdateFluents uf; bwi_kr_execution::AspFluent fluent; fluent.timeStep = 0; fluent.variables.push_back(person_to_know); fluent.variables.push_back(askPerson->getResponse()); fluent.name = "inroom"; uf.request.fluents.push_back(fluent); krClient.call(uf); know = uf.response.consistent; } count++; sound_req.arg = "The room number doesn't exist. Please try again."; delete askPerson; askPerson = new CallGUI("askPerson", CallGUI::TEXT_QUESTION, "The room number doesn't exist. Please try again.", 60.0); } sound_req.arg = "Thank you!"; CallGUI *thank = new CallGUI("thank", CallGUI::DISPLAY, "Thank you!"); if (!know) { sound_req.arg = "OK, thank you anyway!"; delete thank; thank = new CallGUI("thank", CallGUI::DISPLAY, "OK, thank you anyway!"); } //ask_pub.publish(sound_req); thank->run(); bwi_kr_execution::UpdateFluents uf; bwi_kr_execution::AspFluent fluent; fluent.timeStep = 0; fluent.variables.push_back(person_to_ask); fluent.variables.push_back(person_to_know); fluent.name = (know ? "know" : "-know"); uf.request.fluents.push_back(fluent); krClient.call(uf); } done = true; }
void download() { closegraph(); initwindow(1275,700); setfillstyle(1,1); floodfill(100,100,1); setcolor(11); setbkcolor(1); settextstyle(10,0,5); outtextxy(30,275,"Downloading"); //Download bar start setcolor(15); moveto(40,325); lineto(1230,325); arc(40,335,90,270,10); moveto(40,345); lineto(1230,345); arc(1230,335,270,90,10); //Download bar end settextstyle(10,0,7); setbkcolor(1); setcolor(1); //Increasing bar for(int i=0,j=40;i<100;i++,j=j+12) { outintxy(1120,250,i); outtextxy(1200,250,"%"); setcolor(15); moveto(j,325); lineto(j,345); setcolor(11); setfillstyle(1,11); floodfill(j-2,335,15); delay(200); } delay(3000); outtextxy(1100,250,"100%"); floodfill(1231,335,15); setcolor(0); //Done button rectangle(1075,580,1205,650); setfillstyle(1,7); floodfill(1100,600,0); setbkcolor(7); settextstyle(0,0,3); outtextxy(1090,605,"Done"); int x=0,y=0; x = getmaxx( ); y = getmaxy( ); setmousequeuestatus(WM_LBUTTONDOWN); while(!ismouseclick(WM_LBUTTONDOWN)); { getmouseclick(WM_LBUTTONDOWN,x,y); } if(( x > 1075 && x < 1205 ) && ( y > 580 && y < 650 )) { thank(); } system("pause"); }