hlrc / server / include / Animation.h @ 964ddd88
History | View | Annotate | Download (2.863 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 | #pragma once
|
||
30 | #include <humotion/gaze_state.h> |
||
31 | 9cb381ec | Robert Haschke | #include <chrono> |
32 | 0c286af0 | Simon Schulz | |
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 | |||
44 | typedef enum { |
||
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): return "IDLE"; |
||
65 | case(HEAD_NOD): return "HEAD_NOD"; |
||
66 | case(HEAD_SHAKE): return "HEAD_SHAKE"; |
||
67 | case(EYEBLINK_L): return "EYEBLINK_L"; |
||
68 | case(EYEBLINK_R): return "EYEBLINK_R"; |
||
69 | case(EYEBLINK_BOTH): return "EYEBLINK_BOTH"; |
||
70 | case(EYEBROWS_RAISE): return "EYEBROWS_RAISE"; |
||
71 | case(EYEBROWS_LOWER): return "EYEBROWS_LOWER"; |
||
72 | case(ENGAGEMENT_LEFT): return "ENGAGEMENT_LEFT"; |
||
73 | case(ENGAGEMENT_RIGHT): return "ENGAGEMENT_RIGHT"; |
||
74 | default: return "INVALID ID!"; |
||
75 | } |
||
76 | } |
||
77 | |||
78 | std::string as_string(){ |
||
79 | char buf[256]; |
||
80 | snprintf(buf, 255, "Animation: %d times %s (duration each = %dms)", repetitions, type_as_string().c_str(), duration_each); |
||
81 | return buf;
|
||
82 | } |
||
83 | |||
84 | private:
|
||
85 | float apply_motion_profile_positive(float tn); |
||
86 | float apply_motion_profile_symmetric(float tn, unsigned int rep); |
||
87 | float apply_motion_profile_asymmetric(float tn, unsigned int rep); |
||
88 | |||
89 | bool active;
|
||
90 | unsigned int repetition_now; |
||
91 | 9cb381ec | Robert Haschke | std::chrono::time_point<std::chrono::steady_clock> end_time; |
92 | std::chrono::time_point<std::chrono::steady_clock> start_time; |
||
93 | 0c286af0 | Simon Schulz | }; |