Revision f150aab5 client/cpp/include/MiddlewareRSB.h

View differences:

client/cpp/include/MiddlewareRSB.h
1 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
*/
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 28

  
29 29
#pragma once
30 30
#include "Middleware.h"
31 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>
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 36

  
37
    #if USE_INPROTK_SYNTHESIS
38
    #include <rst/communicationpatterns/TaskState.pb.h>
39
    #endif
37
#if USE_INPROTK_SYNTHESIS
38
#include <rst/communicationpatterns/TaskState.pb.h>
39
#endif
40 40
#endif
41 41

  
42
class MiddlewareRSB : public Middleware{
42
class MiddlewareRSB : public Middleware {
43 43
#ifndef RSB_SUPPORT
44 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) {};
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
	}
59 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){};
60 58

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

  
61
	MiddlewareRSB(std::string scope);
65 62

  
66 63
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);
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);
76 72

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

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

  
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;
84
	boost::mutex pending_tasks_mutex;
85
	std::vector<boost::shared_ptr<rst::communicationpatterns::TaskState> > pending_tasks;
86
	unsigned int say_task_active;
87
	unsigned int say_task_done;
92 88

  
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);
89
	boost::mutex current_saytask_mutex;
90
	std::string current_saytask;
91
	std::string get_current_saytask();
92
	void set_current_saytask(std::string text);
97 93

  
98
    void check_for_inprotk();
99
    void incoming_hack(boost::shared_ptr<std::string> finished_task);
94
	void check_for_inprotk();
95
	void incoming_hack(boost::shared_ptr<std::string> finished_task);
100 96
#endif
101 97
#endif
102 98
};
103

  

Also available in: Unified diff