Statistics
| Branch: | Tag: | Revision:

hlrc / server / src / EmotionConfig.cpp @ 84534fbf

History | View | Annotate | Download (7.915 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
#include "EmotionConfig.h"
30

    
31
EmotionConfig::EmotionConfig() {
32
        end_time = std::chrono::time_point<std::chrono::steady_clock>::max();
33
        select_config(NEUTRAL);
34
}
35

    
36
EmotionConfig::EmotionConfig(EmotionType e) {
37
        select_config(e);
38
}
39

    
40
EmotionConfig::~EmotionConfig() {
41
}
42

    
43
bool EmotionConfig::is_active() {
44
        if (std::chrono::steady_clock::now() >= end_time) {
45
                return false;
46
        }
47

    
48
        return true;
49
}
50

    
51
void EmotionConfig::set_duration(unsigned long ms) {
52
        // set a timeout:
53
        end_time = std::chrono::steady_clock::now() + std::chrono::milliseconds(ms);
54
}
55

    
56
void EmotionConfig::select_config(EmotionType e) {
57
        // default overblend time
58
        overblend_time_ms = 500;
59

    
60
        switch ((int)e) {
61
                default:
62
                case (NEUTRAL):
63
                        init_neutral();
64
                        break;
65
                case (HAPPY):
66
                        init_happy();
67
                        break;
68
                case (SAD):
69
                        init_sad();
70
                        break;
71
                case (ANGRY):
72
                        init_angry();
73
                        break;
74
                case (SURPRISED):
75
                        init_surprised();
76
                        break;
77
                case (FEAR):
78
                        init_fear();
79
                        break;
80
        }
81
}
82

    
83
void EmotionConfig::init_neutral() {
84
        // neutral = look straight
85
        gaze_override.pan_offset = 0.0;
86
        gaze_override.tilt_offset = 0.0;
87
        gaze_override.roll_offset = 0.0;
88
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; // GAZETYPE_OVERRIDE;
89

    
90
        // not setable right now
91
        gaze_override.vergence = 0.0;
92

    
93
        gaze_override.eyelid_opening_upper = 25.0;
94
        gaze_override.eyelid_opening_lower = 30.0;
95

    
96
        // eyebrow angles
97
        gaze_override.eyebrow_left = -3.0;
98
        gaze_override.eyebrow_right = 3.0;
99

    
100
        // eyeblink request
101
        gaze_override.eyeblink_request_left = 0;
102
        gaze_override.eyeblink_request_right = 0;
103

    
104
        // mouth:
105
        /*mouth_override.position_left   = 14.7;
106
        mouth_override.opening_left    = 0.0;
107
        mouth_override.position_center = 16.0;
108
        mouth_override.opening_center  = 1.0;
109
        mouth_override.position_right  = 14.7;
110
        mouth_override.opening_right   = 0.0;*/
111
        /*mouth_override.position_left   = 11.54200000000000000000;
112
        mouth_override.opening_left    = 0; //2.412000;
113
        mouth_override.position_center = 12.50000000000000000;
114
        mouth_override.opening_center  = 0; //1.737000;
115
        mouth_override.position_right  = 11.5250000000000000000;
116
        mouth_override.opening_right   = 0;//2.412000;
117
        */
118

    
119
        mouth_override.position_left = 19;
120
        mouth_override.opening_left = 0.0;
121
        mouth_override.position_center = 20;
122
        mouth_override.opening_center = 3.0;
123
        mouth_override.position_right = 19 - 2;
124
        mouth_override.opening_right = 0.0;
125
}
126

    
127
void EmotionConfig::init_happy() {
128
        // neutral = look straight
129
        gaze_override.pan_offset = 0.0;
130
        gaze_override.tilt_offset = 0.0;
131
        gaze_override.roll_offset = 0.0;
132
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; // GAZETYPE_OVERRIDE;
133

    
134
        // not setable right now
135
        gaze_override.vergence = 0.0;
136

    
137
        gaze_override.eyelid_opening_upper = 30.0;
138
        gaze_override.eyelid_opening_lower = 30.0;
139

    
140
        // eyebrow angles
141
        gaze_override.eyebrow_left = -1.0;
142
        gaze_override.eyebrow_right = 1.0;
143

    
144
        // eyeblink request
145
        gaze_override.eyeblink_request_left = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
146
        gaze_override.eyeblink_request_right = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
147
        /*
148
            mouth_override.position_left   = -1+9.5;
149
            mouth_override.opening_left    = 0.0;
150
            mouth_override.position_center = 24.3;
151
            mouth_override.opening_center  = 7.0;
152
            mouth_override.position_right  = -1+10.5;
153
            mouth_override.opening_right   = 0.0;*/
154

    
155
        mouth_override.position_left = 18;   // 13.56850000000000000000;
156
        mouth_override.opening_left = 0;     //.791000;
157
        mouth_override.position_center = 26; // 14.18400000000000000000;
158
        mouth_override.opening_center = 5;
159
        mouth_override.position_right = 18; // 15.31800000000000000000;
160
        mouth_override.opening_right = 0;   // 2.791000;
161
}
162

    
163
void EmotionConfig::init_sad() {
164
        gaze_override.pan_offset = 0.0;
165
        gaze_override.tilt_offset = -3.0;
166
        gaze_override.roll_offset = -3.0;
167
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; // GAZETYPE_OVERRIDE;
168

    
169
        // not setable right now
170
        gaze_override.vergence = 0.0;
171

    
172
        gaze_override.eyelid_opening_upper = 15.0;
173
        gaze_override.eyelid_opening_lower = 40.0;
174

    
175
        // eyebrow angles
176
        gaze_override.eyebrow_left = -20.0;
177
        gaze_override.eyebrow_right = 20.0;
178

    
179
        // eyeblink request
180
        gaze_override.eyeblink_request_left = 3 * humotion::GazeState::EYEBLINK_TIME_DEFAULT;
181
        gaze_override.eyeblink_request_right = 3 * humotion::GazeState::EYEBLINK_TIME_DEFAULT;
182

    
183
        // mouth:
184
        mouth_override.position_left = 21.0;
185
        mouth_override.opening_left = 0.0;
186
        mouth_override.position_center = 16.0;
187
        mouth_override.opening_center = 0.0;
188
        mouth_override.position_right = 21.0;
189
        mouth_override.opening_right = 0.0;
190
}
191

    
192
void EmotionConfig::init_angry() {
193
        gaze_override.pan_offset = 0.0;
194
        gaze_override.tilt_offset = -5.0;
195
        gaze_override.roll_offset = 0.0;
196
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; // GAZETYPE_OVERRIDE;
197

    
198
        // not setable right now
199
        gaze_override.vergence = 0.0;
200

    
201
        gaze_override.eyelid_opening_upper = 18.0;
202
        gaze_override.eyelid_opening_lower = 18.0;
203

    
204
        // eyebrow angles
205
        gaze_override.eyebrow_left = 21.0;
206
        gaze_override.eyebrow_right = -21.0;
207

    
208
        // eyeblink request
209
        gaze_override.eyeblink_request_left = 0;
210
        gaze_override.eyeblink_request_right = 0;
211

    
212
        // mouth:
213
        mouth_override.position_left = 21;
214
        mouth_override.opening_left = 6.0;
215
        mouth_override.position_center = 22.3;
216
        mouth_override.opening_center = 0.0;
217
        mouth_override.position_right = 21;
218
        mouth_override.opening_right = 6.0;
219
}
220

    
221
void EmotionConfig::init_surprised() {
222
        gaze_override.pan_offset = 0.0;
223
        gaze_override.tilt_offset = 8.0;
224
        gaze_override.roll_offset = 0.0;
225
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; // GAZETYPE_OVERRIDE;
226

    
227
        // not setable right now
228
        gaze_override.vergence = 0.0;
229

    
230
        // eyelids
231
        gaze_override.eyelid_opening_upper = 60.0;
232
        gaze_override.eyelid_opening_lower = 60.0;
233

    
234
        // eyebrow angles
235
        gaze_override.eyebrow_left = -2.0;
236
        gaze_override.eyebrow_right = 2.0;
237

    
238
        // eyeblink request
239
        gaze_override.eyeblink_request_left = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
240
        gaze_override.eyeblink_request_right = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
241

    
242
        // mouth:
243
        mouth_override.position_left = 22;
244
        mouth_override.opening_left = 0.0;
245
        mouth_override.position_center = 26.0;
246
        mouth_override.opening_center = 10.0;
247
        mouth_override.position_right = 22.0;
248
        mouth_override.opening_right = 0.0;
249
}
250

    
251
void EmotionConfig::init_fear() {
252
        gaze_override.pan_offset = 5.0;
253
        gaze_override.tilt_offset = 0.0;
254
        gaze_override.roll_offset = 0.0;
255
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE;
256

    
257
        // not setable right now
258
        gaze_override.vergence = 0.0;
259

    
260
        gaze_override.eyelid_opening_upper = 50.0;
261
        gaze_override.eyelid_opening_lower = 50.0;
262

    
263
        // eyebrow angles
264
        gaze_override.eyebrow_left = -23.0;
265
        gaze_override.eyebrow_right = 23.0;
266

    
267
        // eyeblink request
268
        gaze_override.eyeblink_request_left = 0;
269
        gaze_override.eyeblink_request_right = 0;
270

    
271
        // mouth:
272
        mouth_override.position_left = 14;
273
        mouth_override.opening_left = 0.0;
274
        mouth_override.position_center = 21;
275
        mouth_override.opening_center = 5;
276
        mouth_override.position_right = 35.9;
277
        mouth_override.opening_right = 0.0;
278
}