Statistics
| Branch: | Tag: | Revision:

hlrc / server / src / EmotionConfig.cpp @ d4dfb462

History | View | Annotate | Download (7.59 KB)

1 0c286af0 Simon Schulz
/*
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
using namespace boost;
31
32
EmotionConfig::EmotionConfig(){
33
    select_config(NEUTRAL);
34
}
35
36
EmotionConfig::EmotionConfig(EmotionType e){
37
    select_config(e);
38
}
39
40
EmotionConfig::~EmotionConfig(){
41
}
42
43
44
bool EmotionConfig::is_active(){
45
    if (get_system_time() >= end_time){
46
        return false;
47
    }
48
49
    return true;
50
}
51
52
void EmotionConfig::set_duration(unsigned long ms){
53
    //set a timeout:
54
    end_time = get_system_time() + posix_time::milliseconds(ms);
55
}
56
57
void EmotionConfig::select_config(EmotionType e){
58 efbcb710 sschulz
    // default overblend time
59
    overblend_time_ms = 500;
60
61 0c286af0 Simon Schulz
    switch((int) e){
62
        default:
63
        case(NEUTRAL): init_neutral(); break;
64
        case(HAPPY  ): init_happy(); break;
65
        case(SAD    ): init_sad(); break;
66
        case(ANGRY  ): init_angry(); break;
67
        case(SURPRISED): init_surprised(); break;
68
        case(FEAR):      init_fear(); break;
69
    }
70
}
71
72
void EmotionConfig::init_neutral(){
73
    //neutral = look straight
74
    gaze_override.pan_offset = 0.0;
75
    gaze_override.tilt_offset = 0.0;
76
    gaze_override.roll_offset = 0.0;
77 16a22a2b Simon Schulz
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
78 0c286af0 Simon Schulz
79
    //not setable right now
80
    gaze_override.vergence = 0.0;
81
82 ded12eae Simon Schulz
    gaze_override.eyelid_opening_upper = 25.0;
83
    gaze_override.eyelid_opening_lower = 30.0;
84 0c286af0 Simon Schulz
85
    //eyebrow angles
86
    gaze_override.eyebrow_left = -3.0;
87
    gaze_override.eyebrow_right = 3.0;
88
89
    //eyeblink request
90
    gaze_override.eyeblink_request_left  = 0;
91
    gaze_override.eyeblink_request_right = 0;
92
93
    //mouth:
94
    mouth_override.position_left   = 14.7;
95
    mouth_override.opening_left    = 0.0;
96
    mouth_override.position_center = 16.0;
97
    mouth_override.opening_center  = 1.0;
98
    mouth_override.position_right  = 14.7;
99
    mouth_override.opening_right   = 0.0;
100
}
101
102
void EmotionConfig::init_happy(){
103
    //neutral = look straight
104
    gaze_override.pan_offset = 0.0;
105
    gaze_override.tilt_offset = 0.0;
106
    gaze_override.roll_offset = 0.0;
107 16a22a2b Simon Schulz
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
108 0c286af0 Simon Schulz
109
    //not setable right now
110
    gaze_override.vergence = 0.0;
111
112 ded12eae Simon Schulz
    gaze_override.eyelid_opening_upper = 30.0;
113
    gaze_override.eyelid_opening_lower = 30.0;
114 0c286af0 Simon Schulz
115
    //eyebrow angles
116
    gaze_override.eyebrow_left = -1.0;
117
    gaze_override.eyebrow_right = 1.0;
118
119
    //eyeblink request
120
    gaze_override.eyeblink_request_left  = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
121
    gaze_override.eyeblink_request_right = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
122
123
    //mouth:
124
    mouth_override.position_left   = 12.5;
125
    mouth_override.opening_left    = 0.0;
126
    mouth_override.position_center = 14.88;
127
    mouth_override.opening_center  = 7.4;
128
    mouth_override.position_right  = 12.5;
129
    mouth_override.opening_right   = 0.0;
130
131 3f2353f5 sschulz
    // faster overblending
132
    overblend_time_ms = 300;
133 0c286af0 Simon Schulz
}
134
135
void EmotionConfig::init_sad(){
136
    gaze_override.pan_offset = 0.0;
137 efbcb710 sschulz
    gaze_override.tilt_offset = -13.0;
138 0c286af0 Simon Schulz
    gaze_override.roll_offset = -3.0;
139 16a22a2b Simon Schulz
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
140 0c286af0 Simon Schulz
141
    //not setable right now
142
    gaze_override.vergence = 0.0;
143
144
    gaze_override.eyelid_opening_upper = 15.0;
145
    gaze_override.eyelid_opening_lower = 40.0;
146
147
    //eyebrow angles
148
    gaze_override.eyebrow_left = -20.0;
149
    gaze_override.eyebrow_right = 20.0;
150
151
    //eyeblink request
152
    gaze_override.eyeblink_request_left  = 3 * humotion::GazeState::EYEBLINK_TIME_DEFAULT;
153
    gaze_override.eyeblink_request_right = 3 * humotion::GazeState::EYEBLINK_TIME_DEFAULT;
154
155
    //mouth:
156
    mouth_override.position_left   = 20.0;
157
    mouth_override.opening_left    = 0.0;
158
    mouth_override.position_center = 16.1;
159
    mouth_override.opening_center  = 4.0;
160
    mouth_override.position_right  = 20.0;
161
    mouth_override.opening_right   = 0.0;
162 3f2353f5 sschulz
163
    // slower overblending
164
    overblend_time_ms = 900;
165 0c286af0 Simon Schulz
}
166
167
void EmotionConfig::init_angry(){
168
    gaze_override.pan_offset = 0.0;
169
    gaze_override.tilt_offset = -5.0;
170
    gaze_override.roll_offset = 0.0;
171 16a22a2b Simon Schulz
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
172 0c286af0 Simon Schulz
173
    //not setable right now
174
    gaze_override.vergence = 0.0;
175
176
    gaze_override.eyelid_opening_upper = 18.0;
177
    gaze_override.eyelid_opening_lower = 18.0;
178
179
    //eyebrow angles
180
    gaze_override.eyebrow_left =  21.0;
181
    gaze_override.eyebrow_right = -21.0;
182
183
    //eyeblink request
184
    gaze_override.eyeblink_request_left  = 0;
185
    gaze_override.eyeblink_request_right = 0;
186
187
    //mouth:
188
    mouth_override.position_left   = 12.5;
189
    mouth_override.opening_left    = 0.0;
190
    mouth_override.position_center = 16.3;
191
    mouth_override.opening_center  = 2.0;
192
    mouth_override.position_right  = 17.5;
193
    mouth_override.opening_right   = 0.0;
194
}
195
196
void EmotionConfig::init_surprised(){
197
    gaze_override.pan_offset  = 0.0;
198
    gaze_override.tilt_offset = 8.0;
199
    gaze_override.roll_offset = 0.0;
200 16a22a2b Simon Schulz
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
201 0c286af0 Simon Schulz
202
    //not setable right now
203
    gaze_override.vergence = 0.0;
204
205
    //eyelids
206
    gaze_override.eyelid_opening_upper = 60.0;
207
    gaze_override.eyelid_opening_lower = 60.0;
208
209
    //eyebrow angles
210
    gaze_override.eyebrow_left =  -2.0;
211
    gaze_override.eyebrow_right =  2.0;
212
213
    //eyeblink request
214
    gaze_override.eyeblink_request_left  = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
215
    gaze_override.eyeblink_request_right = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
216
217
    //mouth:
218
    mouth_override.position_left   = 12.5;
219
    mouth_override.opening_left    = 0.0;
220
    mouth_override.position_center = 16.3;
221
    mouth_override.opening_center  = 9.0;
222
    mouth_override.position_right  = 12.5;
223
    mouth_override.opening_right   = 0.0;
224 3f2353f5 sschulz
225
    // faster overblending
226
    overblend_time_ms = 300;
227 0c286af0 Simon Schulz
}
228
229
void EmotionConfig::init_fear(){
230
    gaze_override.pan_offset  = 5.0;
231
    gaze_override.tilt_offset = 0.0;
232
    gaze_override.roll_offset = 0.0;
233 3787a859 Simon Schulz
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE;
234 0c286af0 Simon Schulz
235
    //not setable right now
236
    gaze_override.vergence = 0.0;
237
238
    gaze_override.eyelid_opening_upper = 50.0;
239
    gaze_override.eyelid_opening_lower = 50.0;
240
241
242
    //eyebrow angles
243
    gaze_override.eyebrow_left =  -23.0;
244
    gaze_override.eyebrow_right =  23.0;
245
246
    //eyeblink request
247
    gaze_override.eyeblink_request_left  = 0;
248
    gaze_override.eyeblink_request_right = 0;
249
250
    //mouth:
251
    mouth_override.position_left   = 18.9;
252
    mouth_override.opening_left    = 0.0;
253
    mouth_override.position_center = 16.3;
254
    mouth_override.opening_center  = 2.2;
255
    mouth_override.position_right  = 18.9;
256
    mouth_override.opening_right   = 0.0;
257 3f2353f5 sschulz
258
    // slower overblending
259
    overblend_time_ms = 800;
260 0c286af0 Simon Schulz
}