iol
utils.h
1 /*
2  * Copyright (C) 2011 Department of Robotics Brain and Cognitive Sciences - Istituto Italiano di Tecnologia
3  * Author: 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  * 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 __UTILS_H__
19 #define __UTILS_H__
20 
21 #include <string>
22 
23 #include <yarp/os/all.h>
24 #include <yarp/sig/all.h>
25 
26 #include <opencv2/opencv.hpp>
27 
28 
29 using namespace std;
30 using namespace yarp::os;
31 using namespace yarp::sig;
32 
33 class Manager; // forward declaration
34 
35 /**********************************************************/
36 class Speaker : public Port
37 {
38 protected:
39  bool speaking;
40 
41 public:
42  Speaker() : speaking(true) { }
43  void setSpeaker(const bool speaking) { this->speaking=speaking; }
44  bool getSpeaker() const { return speaking; }
45  void speak(const string &phrase, const bool force=false);
46 };
47 
48 
49 /**********************************************************/
50 class PointedLocationPort : public BufferedPort<Bottle>
51 {
52 protected:
53  cv::Point loc;
54  double rxTime;
55  double timeout;
56 
57  void onRead(Bottle &b);
58 
59 public:
60  PointedLocationPort();
61  bool getLoc(cv::Point &loc);
62 };
63 
64 
65 /**********************************************************/
66 class StopCmdPort : public BufferedPort<Bottle>
67 {
68 protected:
69  Manager *manager;
70 
71  void onRead(Bottle &b);
72 
73 public:
74  StopCmdPort();
75  void setManager(Manager *manager);
76 };
77 
78 
79 /**********************************************************/
80 class Attention : public PeriodicThread
81 {
82 protected:
83  Manager *manager;
84 
85  bool threadInit();
86  void run();
87 
88 public:
89  Attention();
90  void suspend();
91  void setManager(Manager *manager);
92 };
93 
94 
95 /**********************************************************/
96 class RtLocalization : public PeriodicThread
97 {
98 protected:
99  Manager *manager;
100 
101  bool threadInit();
102  void run();
103 
104 public:
105  RtLocalization();
106  void setManager(Manager *manager);
107 };
108 
109 
110 /**********************************************************/
111 class Exploration : public PeriodicThread
112 {
113 protected:
114  Manager *manager;
115  string object;
116  Vector position;
117 
118  bool threadInit();
119  void run();
120 
121 public:
122  Exploration();
123  void setManager(Manager *manager);
124  void setInfo(const string &object, const Vector &position);
125 };
126 
127 
128 /**********************************************************/
129 class MemoryUpdater : public PeriodicThread
130 {
131 protected:
132  Manager *manager;
133 
134  bool threadInit();
135  void run();
136 
137 public:
138  MemoryUpdater();
139  void setManager(Manager *manager);
140 };
141 
142 
143 /**********************************************************/
144 class MemoryReporter : public PortReport
145 {
146  Manager *manager;
147 
148 public:
149  MemoryReporter();
150  void setManager(Manager *manager);
151  void report(const PortInfo &info);
152 };
153 
154 
155 #endif
156