hlrc / server / include / Animation.h @ 0652ebb7
History | View | Annotate | Download (2.91 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 | #include "boost/date_time/posix_time/posix_time.hpp" |
||
32 | #include <boost/thread/thread_time.hpp> |
||
33 | #include <boost/thread/thread.hpp> |
||
34 | |||
35 | class Animation{ |
||
36 | public:
|
||
37 | Animation(); |
||
38 | ~Animation(); |
||
39 | |||
40 | void apply_on_gazestate(humotion::GazeState *gaze);
|
||
41 | void start();
|
||
42 | bool is_active();
|
||
43 | bool collides_with(Animation *ani);
|
||
44 | |||
45 | |||
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; |
||
58 | |||
59 | AnimationType_t target; |
||
60 | unsigned int repetitions; |
||
61 | unsigned int duration_each; //in ms |
||
62 | float scale;
|
||
63 | |||
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 | } |
||
85 | |||
86 | 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); |
||
90 | |||
91 | bool active;
|
||
92 | unsigned int repetition_now; |
||
93 | boost::system_time end_time; |
||
94 | boost::system_time start_time; |
||
95 | }; |
||
96 |