Revision f150aab5 server/src/EmotionConfig.cpp

View differences:

server/src/EmotionConfig.cpp
1 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
*/
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 28

  
29 29
#include "EmotionConfig.h"
30 30
using namespace boost;
31 31

  
32
EmotionConfig::EmotionConfig(){
33
    select_config(NEUTRAL);
32
EmotionConfig::EmotionConfig() {
33
	select_config(NEUTRAL);
34 34
}
35 35

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

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

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

  
44
bool EmotionConfig::is_active(){
45
    if (get_system_time() >= end_time){
46
        return false;
47
    }
48

  
49
    return true;
48
	return true;
50 49
}
51 50

  
52
void EmotionConfig::set_duration(unsigned long ms){
53
    //set a timeout:
54
    end_time = get_system_time() + posix_time::milliseconds(ms);
51
void EmotionConfig::set_duration(unsigned long ms) {
52
	// set a timeout:
53
	end_time = get_system_time() + posix_time::milliseconds(ms);
55 54
}
56 55

  
57
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): 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
    }
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
	}
70 81
}
71 82

  
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
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
78

  
79
    //not setable right now
80
    gaze_override.vergence = 0.0;
81

  
82
    gaze_override.eyelid_opening_upper = 25.0;
83
    gaze_override.eyelid_opening_lower = 30.0;
84

  
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
    /*mouth_override.position_left   = 11.54200000000000000000;
101
    mouth_override.opening_left    = 0; //2.412000;
102
    mouth_override.position_center = 12.50000000000000000;
103
    mouth_override.opening_center  = 0; //1.737000;
104
    mouth_override.position_right  = 11.5250000000000000000;
105
    mouth_override.opening_right   = 0;//2.412000;
106
    */
107
    
108
    mouth_override.position_left   = 20;
109
    mouth_override.opening_left    = 0.0;
110
    mouth_override.position_center = 22;
111
    mouth_override.opening_center  = 2.0;
112
    mouth_override.position_right  = 20-2;
113
    mouth_override.opening_right   = 0.0;
114

  
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 = 20;
120
	mouth_override.opening_left = 0.0;
121
	mouth_override.position_center = 22;
122
	mouth_override.opening_center = 2.0;
123
	mouth_override.position_right = 20 - 2;
124
	mouth_override.opening_right = 0.0;
115 125
}
116 126

  
117
void EmotionConfig::init_happy(){
118
    //neutral = look straight
119
    gaze_override.pan_offset = 0.0;
120
    gaze_override.tilt_offset = 0.0;
121
    gaze_override.roll_offset = 0.0;
122
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
123

  
124
    //not setable right now
125
    gaze_override.vergence = 0.0;
126

  
127
    gaze_override.eyelid_opening_upper = 30.0;
128
    gaze_override.eyelid_opening_lower = 30.0;
129

  
130
    //eyebrow angles
131
    gaze_override.eyebrow_left = -1.0;
132
    gaze_override.eyebrow_right = 1.0;
133

  
134
    //eyeblink request
135
    gaze_override.eyeblink_request_left  = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
136
    gaze_override.eyeblink_request_right = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
137
/*
138
    mouth_override.position_left   = -1+9.5;
139
    mouth_override.opening_left    = 0.0;
140
    mouth_override.position_center = 24.3;
141
    mouth_override.opening_center  = 7.0;
142
    mouth_override.position_right  = -1+10.5;
143
    mouth_override.opening_right   = 0.0;*/
144
  
145
    mouth_override.position_left   = 18; //13.56850000000000000000;
146
    mouth_override.opening_left    = 0; //.791000;
147
    mouth_override.position_center = 26; //14.18400000000000000000;
148
    mouth_override.opening_center  = 5;
149
    mouth_override.position_right  = 18; //15.31800000000000000000;
150
    mouth_override.opening_right   = 0; //2.791000;
151

  
152
 
153

  
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;
154 161
}
155 162

  
156
void EmotionConfig::init_sad(){
157
    gaze_override.pan_offset = 0.0;
158
    gaze_override.tilt_offset = -3.0;
159
    gaze_override.roll_offset = -3.0;
160
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
161

  
162
    //not setable right now
163
    gaze_override.vergence = 0.0;
164

  
165
    gaze_override.eyelid_opening_upper = 15.0;
166
    gaze_override.eyelid_opening_lower = 40.0;
167

  
168
    //eyebrow angles
169
    gaze_override.eyebrow_left = -20.0;
170
    gaze_override.eyebrow_right = 20.0;
171

  
172
    //eyeblink request
173
    gaze_override.eyeblink_request_left  = 3 * humotion::GazeState::EYEBLINK_TIME_DEFAULT;
174
    gaze_override.eyeblink_request_right = 3 * humotion::GazeState::EYEBLINK_TIME_DEFAULT;
175

  
176
    //mouth:
177
    mouth_override.position_left   = 21.0;
178
    mouth_override.opening_left    = 0.0;
179
    mouth_override.position_center = 16.0;
180
    mouth_override.opening_center  = 0.0;
181
    mouth_override.position_right  = 21.0;
182
    mouth_override.opening_right   = 0.0;
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;
183 190
}
184 191

  
185
void EmotionConfig::init_angry(){
186
    gaze_override.pan_offset = 0.0;
187
    gaze_override.tilt_offset = -5.0;
188
    gaze_override.roll_offset = 0.0;
189
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
190

  
191
    //not setable right now
192
    gaze_override.vergence = 0.0;
193

  
194
    gaze_override.eyelid_opening_upper = 18.0;
195
    gaze_override.eyelid_opening_lower = 18.0;
196

  
197
    //eyebrow angles
198
    gaze_override.eyebrow_left =  21.0;
199
    gaze_override.eyebrow_right = -21.0;
200

  
201
    //eyeblink request
202
    gaze_override.eyeblink_request_left  = 0;
203
    gaze_override.eyeblink_request_right = 0;
204

  
205
    //mouth:
206
    mouth_override.position_left   = 21;
207
    mouth_override.opening_left    = 6.0;
208
    mouth_override.position_center = 22.3;
209
    mouth_override.opening_center  = 0.0;
210
    mouth_override.position_right  = 21;
211
    mouth_override.opening_right   = 6.0;
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;
212 219
}
213 220

  
214
void EmotionConfig::init_surprised(){
215
    gaze_override.pan_offset  = 0.0;
216
    gaze_override.tilt_offset = 8.0;
217
    gaze_override.roll_offset = 0.0;
218
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
219

  
220
    //not setable right now
221
    gaze_override.vergence = 0.0;
222

  
223
    //eyelids
224
    gaze_override.eyelid_opening_upper = 60.0;
225
    gaze_override.eyelid_opening_lower = 60.0;
226

  
227
    //eyebrow angles
228
    gaze_override.eyebrow_left =  -2.0;
229
    gaze_override.eyebrow_right =  2.0;
230

  
231
    //eyeblink request
232
    gaze_override.eyeblink_request_left  = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
233
    gaze_override.eyeblink_request_right = humotion::GazeState::EYEBLINK_TIME_DEFAULT;
234

  
235
    //mouth:
236
    mouth_override.position_left   = 22;
237
    mouth_override.opening_left    = 0.0;
238
    mouth_override.position_center = 26.0;
239
    mouth_override.opening_center  = 10.0;
240
    mouth_override.position_right  = 22.0;
241
    mouth_override.opening_right   = 0.0;
242

  
243
    
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;
244 249
}
245 250

  
246
void EmotionConfig::init_fear(){
247
    gaze_override.pan_offset  = 5.0;
248
    gaze_override.tilt_offset = 0.0;
249
    gaze_override.roll_offset = 0.0;
250
    gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE;
251

  
252
    //not setable right now
253
    gaze_override.vergence = 0.0;
254

  
255
    gaze_override.eyelid_opening_upper = 50.0;
256
    gaze_override.eyelid_opening_lower = 50.0;
257

  
258

  
259
    //eyebrow angles
260
    gaze_override.eyebrow_left =  -23.0;
261
    gaze_override.eyebrow_right =  23.0;
262

  
263
    //eyeblink request
264
    gaze_override.eyeblink_request_left  = 0;
265
    gaze_override.eyeblink_request_right = 0;
266

  
267
    //mouth:
268
    mouth_override.position_left   = 14;
269
    mouth_override.opening_left    = 0.0;
270
    mouth_override.position_center = 21;
271
    mouth_override.opening_center  = 5;
272
    mouth_override.position_right  = 35.9;
273
    mouth_override.opening_right   = 0.0;
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;
274 278
}

Also available in: Unified diff