Revision f150aab5 server/include/Animation.h
server/include/Animation.h | ||
---|---|---|
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 |
#pragma once |
30 | 30 |
#include <humotion/gaze_state.h> |
... | ... | |
32 | 32 |
#include <boost/thread/thread_time.hpp> |
33 | 33 |
#include <boost/thread/thread.hpp> |
34 | 34 |
|
35 |
class Animation{ |
|
35 |
class Animation {
|
|
36 | 36 |
public: |
37 |
Animation();
|
|
38 |
~Animation();
|
|
37 |
Animation();
|
|
38 |
~Animation();
|
|
39 | 39 |
|
40 |
void apply_on_gazestate(humotion::GazeState *gaze);
|
|
41 |
void start();
|
|
42 |
bool is_active();
|
|
43 |
bool collides_with(Animation *ani);
|
|
40 |
void apply_on_gazestate(humotion::GazeState* gaze);
|
|
41 |
void start();
|
|
42 |
bool is_active();
|
|
43 |
bool collides_with(Animation* ani);
|
|
44 | 44 |
|
45 |
typedef enum |
|
46 |
{ |
|
47 |
IDLE = 0, |
|
48 |
HEAD_NOD, |
|
49 |
HEAD_SHAKE, |
|
50 |
EYEBLINK_L, |
|
51 |
EYEBLINK_R, |
|
52 |
EYEBLINK_BOTH, |
|
53 |
EYEBROWS_RAISE, |
|
54 |
EYEBROWS_LOWER, |
|
55 |
ENGAGEMENT_LEFT, |
|
56 |
ENGAGEMENT_RIGHT |
|
57 |
} AnimationType_t; |
|
45 | 58 |
|
46 |
typedef enum { |
|
47 |
IDLE = 0, |
|
48 |
HEAD_NOD, |
|
49 |
HEAD_SHAKE, |
|
50 |
EYEBLINK_L, |
|
51 |
EYEBLINK_R, |
|
52 |
EYEBLINK_BOTH, |
|
53 |
EYEBROWS_RAISE, |
|
54 |
EYEBROWS_LOWER, |
|
55 |
ENGAGEMENT_LEFT, |
|
56 |
ENGAGEMENT_RIGHT |
|
57 |
} AnimationType_t; |
|
59 |
AnimationType_t target; |
|
60 |
unsigned int repetitions; |
|
61 |
unsigned int duration_each; // in ms |
|
62 |
float scale; |
|
58 | 63 |
|
59 |
AnimationType_t target; |
|
60 |
unsigned int repetitions; |
|
61 |
unsigned int duration_each; //in ms |
|
62 |
float scale; |
|
64 |
std::string type_as_string() { |
|
65 |
switch ((int)target) { |
|
66 |
case (IDLE): |
|
67 |
return "IDLE"; |
|
68 |
case (HEAD_NOD): |
|
69 |
return "HEAD_NOD"; |
|
70 |
case (HEAD_SHAKE): |
|
71 |
return "HEAD_SHAKE"; |
|
72 |
case (EYEBLINK_L): |
|
73 |
return "EYEBLINK_L"; |
|
74 |
case (EYEBLINK_R): |
|
75 |
return "EYEBLINK_R"; |
|
76 |
case (EYEBLINK_BOTH): |
|
77 |
return "EYEBLINK_BOTH"; |
|
78 |
case (EYEBROWS_RAISE): |
|
79 |
return "EYEBROWS_RAISE"; |
|
80 |
case (EYEBROWS_LOWER): |
|
81 |
return "EYEBROWS_LOWER"; |
|
82 |
case (ENGAGEMENT_LEFT): |
|
83 |
return "ENGAGEMENT_LEFT"; |
|
84 |
case (ENGAGEMENT_RIGHT): |
|
85 |
return "ENGAGEMENT_RIGHT"; |
|
86 |
default: |
|
87 |
return "INVALID ID!"; |
|
88 |
} |
|
89 |
} |
|
63 | 90 |
|
64 |
std::string type_as_string(){ |
|
65 |
switch ((int)target){ |
|
66 |
case(IDLE): return "IDLE"; |
|
67 |
case(HEAD_NOD): return "HEAD_NOD"; |
|
68 |
case(HEAD_SHAKE): return "HEAD_SHAKE"; |
|
69 |
case(EYEBLINK_L): return "EYEBLINK_L"; |
|
70 |
case(EYEBLINK_R): return "EYEBLINK_R"; |
|
71 |
case(EYEBLINK_BOTH): return "EYEBLINK_BOTH"; |
|
72 |
case(EYEBROWS_RAISE): return "EYEBROWS_RAISE"; |
|
73 |
case(EYEBROWS_LOWER): return "EYEBROWS_LOWER"; |
|
74 |
case(ENGAGEMENT_LEFT): return "ENGAGEMENT_LEFT"; |
|
75 |
case(ENGAGEMENT_RIGHT): return "ENGAGEMENT_RIGHT"; |
|
76 |
default: return "INVALID ID!"; |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
std::string as_string(){ |
|
81 |
char buf[256]; |
|
82 |
snprintf(buf, 255, "Animation: %d times %s (duration each = %dms)", repetitions, type_as_string().c_str(), duration_each); |
|
83 |
return buf; |
|
84 |
} |
|
91 |
std::string as_string() { |
|
92 |
char buf[256]; |
|
93 |
snprintf(buf, 255, "Animation: %d times %s (duration each = %dms)", repetitions, type_as_string().c_str(), |
|
94 |
duration_each); |
|
95 |
return buf; |
|
96 |
} |
|
85 | 97 |
|
86 | 98 |
private: |
87 |
float apply_motion_profile_positive(float tn);
|
|
88 |
float apply_motion_profile_symmetric(float tn, unsigned int rep);
|
|
89 |
float apply_motion_profile_asymmetric(float tn, unsigned int rep);
|
|
99 |
float apply_motion_profile_positive(float tn);
|
|
100 |
float apply_motion_profile_symmetric(float tn, unsigned int rep);
|
|
101 |
float apply_motion_profile_asymmetric(float tn, unsigned int rep);
|
|
90 | 102 |
|
91 |
bool active;
|
|
92 |
unsigned int repetition_now;
|
|
93 |
boost::system_time end_time;
|
|
94 |
boost::system_time start_time;
|
|
103 |
bool active;
|
|
104 |
unsigned int repetition_now;
|
|
105 |
boost::system_time end_time;
|
|
106 |
boost::system_time start_time;
|
|
95 | 107 |
}; |
96 |
|
|
97 |
|
Also available in: Unified diff