Statistics
| Branch: | Tag: | Revision:

hlrc / client / cpp / include / MiddlewareRSB.h @ 482adb6d

History | View | Annotate | Download (3.409 KB)

1 0c286af0 Simon Schulz
/*
2 f150aab5 Robert Haschke
 * 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 0c286af0 Simon Schulz
29
#pragma once
30
#include "Middleware.h"
31
#ifdef RSB_SUPPORT
32 f150aab5 Robert Haschke
#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 0c286af0 Simon Schulz
37 f150aab5 Robert Haschke
#if USE_INPROTK_SYNTHESIS
38
#include <rst/communicationpatterns/TaskState.pb.h>
39
#endif
40 0c286af0 Simon Schulz
#endif
41
42 f150aab5 Robert Haschke
class MiddlewareRSB : public Middleware {
43 0c286af0 Simon Schulz
#ifndef RSB_SUPPORT
44
public:
45 f150aab5 Robert Haschke
        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 dff2f3b4 Simon Schulz
50 f150aab5 Robert Haschke
        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 dff2f3b4 Simon Schulz
59 0c286af0 Simon Schulz
#else
60
public:
61 f150aab5 Robert Haschke
        MiddlewareRSB(std::string scope);
62 0c286af0 Simon Schulz
63
protected:
64 f150aab5 Robert Haschke
        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 0c286af0 Simon Schulz
73
private:
74 f150aab5 Robert Haschke
        void publish_emotion(std::string scope_target, RobotEmotion e, bool blocking);
75 0c286af0 Simon Schulz
76 f150aab5 Robert Haschke
        // rsb::patterns::RemoteServerPtr inprotk_server;
77
        rsb::patterns::RemoteServerPtr hlrc_server;
78
        // rsb::patterns::LocalServerPtr inprotk_server;
79 0c286af0 Simon Schulz
#if USE_INPROTK_SYNTHESIS
80 f150aab5 Robert Haschke
        rsb::Informer<rst::communicationpatterns::TaskState>::Ptr inprotk_informer;
81
        rsb::ListenerPtr inprotk_listener;
82
        rsb::ListenerPtr hack_listener;
83 0c286af0 Simon Schulz
84 42084118 Robert Haschke
        std::mutex pending_tasks_mutex;
85 482adb6d Robert Haschke
        std::vector<std::shared_ptr<rst::communicationpatterns::TaskState> > pending_tasks;
86 f150aab5 Robert Haschke
        unsigned int say_task_active;
87
        unsigned int say_task_done;
88 0c286af0 Simon Schulz
89 42084118 Robert Haschke
        std::mutex current_saytask_mutex;
90 f150aab5 Robert Haschke
        std::string current_saytask;
91
        std::string get_current_saytask();
92
        void set_current_saytask(std::string text);
93 0c286af0 Simon Schulz
94 f150aab5 Robert Haschke
        void check_for_inprotk();
95 482adb6d Robert Haschke
        void incoming_hack(std::shared_ptr<std::string> finished_task);
96 0c286af0 Simon Schulz
#endif
97
#endif
98
};