icub-client
moveObject.cpp
Go to the documentation of this file.
1 #include "moveObject.h"
2 
3 using namespace std;
4 using namespace yarp::os;
5 
7  Bottle targetGroup = (rf.findGroup("targetPos"));
8  target_pullback = targetGroup.check("backPos",Value(-0.25)).asDouble();
9  target_pushfront = targetGroup.check("frontPos",Value(-0.5)).asDouble();
10  target_pushleft = targetGroup.check("leftPos",Value(-0.2)).asDouble();
11  target_pushright = targetGroup.check("rightPos",Value(0.2)).asDouble();
12 }
13 
14 void MoveObject::run(const Bottle &args) {
15  yInfo() << "MoveObject::run";
16 
17  bool succeeded;
18  string obj_name, move_type;
19 
20  if (args.size()!=0) {
21  obj_name = args.get(0).asList()->get(0).asString();
22  move_type = args.get(0).asList()->get(1).asString();
23  } else {
24  yError() << "Wrong number of parameters, abort";
25  return;
26  }
27  yInfo() << "received context from planner:" << move_type << "and" << obj_name;
28 
29  if(move_type == "front") {
30  iCub->say("I will push the " + obj_name + " to the front");
31  } else if(move_type == "back") {
32  iCub->say("I will pull the " + obj_name + " to the back");
33  } else if(move_type == "left") {
34  iCub->say("I will push the " + obj_name + " to the left");
35  } else if(move_type == "right") {
36  iCub->say("I will push the " + obj_name + " to the right");
37  } else {
38  yError() << "[moveObject] Wrong direction";
39  iCub->say("I don't know this direction");
40  return;
41  }
42 
43  iCub->opc->checkout();
44 
45  if(move_type == "front") {
46  succeeded = iCub->pushKarmaFront(obj_name, target_pushfront);
47  } else if(move_type == "back") {
48  succeeded = iCub->pullKarmaBack(obj_name, target_pullback);
49  } else if(move_type == "left") {
50  succeeded = iCub->pushKarmaLeft(obj_name, target_pushleft);
51  } else if(move_type == "right") {
52  succeeded = iCub->pushKarmaRight(obj_name, target_pushright);
53  } else {
54  yError() << "[moveObject] Wrong direction";
55  iCub->say("I don't know this direction");
56  return;
57  }
58 
59  if (!succeeded) {
60  iCub->lookAtPartner();
61  iCub->say("I could not move the object");
62  yError() << "Karma did not succeed moving the object";
63  }
64 
65  iCub->home();
66 }
STL namespace.
void run(const yarp::os::Bottle &args)
Definition: moveObject.cpp:14
void configure()
Definition: moveObject.cpp:6