icub-client
subSystem_KARMA.h
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 * website: http://wysiwyd.upf.edu/
6 * Permission is granted to copy, distribute, and/or modify this program
7 * under the terms of the GNU General Public License, version 2 or any
8 * later version published by the Free Software Foundation.
9 *
10 * A copy of the license can be found at
11 * icub-client/license/gpl.txt
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16 * Public License for more details
17 */
18 
19 #ifndef SUBSYSTEM_KARMA_H
20 #define SUBSYSTEM_KARMA_H
21 
22 #include <string>
23 #include <algorithm>
24 #include <yarp/os/all.h>
25 #include <yarp/sig/all.h>
26 #include <yarp/dev/all.h>
27 
30 
31 #define SUBSYSTEM_KARMA "KARMA"
32 
33 namespace icubclient {
43 class SubSystem_KARMA : public SubSystem
44 {
45 protected:
48 
49  std::string robot;
50  double tableHeight;
51  bool hasTable;
52 
53  yarp::os::RpcClient portStop;
54  yarp::os::RpcClient portVision;
55  yarp::os::RpcClient portFinder;
56  yarp::os::RpcClient portCalib;
57 
58  //testing Cartesian interface
59  yarp::dev::PolyDriver driverL;
60  yarp::dev::PolyDriver driverR;
61  yarp::dev::PolyDriver driverHL;
62  yarp::dev::PolyDriver driverHR;
63 
64  yarp::dev::ICartesianControl *iCartCtrlL;
65  yarp::dev::ICartesianControl *iCartCtrlR;
66 
70  void appendTarget(yarp::os::Bottle& b, const yarp::sig::VectorOf<double> &tCenter);
71 
75  void appendDouble(yarp::os::Bottle& b, const double &v);
76 
77  bool returnArmSafely(std::string armType);
78 
79  void selectHandCorrectTarget(yarp::os::Bottle& options, const std::string &targetName,
80  yarp::sig::VectorOf<double>& target,
81  const std::string handToUse="");
82 
88  bool sendCmd(yarp::os::Bottle &cmd);
89 
90  bool connect();
91 
92 public:
98  SubSystem_KARMA(const std::string &masterName, const std::string &robot);
99 
100  void Close();
101 
107  yarp::sig::VectorOf<double> applySafetyMargins(const yarp::sig::VectorOf<double>& in);
108 
113  bool chooseArm(const std::string &armType);
114 
118  void chooseArmAuto();
119 
130  bool pushAside(const std::string &objName,
131  const yarp::sig::VectorOf<double> &objCenter, const double &targetPosY,
132  const double &theta,
133  const std::string &armType = "selectable",
134  const yarp::os::Bottle &options = yarp::os::Bottle());
135 
145  bool pushFront(const std::string &objName,
146  const yarp::sig::VectorOf<double> &objCenter, const double &targetPosXFront,
147  const std::string &armType = "selectable",
148  const yarp::os::Bottle &options = yarp::os::Bottle());
149 
158  bool push(const yarp::sig::VectorOf<double> &targetCenter, const double theta, const double radius,
159  const yarp::os::Bottle &options = yarp::os::Bottle());
160 
170  bool pullBack(const std::string &objName,
171  const yarp::sig::VectorOf<double> &objCenter, const double &targetPosXBack,
172  const std::string &armType = "selectable",
173  const yarp::os::Bottle &options = yarp::os::Bottle());
183  bool draw(const yarp::sig::VectorOf<double> &targetCenter, const double theta,
184  const double radius, const double dist,
185  const yarp::os::Bottle &options = yarp::os::Bottle());
186 
197  bool vdraw(const std::string &objName,
198  const yarp::sig::VectorOf<double> &targetCenter, const double theta,
199  const double radius, const double dist,
200  const yarp::os::Bottle &options = yarp::os::Bottle());
201 
202  bool openCartesianClient();
203 
208 };
209 }
210 
211 #endif // SUBSYSTEM_KARMA_H
bool chooseArm(const std::string &armType)
chooseArm (toolAttach in KARMA): wrapper for tool-attach of KARMA, can be used to choose the arm for ...
bool sendCmd(yarp::os::Bottle &cmd)
Sends a command to KARMA&#39;s RPC port.
bool pullBack(const std::string &objName, const yarp::sig::VectorOf< double > &objCenter, const double &targetPosXBack, const std::string &armType="selectable", const yarp::os::Bottle &options=yarp::os::Bottle())
pullBack (KARMA): pull an object to a certain location along x-axis of robot RoF
SubSystem to deal with the actionsRenderingEngine module (a.k.a.
Definition: subSystem_ARE.h:41
yarp::dev::PolyDriver driverHR
yarp::dev::PolyDriver driverR
SubSystem to deal with the experimental affordance learning module (a.k.a.
bool vdraw(const std::string &objName, const yarp::sig::VectorOf< double > &targetCenter, const double theta, const double radius, const double dist, const yarp::os::Bottle &options=yarp::os::Bottle())
vdraw (KARMA): virtual draw action, along the positive direction of the x-axis (in robot FoR) ...
yarp::os::RpcClient portFinder
yarp::sig::VectorOf< double > applySafetyMargins(const yarp::sig::VectorOf< double > &in)
Applies safety margins, i.e.
void appendTarget(yarp::os::Bottle &b, const yarp::sig::VectorOf< double > &tCenter)
Appends a target vector t to the Bottle
bool draw(const yarp::sig::VectorOf< double > &targetCenter, const double theta, const double radius, const double dist, const yarp::os::Bottle &options=yarp::os::Bottle())
draw (KARMA): draw action, along the positive direction of the x-axis (in robot FoR) ...
yarp::dev::PolyDriver driverHL
Abstract class to handle sub-systems of the icub-client.
Definition: subSystem.h:43
yarp::dev::PolyDriver driverL
SubSystem_KARMA(const std::string &masterName, const std::string &robot)
Default constructor.
bool returnArmSafely(std::string armType)
yarp::os::RpcClient portCalib
void selectHandCorrectTarget(yarp::os::Bottle &options, const std::string &targetName, yarp::sig::VectorOf< double > &target, const std::string handToUse="")
void chooseArmAuto()
chooseArmAuto (toolRemove in KARMA): wrapper for tool-remove of Karma, use to clear the arm choise ...
yarp::os::RpcClient portStop
void appendDouble(yarp::os::Bottle &b, const double &v)
Appends a double value v to the Bottle
bool pushFront(const std::string &objName, const yarp::sig::VectorOf< double > &objCenter, const double &targetPosXFront, const std::string &armType="selectable", const yarp::os::Bottle &options=yarp::os::Bottle())
pushFront (KARMA): push an object to a certain location along x-axis of robot RoF ...
bool push(const yarp::sig::VectorOf< double > &targetCenter, const double theta, const double radius, const yarp::os::Bottle &options=yarp::os::Bottle())
push (KARMA): push to certain position, along a defined direction
yarp::os::RpcClient portVision
bool pushAside(const std::string &objName, const yarp::sig::VectorOf< double > &objCenter, const double &targetPosY, const double &theta, const std::string &armType="selectable", const yarp::os::Bottle &options=yarp::os::Bottle())
pushAside (KARMA): push an object to a certain location along y-axis of robot RoF ...
void Close()
Clean up resources.
yarp::dev::ICartesianControl * iCartCtrlL
yarp::dev::ICartesianControl * iCartCtrlR