hlrc / server / include / MiddlewareROS.h @ 84534fbf
History | View | Annotate | Download (3.111 KB)
1 |
/*
|
---|---|
2 |
* This file is part of hlrc_server
|
3 |
*
|
4 |
* Copyright(c) sschulz <AT> techfak.uni-bielefeld.de
|
5 |
* http://opensource.cit-ec.de/projects/hlrc_server
|
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 ROS_SUPPORT
|
32 |
#include "ros/ros.h" |
33 |
#include <actionlib/client/simple_action_client.h> |
34 |
#include <tf2_ros/transform_listener.h> |
35 |
|
36 |
// messages
|
37 |
#include "hlrc_server/phoneme.h" |
38 |
#include "hlrc_server/soundchunk.h" |
39 |
#include "hlrc_server/utterance.h" |
40 |
// actions
|
41 |
#include "hlrc_server/gazetargetAction.h" |
42 |
#include "hlrc_server/lookattargetAction.h" |
43 |
#include "hlrc_server/ttsAction.h" |
44 |
|
45 |
#include "ROS/GazeCallbackWrapperROS.h" |
46 |
#include "ROS/LookatCallbackWrapperROS.h" |
47 |
#include "ROS/MouthCallbackWrapperROS.h" |
48 |
#include "ROS/UtteranceCallbackWrapperROS.h" |
49 |
#include "ROS/EmotionCallbackWrapperROS.h" |
50 |
#include "ROS/AnimationCallbackWrapperROS.h" |
51 |
#include "ROS/SpeechCallbackWrapperROS.h" |
52 |
#endif
|
53 |
#include <memory> |
54 |
|
55 |
#define ROS_ACTION_CALL_TIMEOUT 30.0 |
56 |
|
57 |
class MiddlewareROS : public Middleware { |
58 |
#ifndef ROS_SUPPORT
|
59 |
public:
|
60 |
MiddlewareROS(Arbiter* a, std::string _base_scope) : Middleware(a, _base_scope) { |
61 |
printf("> ERROR: hlrc was compiled without ROS middleware support.");
|
62 |
exit(EXIT_FAILURE); |
63 |
} |
64 |
|
65 |
~MiddlewareROS() { |
66 |
} |
67 |
void init(){};
|
68 |
void tick(){};
|
69 |
|
70 |
std::shared_ptr<Utterance> tts_call(std::string text) { |
71 |
return std::shared_ptr<Utterance>(new Utterance());
|
72 |
} |
73 |
|
74 |
#else
|
75 |
public:
|
76 |
MiddlewareROS(Arbiter* a, std::string _base_scope); |
77 |
~MiddlewareROS(); |
78 |
void init();
|
79 |
void tick();
|
80 |
std::shared_ptr<Utterance> tts_call(std::string text); |
81 |
|
82 |
private:
|
83 |
// std::shared_ptr<ros::NodeHandle> node_handle;
|
84 |
ros::NodeHandle* ros_node_handle; |
85 |
bool tick_necessary;
|
86 |
// listen to tf tree
|
87 |
tf2_ros::Buffer tfBuffer; |
88 |
std::shared_ptr<tf2_ros::TransformListener> tfListener; |
89 |
|
90 |
// FIXME: These pointers are never destroyed. Shouldn't they be shared_ptrs?
|
91 |
AnimationCallbackWrapper* animation_action_server; |
92 |
UtteranceCallbackWrapper* utterance_action_server; |
93 |
EmotionCallbackWrapper* current_emotion_action_server; |
94 |
EmotionCallbackWrapper* default_emotion_action_server; |
95 |
GazeCallbackWrapper* gaze_action_server; |
96 |
LookatCallbackWrapper* lookat_action_server; |
97 |
MouthCallbackWrapper* mouth_action_server; |
98 |
SpeechCallbackWrapper* speech_action_server; |
99 |
actionlib::SimpleActionClient<hlrc_server::ttsAction>* tts_ac; |
100 |
#endif
|
101 |
}; |