Revision 4b77b008 src/server/controller.cpp
src/server/controller.cpp | ||
---|---|---|
25 | 25 |
* Excellence Initiative. |
26 | 26 |
*/ |
27 | 27 |
|
28 |
#include <string> |
|
29 |
|
|
28 | 30 |
#include "humotion/server/controller.h" |
29 | 31 |
#include "humotion/server/eye_motion_generator.h" |
30 | 32 |
#include "humotion/server/eyebrow_motion_generator.h" |
... | ... | |
33 | 35 |
#include "humotion/server/neck_motion_generator.h" |
34 | 36 |
#include "humotion/timestamp.h" |
35 | 37 |
|
38 |
|
|
36 | 39 |
// using namespace std; |
37 | 40 |
// using namespace humotion; |
38 | 41 |
// using namespace humotion::server; |
... | ... | |
100 | 103 |
debug_data.insert(dataset.begin(), dataset.end()); |
101 | 104 |
} |
102 | 105 |
|
106 |
// fetch data from controller as well |
|
107 |
debug_data_t controller_dataset = debug_data_; |
|
108 |
debug_data.insert(controller_dataset.begin(), controller_dataset.end()); |
|
109 |
|
|
103 | 110 |
return debug_data; |
104 | 111 |
} |
105 | 112 |
|
113 |
//! store debug data |
|
114 |
void Controller::store_debug_data(std::string name, float value) { |
|
115 |
debug_data_[name] = value; |
|
116 |
} |
|
117 |
|
|
106 | 118 |
//! publish all target angles to the devices: |
107 | 119 |
//! NOTE: this is done in an extra loop to have a low delay between consequent sets: |
108 | 120 |
void Controller::publish_targets() { |
... | ... | |
114 | 126 |
|
115 | 127 |
humotion::GazeState Controller::relative_gaze_to_absolute_gaze(humotion::GazeState relative) { |
116 | 128 |
double pan, tilt, roll; |
129 |
double neck_pan = 0.0; |
|
130 |
double neck_tilt = 0.0; |
|
131 |
|
|
117 | 132 |
humotion::GazeState absolute_gaze = relative; |
118 | 133 |
|
119 | 134 |
// incoming gaze state wants to set a relative gaze angle |
... | ... | |
146 | 161 |
} else { |
147 | 162 |
// all fine, we can reconstruct the absolute target |
148 | 163 |
// fetch head / camera pose during that timestamp |
149 |
double neck_pan = joint_interface_->get_ts_position(
|
|
164 |
neck_pan = joint_interface_->get_ts_position( |
|
150 | 165 |
JointInterface::ID_NECK_PAN).get_interpolated_value(relative_target_timestamp); |
151 | 166 |
double eye_l_pan = joint_interface_->get_ts_position( |
152 | 167 |
JointInterface::ID_EYES_LEFT_LR).get_interpolated_value(relative_target_timestamp); |
... | ... | |
154 | 169 |
JointInterface::ID_EYES_RIGHT_LR).get_interpolated_value(relative_target_timestamp); |
155 | 170 |
last_known_absolute_target_pan_ = neck_pan + (eye_l_pan + eye_r_pan)/2.0; |
156 | 171 |
// |
157 |
double neck_tilt = joint_interface_->get_ts_position(
|
|
172 |
neck_tilt = joint_interface_->get_ts_position( |
|
158 | 173 |
JointInterface::ID_NECK_TILT).get_interpolated_value(relative_target_timestamp); |
159 | 174 |
double eye_tilt = joint_interface_->get_ts_position( |
160 | 175 |
JointInterface::ID_EYES_BOTH_UD).get_interpolated_value(relative_target_timestamp); |
... | ... | |
176 | 191 |
tilt -= relative.tilt_offset; |
177 | 192 |
roll -= relative.roll_offset; |
178 | 193 |
|
179 |
|
|
180 | 194 |
// build up absolute target |
181 | 195 |
absolute_gaze.gaze_type = GazeState::GAZETYPE_ABSOLUTE; |
182 | 196 |
absolute_gaze.pan = pan + relative.pan; |
183 | 197 |
absolute_gaze.tilt = tilt + relative.tilt; |
184 | 198 |
absolute_gaze.roll = roll + relative.roll; |
185 |
printf("pan now = %4.1f, rel=%4.1f ===> %4.2f\n", pan, relative.pan, absolute_gaze.pan); |
|
186 |
printf("tilt now = %4.1f, rel=%4.1f ===> %4.2f\n", tilt, relative.tilt, absolute_gaze.tilt); |
|
187 |
|
|
199 |
//printf("pan now = %4.1f, rel=%4.1f ===> %4.2f\n", pan, relative.pan, absolute_gaze.pan); |
|
200 |
//printf("tilt now = %4.1f, rel=%4.1f ===> %4.2f\n", tilt, relative.tilt, absolute_gaze.tilt); |
|
201 |
|
|
202 |
// store debug data: |
|
203 |
store_debug_data("controller/last_known_absolute_target_pan", last_known_absolute_target_pan_); |
|
204 |
store_debug_data("controller/pan", pan); |
|
205 |
store_debug_data("controller/neck_pan", neck_pan); |
|
206 |
store_debug_data("controller/absolute_gaze_pan", absolute_gaze.pan); |
|
207 |
// store_debug_data("controller/relative_timestamp", relative_target_timestamp.to_seconds()); |
|
208 |
// printf("BEFORE DBG %f\n", relative.timestamp.to_seconds()); |
|
209 |
std::srand(std::time(0)); // use current time as seed for random generator |
|
210 |
int random_variable = std::rand(); |
|
211 |
store_debug_data("controller/relative_timestamp2", random_variable); |
|
212 |
printf("DBG %i\n", random_variable); |
|
188 | 213 |
// FIXME: use ros TF for that calculation... |
189 | 214 |
// see http://wiki.ros.org/tf/Tutorials/Time%20travel%20with%20tf%20%28C%2B%2B%29 |
190 | 215 |
// ros::Time past = now - ros::Duration(5.0); |
Also available in: Unified diff