icub-basic-demos
main.cpp
1 /*
2  * Copyright (C) 2016 Department of Robotics Brain and Cognitive Sciences - Istituto Italiano di Tecnologia
3  * Author: Marco Randazzo
4  * email: marco.randazzo@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  * http://www.robotcub.org/icub/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>
20 #include <yarp/dev/all.h>
21 
22 #include <string>
23 #include <QApplication>
24 #include "mainwindow.h"
25 #include "robot_interfaces.h"
26 
27 using namespace yarp::os;
28 using namespace yarp::sig;
29 using namespace yarp::dev;
30 using namespace std;
31 
32 int main(int argc, char * argv[])
33 {
34  QApplication a(argc, argv);
35 
36  yarp::os::Network yarp;
37  if (!yarp.checkNetwork())
38  {
39  yError("ERROR: check Yarp network.");
40  return 0;
41  }
42 
43  yarp::os::ResourceFinder* rf = new ResourceFinder;
44  rf->configure(argc, argv);
45 
46  robot_interfaces *robot;
47  robot = new robot_interfaces();
48  std::string robot_name = "icub";
49 
50  if (rf->check("robot"))
51  {
52  robot_name=rf->find("robot").asString();
53  }
54 
55  if (robot->init(robot_name) == false)
56  {
57  /*
58  yError("Failed to connect to robot");
59  delete rf;
60  delete robot;
61  return 0;
62  */
63  }
64 
65  MainWindow w;
66  w.init("icub", rf, robot);
67  w.show();
68 
69  int appRet = a.exec();
70 
71  delete rf;
72  delete robot;
73 
74  return (appRet != 0 ? 1 : 0);
75 }
76 
77