Statistics
| Branch: | Tag: | Revision:

hlrc / client / cpp / include / MiddlewareRSB.h @ 00c26660

History | View | Annotate | Download (2.89 KB)

1 0c286af0 Simon Schulz
/*
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){
46
        printf("> ERROR: hlrc was compiled without RSB middleware support. Please use MiddlewareROS() instead!\n\n");
47
        exit(EXIT_FAILURE);
48
    }
49
50
#else
51
public:
52
    MiddlewareRSB(std::string scope);
53
54
55
protected:
56
    void init();
57
    void publish_current_emotion(RobotEmotion e, bool blocking);
58
    void publish_default_emotion(RobotEmotion e, bool blocking);
59
    void publish_gaze_target(RobotGaze target, bool blocking);
60
    void publish_mouth_target(RobotMouth target, bool blocking);
61
    void publish_head_animation(RobotHeadAnimation a, bool blocking);
62
    void publish_speech(std::string text, bool blocking);
63
64
private:
65
    void publish_emotion(std::string scope_target, RobotEmotion e, bool blocking);
66
67
    //rsb::patterns::RemoteServerPtr inprotk_server;
68
    rsb::patterns::RemoteServerPtr hlrc_server;
69
    //rsb::patterns::LocalServerPtr inprotk_server;
70
#if USE_INPROTK_SYNTHESIS
71
    rsb::Informer<rst::communicationpatterns::TaskState>::Ptr inprotk_informer;
72
    rsb::ListenerPtr inprotk_listener;
73
    rsb::ListenerPtr hack_listener;
74
75
    boost::mutex pending_tasks_mutex;
76
    std::vector<boost::shared_ptr<rst::communicationpatterns::TaskState>> pending_tasks;
77
    unsigned int say_task_active;
78
    unsigned int say_task_done;
79
80
    boost::mutex current_saytask_mutex;
81
    std::string current_saytask;
82
    std::string get_current_saytask();
83
    void set_current_saytask(std::string text);
84
85
    void check_for_inprotk();
86
    void incoming_hack(boost::shared_ptr<std::string> finished_task);
87
#endif
88
#endif
89
};