Statistics
| Branch: | Tag: | Revision:

hlrc / client / cpp / include / MiddlewareRSB.h @ 836f314c

History | View | Annotate | Download (3.409 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, bool blocking, float roll){};
55
        void publish_mouth_target(RobotMouth m, bool blocking){};
56
        void publish_head_animation(RobotHeadAnimation a, bool blocking){};
57
        void publish_speech(std::string text, bool blocking){};
58

    
59
#else
60
public:
61
        MiddlewareRSB(std::string scope);
62

    
63
protected:
64
        void init();
65
        void publish_current_emotion(RobotEmotion e, bool blocking);
66
        void publish_default_emotion(RobotEmotion e, bool blocking);
67
        void publish_gaze_target(RobotGaze target, bool blocking);
68
        void publish_lookat_target(float x, float y, float z, const std::string frame_id, bool blocking, float roll);
69
        void publish_mouth_target(RobotMouth target, bool blocking);
70
        void publish_head_animation(RobotHeadAnimation a, bool blocking);
71
        void publish_speech(std::string text, bool blocking);
72

    
73
private:
74
        void publish_emotion(std::string scope_target, RobotEmotion e, bool blocking);
75

    
76
        // rsb::patterns::RemoteServerPtr inprotk_server;
77
        rsb::patterns::RemoteServerPtr hlrc_server;
78
        // rsb::patterns::LocalServerPtr inprotk_server;
79
#if USE_INPROTK_SYNTHESIS
80
        rsb::Informer<rst::communicationpatterns::TaskState>::Ptr inprotk_informer;
81
        rsb::ListenerPtr inprotk_listener;
82
        rsb::ListenerPtr hack_listener;
83

    
84
        std::mutex pending_tasks_mutex;
85
        std::vector<std::shared_ptr<rst::communicationpatterns::TaskState> > pending_tasks;
86
        unsigned int say_task_active;
87
        unsigned int say_task_done;
88

    
89
        std::mutex current_saytask_mutex;
90
        std::string current_saytask;
91
        std::string get_current_saytask();
92
        void set_current_saytask(std::string text);
93

    
94
        void check_for_inprotk();
95
        void incoming_hack(std::shared_ptr<std::string> finished_task);
96
#endif
97
#endif
98
};