Statistics
| Branch: | Tag: | Revision:

hlrc / server / include / Arbiter.h @ e34ce888

History | View | Annotate | Download (3.104 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 <string>
31 90fa4b4e Robert Haschke
#include <vector>
32 482adb6d Robert Haschke
#include <memory>
33 42084118 Robert Haschke
#include <mutex>
34 0c286af0 Simon Schulz
#include <humotion/client/client.h>
35
#include "EmotionState.h"
36
#include "EmotionConfig.h"
37
#include "MouthConfig.h"
38
#include "Utterance.h"
39
#include "AudioPlayer.h"
40
#include "Animation.h"
41
42 f150aab5 Robert Haschke
class Arbiter {
43 0c286af0 Simon Schulz
public:
44 f150aab5 Robert Haschke
        Arbiter(std::string audio_output);
45
        ~Arbiter();
46 0c286af0 Simon Schulz
47 f150aab5 Robert Haschke
        void arbitrate();
48 0c286af0 Simon Schulz
49 f150aab5 Robert Haschke
        void set_default_emotion(EmotionState e);
50
        void set_current_emotion(EmotionState e);
51
        void set_mouth_config(MouthConfig m);
52 482adb6d Robert Haschke
        void speak(std::shared_ptr<Utterance> u);
53 f150aab5 Robert Haschke
        bool speak_active();
54 0c286af0 Simon Schulz
55 f150aab5 Robert Haschke
        void set_gaze_target(humotion::GazeState g);
56
        void set_mouth_target(humotion::MouthState target);
57 482adb6d Robert Haschke
        void play_animation(std::shared_ptr<Animation> ani);
58 0c286af0 Simon Schulz
59 f150aab5 Robert Haschke
        humotion::GazeState get_gaze_state();
60
        humotion::MouthState get_mouth_state();
61 0c286af0 Simon Schulz
62
private:
63 f150aab5 Robert Haschke
        void override_by_emotion();
64
        void override_by_gaze();
65
        void override_by_animation();
66
        void override_by_utterance();
67
        void override_by_mouth();
68 0c286af0 Simon Schulz
69 f150aab5 Robert Haschke
        humotion::GazeState soft_overblend_gaze(humotion::GazeState gaze_now, humotion::GazeState gaze_target,
70
                                                unsigned int overblend_time);
71 efbcb710 sschulz
72 f150aab5 Robert Haschke
        EmotionConfig emotion_config_current;
73
        EmotionConfig emotion_config_default;
74 0c286af0 Simon Schulz
75 f150aab5 Robert Haschke
        humotion::MouthState mouth_state;
76
        humotion::GazeState gaze_state;
77 0c286af0 Simon Schulz
78 90fa4b4e Robert Haschke
        std::chrono::time_point<std::chrono::steady_clock> gaze_state_end_time;
79 f150aab5 Robert Haschke
        humotion::GazeState gaze_state_old;
80
        bool gaze_state_animation_restart;
81 efbcb710 sschulz
82 f150aab5 Robert Haschke
        EmotionConfig* emotion_target;
83 efbcb710 sschulz
84 f150aab5 Robert Haschke
        MouthConfig mouth_config;
85 efbcb710 sschulz
86 482adb6d Robert Haschke
        std::shared_ptr<Utterance> utterance;
87 0c286af0 Simon Schulz
88 f150aab5 Robert Haschke
        humotion::GazeState requested_gaze_state;
89
        humotion::MouthState requested_mouth_state;
90 0c286af0 Simon Schulz
91 42084118 Robert Haschke
        std::mutex emotion_config_default_mutex;
92
        std::mutex emotion_config_current_mutex;
93
        std::mutex mouth_config_override_mutex;
94
        std::mutex utterance_mutex;
95
        std::mutex requested_gaze_state_mutex;
96
        std::mutex requested_mouth_state_mutex;
97
        std::mutex audio_player_mutex;
98 0c286af0 Simon Schulz
99 42084118 Robert Haschke
        std::mutex animation_mutex;
100 f150aab5 Robert Haschke
        Animation active_animation;
101 0c286af0 Simon Schulz
102 482adb6d Robert Haschke
        typedef std::vector<std::shared_ptr<Animation>> active_animation_vector_t;
103 42084118 Robert Haschke
        std::mutex active_animation_vector_mutex;
104 f150aab5 Robert Haschke
        active_animation_vector_t active_animation_vector;
105 0c286af0 Simon Schulz
106 f150aab5 Robert Haschke
        AudioPlayer* audio_player;
107 0c286af0 Simon Schulz
};