humotion / include / server / joint_interface.h @ 5972e317
History | View | Annotate | Download (3.533 KB)
1 |
/*
|
---|---|
2 |
* This file is part of humotion
|
3 |
*
|
4 |
* Copyright(c) sschulz <AT> techfak.uni-bielefeld.de
|
5 |
* http://opensource.cit-ec.de/projects/humotion
|
6 |
*
|
7 |
* This file may be licensed under the terms of the
|
8 |
* GNU Lesser General Public License Version 3 (the ``LGPL''),
|
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 LGPL for the specific language
|
14 |
* governing rights and limitations.
|
15 |
*
|
16 |
* You should have received a copy of the LGPL along with this
|
17 |
* program. If not, go to http://www.gnu.org/licenses/lgpl.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 |
#pragma once
|
29 |
#include <cstdio> |
30 |
#include <cstdint> |
31 |
#include <string> |
32 |
#include <map> |
33 |
#include "../timestamped_list.h" |
34 |
#include "../mouth_state.h" |
35 |
#include "../gaze_state.h" |
36 |
#include "boost/date_time/posix_time/posix_time.hpp" |
37 |
#include <boost/thread/thread_time.hpp> |
38 |
#include <boost/thread/thread.hpp> |
39 |
#include <boost/thread/mutex.hpp> |
40 |
|
41 |
namespace humotion{ |
42 |
namespace server{ |
43 |
|
44 |
//forward declaration to solve include loop
|
45 |
class Controller; |
46 |
|
47 |
|
48 |
class JointInterface{ |
49 |
public:
|
50 |
JointInterface(); |
51 |
~JointInterface(); |
52 |
|
53 |
void set_target_position(int joint_id, float position); |
54 |
float get_target_position(int joint_id); |
55 |
virtual void publish_target_position(int joint_id) = 0; |
56 |
virtual void execute_motion() = 0; |
57 |
|
58 |
typedef std::map<int, TimestampedList> joint_tsl_map_t; |
59 |
|
60 |
TimestampedList get_ts_position(int joint_id);
|
61 |
TimestampedList get_ts_speed(int joint_id);
|
62 |
|
63 |
void set_framerate(float f); |
64 |
|
65 |
void enable_mouth_joints();
|
66 |
void disable_mouth_joints();
|
67 |
bool mouth_target_input_active();
|
68 |
|
69 |
void enable_gaze_joints();
|
70 |
void disable_gaze_joints();
|
71 |
bool gaze_target_input_active();
|
72 |
|
73 |
float get_joint_min(int joint_id); |
74 |
float get_joint_max(int joint_id); |
75 |
|
76 |
void dump_angles();
|
77 |
|
78 |
unsigned int get_and_clear_incoming_position_count(); |
79 |
|
80 |
enum JOINT_ID_ENUM{
|
81 |
ZERO = 0,
|
82 |
ID_LIP_LEFT_UPPER, |
83 |
ID_LIP_LEFT_LOWER, |
84 |
ID_LIP_CENTER_UPPER, |
85 |
ID_LIP_CENTER_LOWER, |
86 |
ID_LIP_RIGHT_UPPER, |
87 |
ID_LIP_RIGHT_LOWER, |
88 |
ID_NECK_PAN, |
89 |
ID_NECK_TILT, |
90 |
ID_NECK_ROLL, |
91 |
ID_EYES_LEFT_LR, |
92 |
ID_EYES_RIGHT_LR, |
93 |
ID_EYES_BOTH_UD, |
94 |
ID_EYES_LEFT_LID_LOWER, |
95 |
ID_EYES_LEFT_LID_UPPER, |
96 |
ID_EYES_RIGHT_LID_LOWER, |
97 |
ID_EYES_RIGHT_LID_UPPER, |
98 |
ID_EYES_LEFT_BROW, |
99 |
ID_EYES_RIGHT_BROW, |
100 |
JOINT_ID_ENUM_SIZE |
101 |
}; |
102 |
|
103 |
bool get_joint_position_map_empty();
|
104 |
|
105 |
protected:
|
106 |
|
107 |
void store_incoming_position(int joint_id, float position, double timestamp); |
108 |
void store_incoming_speed(int joint_id, float speed, double timestamp); |
109 |
|
110 |
virtual void enable_joint(int id) = 0; |
111 |
virtual void disable_joint(int id) = 0; |
112 |
float framerate;
|
113 |
|
114 |
float joint_min[JOINT_ID_ENUM_SIZE];
|
115 |
float joint_max[JOINT_ID_ENUM_SIZE];
|
116 |
float joint_target[JOINT_ID_ENUM_SIZE];
|
117 |
|
118 |
|
119 |
|
120 |
private:
|
121 |
boost::mutex joint_ts_position_map_access_mutex; |
122 |
boost::mutex joint_ts_speed_map_access_mutex; |
123 |
joint_tsl_map_t joint_ts_position_map; |
124 |
joint_tsl_map_t joint_ts_speed_map; |
125 |
|
126 |
bool mouth_enabled;
|
127 |
bool gaze_enabled;
|
128 |
unsigned int incoming_position_count; |
129 |
|
130 |
}; |
131 |
|
132 |
} |
133 |
} |