Statistics
| Branch: | Tag: | Revision:

hlrc / server / src / EmotionConfig.cpp @ 90fa4b4e

History | View | Annotate | Download (7.846 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
#include "EmotionConfig.h"
30
31 f150aab5 Robert Haschke
EmotionConfig::EmotionConfig() {
32
        select_config(NEUTRAL);
33 0c286af0 Simon Schulz
}
34
35 f150aab5 Robert Haschke
EmotionConfig::EmotionConfig(EmotionType e) {
36
        select_config(e);
37 0c286af0 Simon Schulz
}
38
39 f150aab5 Robert Haschke
EmotionConfig::~EmotionConfig() {
40 0c286af0 Simon Schulz
}
41
42 f150aab5 Robert Haschke
bool EmotionConfig::is_active() {
43 90fa4b4e Robert Haschke
        if (std::chrono::steady_clock::now() >= end_time) {
44 f150aab5 Robert Haschke
                return false;
45
        }
46 0c286af0 Simon Schulz
47 f150aab5 Robert Haschke
        return true;
48 0c286af0 Simon Schulz
}
49
50 f150aab5 Robert Haschke
void EmotionConfig::set_duration(unsigned long ms) {
51
        // set a timeout:
52 90fa4b4e Robert Haschke
        end_time = std::chrono::steady_clock::now() + std::chrono::milliseconds(ms);
53 0c286af0 Simon Schulz
}
54
55 f150aab5 Robert Haschke
void EmotionConfig::select_config(EmotionType e) {
56
        // default overblend time
57
        overblend_time_ms = 500;
58
59
        switch ((int)e) {
60
                default:
61
                case (NEUTRAL):
62
                        init_neutral();
63
                        break;
64
                case (HAPPY):
65
                        init_happy();
66
                        break;
67
                case (SAD):
68
                        init_sad();
69
                        break;
70
                case (ANGRY):
71
                        init_angry();
72
                        break;
73
                case (SURPRISED):
74
                        init_surprised();
75
                        break;
76
                case (FEAR):
77
                        init_fear();
78
                        break;
79
        }
80 0c286af0 Simon Schulz
}
81
82 f150aab5 Robert Haschke
void EmotionConfig::init_neutral() {
83
        // neutral = look straight
84
        gaze_override.pan_offset = 0.0;
85
        gaze_override.tilt_offset = 0.0;
86
        gaze_override.roll_offset = 0.0;
87
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; // GAZETYPE_OVERRIDE;
88
89
        // not setable right now
90
        gaze_override.vergence = 0.0;
91
92
        gaze_override.eyelid_opening_upper = 25.0;
93
        gaze_override.eyelid_opening_lower = 30.0;
94
95
        // eyebrow angles
96
        gaze_override.eyebrow_left = -3.0;
97
        gaze_override.eyebrow_right = 3.0;
98
99
        // eyeblink request
100
        gaze_override.eyeblink_request_left = 0;
101
        gaze_override.eyeblink_request_right = 0;
102
103
        // mouth:
104
        /*mouth_override.position_left   = 14.7;
105
        mouth_override.opening_left    = 0.0;
106
        mouth_override.position_center = 16.0;
107
        mouth_override.opening_center  = 1.0;
108
        mouth_override.position_right  = 14.7;
109
        mouth_override.opening_right   = 0.0;*/
110
        /*mouth_override.position_left   = 11.54200000000000000000;
111
        mouth_override.opening_left    = 0; //2.412000;
112
        mouth_override.position_center = 12.50000000000000000;
113
        mouth_override.opening_center  = 0; //1.737000;
114
        mouth_override.position_right  = 11.5250000000000000000;
115
        mouth_override.opening_right   = 0;//2.412000;
116
        */
117
118
        mouth_override.position_left = 20;
119
        mouth_override.opening_left = 0.0;
120
        mouth_override.position_center = 22;
121
        mouth_override.opening_center = 2.0;
122
        mouth_override.position_right = 20 - 2;
123
        mouth_override.opening_right = 0.0;
124 0c286af0 Simon Schulz
}
125
126 f150aab5 Robert Haschke
void EmotionConfig::init_happy() {
127
        // neutral = look straight
128
        gaze_override.pan_offset = 0.0;
129
        gaze_override.tilt_offset = 0.0;
130
        gaze_override.roll_offset = 0.0;
131
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; // GAZETYPE_OVERRIDE;
132
133
        // not setable right now
134
        gaze_override.vergence = 0.0;
135
136
        gaze_override.eyelid_opening_upper = 30.0;
137
        gaze_override.eyelid_opening_lower = 30.0;
138
139
        // eyebrow angles
140
        gaze_override.eyebrow_left = -1.0;
141
        gaze_override.eyebrow_right = 1.0;
142
143
        // eyeblink request
144
        gaze_override.eyeblink_request_left = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
145
        gaze_override.eyeblink_request_right = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
146
        /*
147
            mouth_override.position_left   = -1+9.5;
148
            mouth_override.opening_left    = 0.0;
149
            mouth_override.position_center = 24.3;
150
            mouth_override.opening_center  = 7.0;
151
            mouth_override.position_right  = -1+10.5;
152
            mouth_override.opening_right   = 0.0;*/
153
154
        mouth_override.position_left = 18;   // 13.56850000000000000000;
155
        mouth_override.opening_left = 0;     //.791000;
156
        mouth_override.position_center = 26; // 14.18400000000000000000;
157
        mouth_override.opening_center = 5;
158
        mouth_override.position_right = 18; // 15.31800000000000000000;
159
        mouth_override.opening_right = 0;   // 2.791000;
160 0c286af0 Simon Schulz
}
161
162 f150aab5 Robert Haschke
void EmotionConfig::init_sad() {
163
        gaze_override.pan_offset = 0.0;
164
        gaze_override.tilt_offset = -3.0;
165
        gaze_override.roll_offset = -3.0;
166
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; // GAZETYPE_OVERRIDE;
167
168
        // not setable right now
169
        gaze_override.vergence = 0.0;
170
171
        gaze_override.eyelid_opening_upper = 15.0;
172
        gaze_override.eyelid_opening_lower = 40.0;
173
174
        // eyebrow angles
175
        gaze_override.eyebrow_left = -20.0;
176
        gaze_override.eyebrow_right = 20.0;
177
178
        // eyeblink request
179
        gaze_override.eyeblink_request_left = 3 * humotion::GazeState::EYEBLINK_TIME_DEFAULT;
180
        gaze_override.eyeblink_request_right = 3 * humotion::GazeState::EYEBLINK_TIME_DEFAULT;
181
182
        // mouth:
183
        mouth_override.position_left = 21.0;
184
        mouth_override.opening_left = 0.0;
185
        mouth_override.position_center = 16.0;
186
        mouth_override.opening_center = 0.0;
187
        mouth_override.position_right = 21.0;
188
        mouth_override.opening_right = 0.0;
189 0c286af0 Simon Schulz
}
190
191 f150aab5 Robert Haschke
void EmotionConfig::init_angry() {
192
        gaze_override.pan_offset = 0.0;
193
        gaze_override.tilt_offset = -5.0;
194
        gaze_override.roll_offset = 0.0;
195
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; // GAZETYPE_OVERRIDE;
196
197
        // not setable right now
198
        gaze_override.vergence = 0.0;
199
200
        gaze_override.eyelid_opening_upper = 18.0;
201
        gaze_override.eyelid_opening_lower = 18.0;
202
203
        // eyebrow angles
204
        gaze_override.eyebrow_left = 21.0;
205
        gaze_override.eyebrow_right = -21.0;
206
207
        // eyeblink request
208
        gaze_override.eyeblink_request_left = 0;
209
        gaze_override.eyeblink_request_right = 0;
210
211
        // mouth:
212
        mouth_override.position_left = 21;
213
        mouth_override.opening_left = 6.0;
214
        mouth_override.position_center = 22.3;
215
        mouth_override.opening_center = 0.0;
216
        mouth_override.position_right = 21;
217
        mouth_override.opening_right = 6.0;
218 0c286af0 Simon Schulz
}
219
220 f150aab5 Robert Haschke
void EmotionConfig::init_surprised() {
221
        gaze_override.pan_offset = 0.0;
222
        gaze_override.tilt_offset = 8.0;
223
        gaze_override.roll_offset = 0.0;
224
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; // GAZETYPE_OVERRIDE;
225
226
        // not setable right now
227
        gaze_override.vergence = 0.0;
228
229
        // eyelids
230
        gaze_override.eyelid_opening_upper = 60.0;
231
        gaze_override.eyelid_opening_lower = 60.0;
232
233
        // eyebrow angles
234
        gaze_override.eyebrow_left = -2.0;
235
        gaze_override.eyebrow_right = 2.0;
236
237
        // eyeblink request
238
        gaze_override.eyeblink_request_left = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
239
        gaze_override.eyeblink_request_right = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
240
241
        // mouth:
242
        mouth_override.position_left = 22;
243
        mouth_override.opening_left = 0.0;
244
        mouth_override.position_center = 26.0;
245
        mouth_override.opening_center = 10.0;
246
        mouth_override.position_right = 22.0;
247
        mouth_override.opening_right = 0.0;
248 0c286af0 Simon Schulz
}
249
250 f150aab5 Robert Haschke
void EmotionConfig::init_fear() {
251
        gaze_override.pan_offset = 5.0;
252
        gaze_override.tilt_offset = 0.0;
253
        gaze_override.roll_offset = 0.0;
254
        gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE;
255
256
        // not setable right now
257
        gaze_override.vergence = 0.0;
258
259
        gaze_override.eyelid_opening_upper = 50.0;
260
        gaze_override.eyelid_opening_lower = 50.0;
261
262
        // eyebrow angles
263
        gaze_override.eyebrow_left = -23.0;
264
        gaze_override.eyebrow_right = 23.0;
265
266
        // eyeblink request
267
        gaze_override.eyeblink_request_left = 0;
268
        gaze_override.eyeblink_request_right = 0;
269
270
        // mouth:
271
        mouth_override.position_left = 14;
272
        mouth_override.opening_left = 0.0;
273
        mouth_override.position_center = 21;
274
        mouth_override.opening_center = 5;
275
        mouth_override.position_right = 35.9;
276
        mouth_override.opening_right = 0.0;
277 0c286af0 Simon Schulz
}