icub-client
main.cpp
Go to the documentation of this file.
1 /*
2 * Copyright(C) 2015 WYSIWYD Consortium, European Commission FP7 Project ICT - 612139
3 * Authors: Ugo Pattacini
4 * email : ugo.pattacini@iit.it
5 * Permission is granted to copy, distribute, and / or modify this program
6 * under the terms of the GNU General Public License, version 2 or any
7 * later version published by the Free Software Foundation.
8 *
9 * A copy of the license can be found at
10 * icub-client / license / gpl.txt
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General
15 * Public License for more details
16 */
17 
18 #include <yarp/os/all.h>
19 #include <yarp/sig/all.h>
22 
23 using namespace yarp::os;
24 using namespace yarp::sig;
25 using namespace icubclient;
26 
27 int main()
28 {
29  Network yarp;
30  if (!yarp.checkNetwork())
31  {
32  yError()<<"YARP network seems unavailable!";
33  return 1;
34  }
35 
36  OPCClient world("test_are_attention/opc");
37  if (!world.connect("OPC"))
38  {
39  yError()<<"OPC seems unavailabe!";
40  return 1;
41  }
42  world.clear();
43 
44  ICubClient icub("test_are_attention","icubClient","test_are_attention.ini");
45  if (!icub.connect())
46  {
47  yError()<<"One or more functionalities seem unavailabe!";
48  world.close();
49  return 1;
50  }
51 
52  Object *object=world.addOrRetrieveEntity<Object>("BEER");
53  object->m_present=1.0;
54  object->m_ego_position[0]=-0.35;
55  object->m_ego_position[1]=-0.2;
56  object->m_ego_position[2]=-0.1;
57  yInfo()<<"creating a "<<object->name();
58  world.commit(object);
59 
60  yInfo()<<"homing ...";
61  icub.home();
62 
63  yInfo()<<"looking at the "<<object->name();
64  icub.look(object->name());
65  Time::delay(3.0);
66 
67  yInfo()<<"pointing at the "<<object->name();
68  icub.point(object->name());
69 
70  yInfo()<<"shutting down ... ";
71  world.clear();
72  icub.close();
73  world.close();
74  yInfo()<<"... bye ";
75 
76  return 0;
77 }
78 
79 
bool point(const yarp::sig::VectorOf< double > &target, const yarp::os::Bottle &options=yarp::os::Bottle())
Point at a specified location from the iCub.
void close()
Close the client ports.
Definition: opcClient.cpp:69
Grants access to high level motor commands (grasp, touch, look, goto, etc) of the robot as well as it...
Definition: icubClient.h:66
bool connect(const std::string &opcName="OPC")
Try to connect all functionalities.
Definition: icubClient.cpp:132
double m_present
Is the object present in the scene A value of 1.0 means that the object currently is in the scene A v...
Definition: object.h:69
void commit()
Commit all the entities & relations stored locally, erasing the server copies.
Definition: opcClient.cpp:835
T * addOrRetrieveEntity(const std::string &name)
Obtains an entity with the given name.
Definition: opcClient.h:119
bool connect(const std::string &opcName)
Try to connect the client to an OPC server.
Definition: opcClient.h:157
Represent any physical entity (including objects and agents) that can be stored within the OPC...
Definition: object.h:35
bool home(const std::string &part="all")
Go in home position.
int main()
Definition: main.cpp:32
An OPC client using the datastructures defined within the icub-client library.
Definition: opcClient.h:35
bool look(const std::string &target, const yarp::os::Bottle &options=yarp::os::Bottle())
Look at a specified target object.
void clear()
Clear the OPC content.
Definition: opcClient.cpp:80
std::string name() const
Return the name of an entity (which has to be unique within the OPC)
Definition: entity.h:93
void close()
Properly closes all ports which were opened.
Definition: icubClient.cpp:140