hlrc / server / src / EmotionConfig.cpp @ 44128a92
History | View | Annotate | Download (7.683 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 |
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 |
// 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 |
} |
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 |
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 |
|
101 |
} |
102 |
|
103 |
void EmotionConfig::init_happy(){
|
104 |
//neutral = look straight
|
105 |
gaze_override.pan_offset = 0.0; |
106 |
gaze_override.tilt_offset = 0.0; |
107 |
gaze_override.roll_offset = 0.0; |
108 |
gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
|
109 |
|
110 |
//not setable right now
|
111 |
gaze_override.vergence = 0.0; |
112 |
|
113 |
gaze_override.eyelid_opening_upper = 30.0; |
114 |
gaze_override.eyelid_opening_lower = 30.0; |
115 |
|
116 |
//eyebrow angles
|
117 |
gaze_override.eyebrow_left = -1.0; |
118 |
gaze_override.eyebrow_right = 1.0; |
119 |
|
120 |
//eyeblink request
|
121 |
gaze_override.eyeblink_request_left = humotion::GazeState::EYEBLINK_TIME_DEFAULT; |
122 |
gaze_override.eyeblink_request_right = humotion::GazeState::EYEBLINK_TIME_DEFAULT; |
123 |
|
124 |
//mouth:
|
125 |
//left lower 0.0313
|
126 |
//left upper: 0.0175
|
127 |
//left middle: 24.4
|
128 |
//left opening: 13.8
|
129 |
|
130 |
//center lower: 0.0388
|
131 |
//center upper: 0.0205
|
132 |
//center middle: 29.7
|
133 |
//center opening: 18.3
|
134 |
|
135 |
//right lower: 0.0303
|
136 |
//right upper: 0.0177
|
137 |
//right middle: 24.0
|
138 |
//right opening: 12.6
|
139 |
|
140 |
|
141 |
mouth_override.position_left = -24;
|
142 |
mouth_override.opening_left = 0.0; |
143 |
mouth_override.position_center = 29.7; |
144 |
mouth_override.opening_center = 18.3; |
145 |
mouth_override.position_right = -24;
|
146 |
mouth_override.opening_right = 0.0; |
147 |
|
148 |
} |
149 |
|
150 |
void EmotionConfig::init_sad(){
|
151 |
gaze_override.pan_offset = 0.0; |
152 |
gaze_override.tilt_offset = -3.0; |
153 |
gaze_override.roll_offset = -3.0; |
154 |
gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
|
155 |
|
156 |
//not setable right now
|
157 |
gaze_override.vergence = 0.0; |
158 |
|
159 |
gaze_override.eyelid_opening_upper = 15.0; |
160 |
gaze_override.eyelid_opening_lower = 40.0; |
161 |
|
162 |
//eyebrow angles
|
163 |
gaze_override.eyebrow_left = -20.0; |
164 |
gaze_override.eyebrow_right = 20.0; |
165 |
|
166 |
//eyeblink request
|
167 |
gaze_override.eyeblink_request_left = 3 * humotion::GazeState::EYEBLINK_TIME_DEFAULT;
|
168 |
gaze_override.eyeblink_request_right = 3 * humotion::GazeState::EYEBLINK_TIME_DEFAULT;
|
169 |
|
170 |
//mouth:
|
171 |
mouth_override.position_left = 20.0; |
172 |
mouth_override.opening_left = 0.0; |
173 |
mouth_override.position_center = 16.1; |
174 |
mouth_override.opening_center = 4.0; |
175 |
mouth_override.position_right = 20.0; |
176 |
mouth_override.opening_right = 0.0; |
177 |
} |
178 |
|
179 |
void EmotionConfig::init_angry(){
|
180 |
gaze_override.pan_offset = 0.0; |
181 |
gaze_override.tilt_offset = -5.0; |
182 |
gaze_override.roll_offset = 0.0; |
183 |
gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
|
184 |
|
185 |
//not setable right now
|
186 |
gaze_override.vergence = 0.0; |
187 |
|
188 |
gaze_override.eyelid_opening_upper = 18.0; |
189 |
gaze_override.eyelid_opening_lower = 18.0; |
190 |
|
191 |
//eyebrow angles
|
192 |
gaze_override.eyebrow_left = 21.0; |
193 |
gaze_override.eyebrow_right = -21.0; |
194 |
|
195 |
//eyeblink request
|
196 |
gaze_override.eyeblink_request_left = 0;
|
197 |
gaze_override.eyeblink_request_right = 0;
|
198 |
|
199 |
//mouth:
|
200 |
mouth_override.position_left = 12.5; |
201 |
mouth_override.opening_left = 0.0; |
202 |
mouth_override.position_center = 16.3; |
203 |
mouth_override.opening_center = 2.0; |
204 |
mouth_override.position_right = 17.5; |
205 |
mouth_override.opening_right = 0.0; |
206 |
} |
207 |
|
208 |
void EmotionConfig::init_surprised(){
|
209 |
gaze_override.pan_offset = 0.0; |
210 |
gaze_override.tilt_offset = 8.0; |
211 |
gaze_override.roll_offset = 0.0; |
212 |
gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; //GAZETYPE_OVERRIDE;
|
213 |
|
214 |
//not setable right now
|
215 |
gaze_override.vergence = 0.0; |
216 |
|
217 |
//eyelids
|
218 |
gaze_override.eyelid_opening_upper = 60.0; |
219 |
gaze_override.eyelid_opening_lower = 60.0; |
220 |
|
221 |
//eyebrow angles
|
222 |
gaze_override.eyebrow_left = -2.0; |
223 |
gaze_override.eyebrow_right = 2.0; |
224 |
|
225 |
//eyeblink request
|
226 |
gaze_override.eyeblink_request_left = humotion::GazeState::EYEBLINK_TIME_DEFAULT; |
227 |
gaze_override.eyeblink_request_right = humotion::GazeState::EYEBLINK_TIME_DEFAULT; |
228 |
|
229 |
//mouth:
|
230 |
mouth_override.position_left = 12.5; |
231 |
mouth_override.opening_left = 0.0; |
232 |
mouth_override.position_center = 16.3; |
233 |
mouth_override.opening_center = 9.0; |
234 |
mouth_override.position_right = 12.5; |
235 |
mouth_override.opening_right = 0.0; |
236 |
} |
237 |
|
238 |
void EmotionConfig::init_fear(){
|
239 |
gaze_override.pan_offset = 5.0; |
240 |
gaze_override.tilt_offset = 0.0; |
241 |
gaze_override.roll_offset = 0.0; |
242 |
gaze_override.gaze_type = humotion::GazeState::GAZETYPE_ABSOLUTE; |
243 |
|
244 |
//not setable right now
|
245 |
gaze_override.vergence = 0.0; |
246 |
|
247 |
gaze_override.eyelid_opening_upper = 50.0; |
248 |
gaze_override.eyelid_opening_lower = 50.0; |
249 |
|
250 |
|
251 |
//eyebrow angles
|
252 |
gaze_override.eyebrow_left = -23.0; |
253 |
gaze_override.eyebrow_right = 23.0; |
254 |
|
255 |
//eyeblink request
|
256 |
gaze_override.eyeblink_request_left = 0;
|
257 |
gaze_override.eyeblink_request_right = 0;
|
258 |
|
259 |
//mouth:
|
260 |
mouth_override.position_left = 18.9; |
261 |
mouth_override.opening_left = 0.0; |
262 |
mouth_override.position_center = 16.3; |
263 |
mouth_override.opening_center = 2.2; |
264 |
mouth_override.position_right = 18.9; |
265 |
mouth_override.opening_right = 0.0; |
266 |
} |