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