Statistics
| Branch: | Tag: | Revision:

hlrc / server / include / MiddlewareROS.h @ ebcb799f

History | View | Annotate | Download (3.15 KB)

1 0c286af0 Simon Schulz
/*
2 f150aab5 Robert Haschke
 * 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 0c286af0 Simon Schulz
29
#pragma once
30
#include "Middleware.h"
31
#ifdef ROS_SUPPORT
32 f150aab5 Robert Haschke
#include "ros/ros.h"
33
#include <actionlib/client/simple_action_client.h>
34
#include <tf2_ros/transform_listener.h>
35 0c15613f Simon Schulz
36 f150aab5 Robert Haschke
// 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 0c286af0 Simon Schulz
45 f150aab5 Robert Haschke
#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 0c286af0 Simon Schulz
#endif
53 482adb6d Robert Haschke
#include <memory>
54 0c286af0 Simon Schulz
55 0c15613f Simon Schulz
#define ROS_ACTION_CALL_TIMEOUT 30.0
56 0c286af0 Simon Schulz
57 f150aab5 Robert Haschke
class MiddlewareROS : public Middleware {
58 0c286af0 Simon Schulz
#ifndef ROS_SUPPORT
59
public:
60 f150aab5 Robert Haschke
        MiddlewareROS(Arbiter* a, std::string _base_scope) : Middleware(a, _base_scope) {
61
                printf("> ERROR: hlrc was compiled without ROS middleware support. Please use MiddlewareRSB() instead!\n\n");
62
                exit(EXIT_FAILURE);
63
        }
64 0c286af0 Simon Schulz
65 f150aab5 Robert Haschke
        ~MiddlewareROS() {
66
        }
67
        void init(){};
68
        void tick(){};
69 0c286af0 Simon Schulz
70 482adb6d Robert Haschke
        std::shared_ptr<Utterance> tts_call(std::string text) {
71
                return std::shared_ptr<Utterance>(new Utterance());
72 f150aab5 Robert Haschke
        }
73 0c286af0 Simon Schulz
74
#else
75
public:
76 f150aab5 Robert Haschke
        MiddlewareROS(Arbiter* a, std::string _base_scope);
77
        ~MiddlewareROS();
78
        void init();
79
        void tick();
80 482adb6d Robert Haschke
        std::shared_ptr<Utterance> tts_call(std::string text);
81 0c286af0 Simon Schulz
82
private:
83 482adb6d Robert Haschke
        // std::shared_ptr<ros::NodeHandle> node_handle;
84 f150aab5 Robert Haschke
        ros::NodeHandle* ros_node_handle;
85
        bool tick_necessary;
86
        // listen to tf tree
87
        tf2_ros::Buffer tfBuffer;
88 482adb6d Robert Haschke
        std::shared_ptr<tf2_ros::TransformListener> tfListener;
89 2cf3c285 Robert Haschke
90 f150aab5 Robert Haschke
        // 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 0c286af0 Simon Schulz
#endif
101
};