Statistics
| Branch: | Tag: | Revision:

hlrc / server / src / EmotionConfig.cpp @ d4c15d69

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