icub-client
pointing.cpp
Go to the documentation of this file.
1 #include "pointing.h"
2 
3 using namespace std;
4 using namespace yarp::os;
5 
6 
8  external_port_name = "/proactiveTagging/rpc";
9  from_sensation_port_name = "/opcSensation/known_entities:o";
10 }
11 
12 void Pointing::run(const Bottle &args) {
13  yInfo() << "Pointing::run";
14  Bottle *sensation = sensation_port_in.read();
15 
16  string obj_name, sentence;
17  bool no_objects = true;
18  if (args.size()!=0) {
19  yDebug()<<args.toString() << args.size();
20  obj_name = args.get(0).asList()->get(0).asString();
21  yDebug() << "Object selected: " << obj_name;
22  sentence = "Okay, this is the ";
23  no_objects=false;
24  } else {
25  if(sensation->size()==0) {
26  iCub->lookAtPartner();
27  iCub->say("There are no objects I can point at.");
28  iCub->home();
29  return;
30  }
31  int id = yarp::os::Random::uniform(0, sensation->size() - 1);
32  obj_name = sensation->get(id).asList()->get(1).asString();
33  yDebug() << "Randomly selected: " << id << " " << obj_name;
34  sentence = "I could point to the ";
35  }
36 
37  yDebug() << "[pointing]: opc checkout";
38 
39  iCub->say(sentence + obj_name, false);
40 
41  bool succeeded = iCub->point(obj_name);
42  if (no_objects){
43  bool look_success = iCub->lookAtPartner();
44  if (succeeded) {
45  iCub->say("Do you know that this is a " + obj_name, false);
46  } else {
47  iCub->say("I couldn't find the " + obj_name, false);
48  }
49  if(look_success) {
50  yarp::os::Time::delay(1.5);
51  }
52  }
53  iCub->home();
54 }
void configure()
Definition: pointing.cpp:7
void run(const yarp::os::Bottle &args)
Definition: pointing.cpp:12
STL namespace.