icub-client
main.cpp
Go to the documentation of this file.
1 /*
2 * Copyright(C) 2014 WYSIWYD Consortium, European Commission FP7 Project ICT - 612139
3 * Authors: Nguyen Dong Hai Phuong
4 * email : phuong.nguyen@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 <iostream>
19 #include <iomanip>
20 #include <yarp/os/all.h>
21 #include <yarp/sig/all.h>
22 #include <yarp/math/Math.h>
23 #include <yarp/math/SVD.h>
25 
26 using namespace std;
27 using namespace yarp::os;
28 using namespace yarp::sig;
29 using namespace yarp::math;
30 using namespace icubclient;
31 
32 int main()
33 {
34  Network yarp;
35  if (!yarp.checkNetwork())
36  {
37  yError()<<"[KARMAiCubClientExample] YARP network seems unavailable!";
38  return -1;
39  }
40 
41  ICubClient iCub("KARMAiCubClientExample","icubClient","example_ARE_KARMA.ini");
42 
43  // we connect to ARE and KARMA, which is defined in "example_ARE_KARMA.ini"
44  if (!iCub.connectSubSystems())
45  {
46  yError()<<"[KARMAiCubClientExample] KARMA seems unavailabe!";
47  return -1;
48  }
49 
50  // object location in the iCub frame
51  Vector x(3);
52  x[0]=-0.30;
53  x[1]=0.05;
54  x[2]=-0.05;
55 
56  // push left with pure API of KARMA. Please see KARMA document for details of how to define arguments
57  iCub.home(); // Home by using ARE
58  x[1] =x[1] - 0.1;
59  yInfo()<<"[KARMAiCubClientExample] try to push left with KARMA...";
60  bool ok = iCub.pushKarma(x,180,0.2); // Object will be push to left with y-coordinate as -0.05 from -0.25
61  yInfo()<<(ok?"success":"failed");
62  Time::delay(4.0);
63 
64  // push right with pure API of KARMA. Please see KARMA document for details of how to define arguments
65  iCub.home(); // Home by using ARE
66  yInfo()<<"[KARMAiCubClientExample] try to push right with KARMA...";
67  ok = iCub.pushKarma(x,0,0.2); // Object will be push to right with y-coordinate as -0.05 from 0.15
68  yInfo()<<(ok?"success":"failed");
69  Time::delay(4.0);
70 
71  // push front with pure API of KARMA. Please see KARMA document for details of how to define arguments
72  iCub.home(); // Home by using ARE
73  x[0] = x[0] - 0.15;
74  yInfo()<<"[KARMAiCubClientExample] try to push front with KARMA...";
75  ok = iCub.pushKarma(x,-90,0.2); // Object will be push to front with x-coordinate as -0.45 from -0.25
76  yInfo()<<(ok?"success":"failed");
77  Time::delay(4.0);
78 
79  // pull back with pure API of KARMA. Please see KARMA document for details of how to define arguments
80  iCub.home(); // Home by using ARE
81  x[0] = -0.45;
82  x[1] = 0.1;
83  x[2] = -0.05;
84  yInfo()<<"[KARMAiCubClientExample] try to pull with KARMA...";
85  ok = iCub.drawKarma(x,0,0,0.2); // Object will be pull back 0.2m with x-coordinate from -0.45
86  yInfo()<<(ok?"success":"failed");
87  Time::delay(4.0);
88 
89  yInfo()<<"[KARMAiCubClientExample] shutting down ... ";
90  iCub.close();
91  return 0;
92 }
Grants access to high level motor commands (grasp, touch, look, goto, etc) of the robot as well as it...
Definition: icubClient.h:66
STL namespace.
bool connectSubSystems()
Try to connect to all sub-systems.
Definition: icubClient.cpp:117
bool home(const std::string &part="all")
Go in home position.
bool pushKarma(const yarp::sig::VectorOf< double > &targetCenter, const double &theta, const double &radius, const yarp::os::Bottle &options=yarp::os::Bottle())
pushKarma (KARMA): push to certain position, along a direction See the SubSystem_KARMA::push document...
int main()
Definition: main.cpp:32
void close()
Properly closes all ports which were opened.
Definition: icubClient.cpp:140
bool drawKarma(const yarp::sig::VectorOf< double > &targetCenter, const double &theta, const double &radius, const double &dist, const yarp::os::Bottle &options=yarp::os::Bottle())
drawKarma (KARMA): draw action, along the positive direction of the x-axis (in robot FoR) See the Sub...