hlrc / client / cpp / include / MiddlewareRSB.h @ f0dcf4ca
History | View | Annotate | Download (3.596 KB)
1 |
/*
|
---|---|
2 |
* This file is part of hlrc
|
3 |
*
|
4 |
* Copyright(c) sschulz <AT> techfak.uni-bielefeld.de
|
5 |
* http://opensource.cit-ec.de/projects/hlrc
|
6 |
*
|
7 |
* This file may be licensed under the terms of the
|
8 |
* GNU General Public License Version 3 (the ``GPL''),
|
9 |
* or (at your option) any later version.
|
10 |
*
|
11 |
* Software distributed under the License is distributed
|
12 |
* on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
|
13 |
* express or implied. See the GPL for the specific language
|
14 |
* governing rights and limitations.
|
15 |
*
|
16 |
* You should have received a copy of the GPL along with this
|
17 |
* program. If not, go to http://www.gnu.org/licenses/gpl.html
|
18 |
* or write to the Free Software Foundation, Inc.,
|
19 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20 |
*
|
21 |
* The development of this software was supported by the
|
22 |
* Excellence Cluster EXC 277 Cognitive Interaction Technology.
|
23 |
* The Excellence Cluster EXC 277 is a grant of the Deutsche
|
24 |
* Forschungsgemeinschaft (DFG) in the context of the German
|
25 |
* Excellence Initiative.
|
26 |
*
|
27 |
*/
|
28 |
|
29 |
#pragma once
|
30 |
#include "Middleware.h" |
31 |
#ifdef RSB_SUPPORT
|
32 |
#define BOOST_SIGNALS_NO_DEPRECATION_WARNING //mute warnings from RSB |
33 |
#include <rsb/Factory.h> |
34 |
#include <rsb/Informer.h> |
35 |
#include <rsb/Listener.h> |
36 |
|
37 |
#if USE_INPROTK_SYNTHESIS
|
38 |
#include <rst/communicationpatterns/TaskState.pb.h> |
39 |
#endif
|
40 |
#endif
|
41 |
|
42 |
class MiddlewareRSB : public Middleware{ |
43 |
#ifndef RSB_SUPPORT
|
44 |
public:
|
45 |
MiddlewareRSB(std::string scope) : Middleware(scope){ |
46 |
printf("> ERROR: hlrc was compiled without RSB middleware support. Please use MiddlewareROS() instead!\n\n");
|
47 |
exit(EXIT_FAILURE); |
48 |
} |
49 |
|
50 |
void init(){};
|
51 |
void publish_default_emotion(RobotEmotion e, bool blocking){}; |
52 |
void publish_current_emotion(RobotEmotion e, bool blocking){}; |
53 |
void publish_gaze_target(RobotGaze g, bool blocking){}; |
54 |
void publish_lookat_target(float x, float y, float z, const std::string frame_id, |
55 |
bool blocking, float roll){}; |
56 |
void publish_mouth_target(RobotMouth m, bool blocking){}; |
57 |
void publish_head_animation(RobotHeadAnimation a, bool blocking) {}; |
58 |
void publish_speech(std::string text, bool blocking) {}; |
59 |
|
60 |
|
61 |
#else
|
62 |
public:
|
63 |
MiddlewareRSB(std::string scope); |
64 |
|
65 |
|
66 |
protected:
|
67 |
void init();
|
68 |
void publish_current_emotion(RobotEmotion e, bool blocking); |
69 |
void publish_default_emotion(RobotEmotion e, bool blocking); |
70 |
void publish_gaze_target(RobotGaze target, bool blocking); |
71 |
void publish_lookat_target(float x, float y, float z, const std::string frame_id, |
72 |
bool blocking, float roll); |
73 |
void publish_mouth_target(RobotMouth target, bool blocking); |
74 |
void publish_head_animation(RobotHeadAnimation a, bool blocking); |
75 |
void publish_speech(std::string text, bool blocking); |
76 |
|
77 |
private:
|
78 |
void publish_emotion(std::string scope_target, RobotEmotion e, bool blocking); |
79 |
|
80 |
//rsb::patterns::RemoteServerPtr inprotk_server;
|
81 |
rsb::patterns::RemoteServerPtr hlrc_server; |
82 |
//rsb::patterns::LocalServerPtr inprotk_server;
|
83 |
#if USE_INPROTK_SYNTHESIS
|
84 |
rsb::Informer<rst::communicationpatterns::TaskState>::Ptr inprotk_informer; |
85 |
rsb::ListenerPtr inprotk_listener; |
86 |
rsb::ListenerPtr hack_listener; |
87 |
|
88 |
boost::mutex pending_tasks_mutex; |
89 |
std::vector<boost::shared_ptr<rst::communicationpatterns::TaskState>> pending_tasks; |
90 |
unsigned int say_task_active; |
91 |
unsigned int say_task_done; |
92 |
|
93 |
boost::mutex current_saytask_mutex; |
94 |
std::string current_saytask; |
95 |
std::string get_current_saytask(); |
96 |
void set_current_saytask(std::string text);
|
97 |
|
98 |
void check_for_inprotk();
|
99 |
void incoming_hack(boost::shared_ptr<std::string> finished_task);
|
100 |
#endif
|
101 |
#endif
|
102 |
}; |
103 |
|