d4c
d4c_client.h
1 /*
2  * Copyright (C) 2013 iCub Facility - Istituto Italiano di Tecnologia
3  * Authors: Ilaria Gori, Ugo Pattacini
4  * email: ilaria.gori@iit.it, 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  * 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 #ifndef __D4C_CLIENT_H__
19 #define __D4C_CLIENT_H__
20 
21 #include <string>
22 
23 #include <yarp/os/all.h>
24 #include <yarp/sig/all.h>
25 
26 #include <iCub/d4c/d4c.h>
27 
28 namespace iCub
29 {
30 
31 namespace d4c
32 {
33 
34 class D4CClient : public D4C
35 {
36 protected:
37  bool isOpen;
38  int verbosity;
39 
40  std::string remote;
41  std::string local;
42  std::string carrier;
43 
44  mutable yarp::sig::Vector field;
45  mutable yarp::sig::Vector xdot;
46  mutable yarp::sig::Vector x;
47  mutable yarp::sig::Vector xhat;
48  mutable yarp::sig::Vector qhat;
49 
50  mutable yarp::os::BufferedPort<yarp::os::Property> data;
51  yarp::os::RpcClient rpc;
52 
53  virtual void printMessage(const int logtype, const int level,
54  const char *format, ...) const;
55 
56 public:
57  D4CClient();
58  bool open(const yarp::os::Property &options);
59  void close();
60  bool addItem(const yarp::os::Property &options, int &item);
61  bool eraseItem(const int item);
62  bool clearItems();
63  bool getItems(yarp::os::Bottle &items);
64  bool setProperty(const int item, const yarp::os::Property &options);
65  bool getProperty(const int item, yarp::os::Property &options);
66  bool enableField();
67  bool disableField();
68  bool getFieldStatus(bool &status);
69  bool enableControl();
70  bool disableControl();
71  bool enableSimulation();
72  bool disableSimulation();
73  bool getSimulationStatus(bool &status);
74  bool getControlStatus(bool &status);
75  bool setPeriod(const int period);
76  bool getPeriod(int &period);
77  bool setPointStateToTool();
78  bool attachToolFrame(const yarp::sig::Vector &x, const yarp::sig::Vector &o);
79  bool getToolFrame(yarp::sig::Vector &x, yarp::sig::Vector &o);
80  bool removeToolFrame();
81  bool getTool(yarp::sig::Vector &x, yarp::sig::Vector &o);
82  bool setPointState(const yarp::sig::Vector &x, const yarp::sig::Vector &o,
83  const yarp::sig::Vector &xdot, const yarp::sig::Vector &odot);
84  bool setPointOrientation(const yarp::sig::Vector &o, const yarp::sig::Vector &odot);
85  bool getPointState(yarp::sig::Vector &x, yarp::sig::Vector &o,
86  yarp::sig::Vector &xdot, yarp::sig::Vector &odot);
87  bool getField(yarp::sig::Vector &field);
88  bool getSimulation(yarp::sig::Vector &xhat, yarp::sig::Vector &ohat,
89  yarp::sig::Vector &qhat);
90  bool getActiveIF(std::string &activeIF);
91  bool setActiveIF(const std::string &activeIF);
92  bool getTrajectory(std::deque<yarp::sig::Vector> &trajPos,
93  std::deque<yarp::sig::Vector> &trajOrien,
94  const unsigned int maxIterations=D4C_DEFAULT_MAXITERATIONS,
95  const double Ts=D4C_DEFAULT_TS_DISABLED);
96  bool executeTrajectory(const std::deque<yarp::sig::Vector> &trajPos,
97  const std::deque<yarp::sig::Vector> &trajOrien,
98  const double trajTime);
99  virtual ~D4CClient();
100 };
101 
102 }
103 
104 }
105 
106 #endif
107 
108 
Definition: d4c.h:43