Revision dbf66483

View differences:

include/humotion/server/controller.h
28 28
#ifndef INCLUDE_HUMOTION_SERVER_CONTROLLER_H_
29 29
#define INCLUDE_HUMOTION_SERVER_CONTROLLER_H_
30 30

  
31
#include <string>
31 32
#include <vector>
32 33

  
33 34
#include "humotion/gaze_state.h"
src/server/controller.cpp
139 139
    // check if this timestamp allows a valid conversion:
140 140
    Timestamp history_begin =
141 141
            joint_interface_->get_ts_position(JointInterface::ID_NECK_PAN).get_first_timestamp();
142
    // Timestamp history_end   =
143
    //       joint_interface->get_ts_position(JointInterface::ID_NECK_PAN).get_last_timestamp();
142
    Timestamp history_end   =
143
            joint_interface_->get_ts_position(JointInterface::ID_NECK_PAN).get_last_timestamp();
144 144

  
145 145
    // printf("> incoming: %f, history is %f to %f\n",relative_target_timestamp.to_seconds(),
146 146
    // history_begin.to_seconds(), history_end.to_seconds());
......
152 152
        // therefore we will use the last known targets (see below)
153 153
        // in case we did not see this timestamp before, show a warning:
154 154
        if (last_known_absolute_timestamp_ != relative_target_timestamp) {
155
            printf("> WARNING: restored/guessed absolute target for unknown timestamp %f "
156
                   "[this should only happen during startup]\n", relative_target_timestamp.to_seconds());
155
            printf("> WARNING: restored/guessed absolute target for unknown timestamp %f (tsmap = [%f - %f])"
156
                   "[this should only happen during startup]\n", relative_target_timestamp.to_seconds(),
157
                   history_begin.to_seconds(),
158
                   history_end.to_seconds()
159
                   );
157 160
            last_known_absolute_target_pan_ = 0.0;
158 161
            last_known_absolute_target_tilt_ = 0.0;
159 162
            last_known_absolute_target_roll_ = 0.0;
......
199 202
    // printf("pan  now = %4.1f, rel=%4.1f ===> %4.2f\n", pan, relative.pan, absolute_gaze.pan);
200 203
    // printf("tilt now = %4.1f, rel=%4.1f ===> %4.2f\n", tilt, relative.tilt, absolute_gaze.tilt);
201 204

  
205
    // update the timestamp. this gaze target is now absolute, set appropriate timestamp
206
    //printf("%f %f %f 333\n", absolute_gaze.pan, absolute_gaze.tilt, absolute_gaze.roll);
207
    //absolute_gaze.tilt = 0.0;
208
    //absolute_gaze.roll = 0.0;
209

  
210
    //absolute_gaze.roll = absolute_gaze.pan; //0.012;
211
    absolute_gaze.timestamp = Timestamp::now();
212

  
202 213
    // store debug data:
203 214
    // this is the position we had at the ts of the relative target
204
    store_debug_data("controller/pan_position_at_relative_ts", last_known_absolute_target_pan_);
215
    store_debug_data("controller/pan_neck_position_at_relative_ts", neck_pan);
216
    store_debug_data("controller/pan_overall_position_at_relative_ts", last_known_absolute_target_pan_);
205 217
    // this is the relative movement that was requested
206 218
    store_debug_data("controller/pan_target_relative", relative.pan);
207 219
    // this is the calculated overall target
src/server/joint_interface.cpp
77 77
    // following atomic instructions:
78 78
    mutex::scoped_lock sl(joint_ts_position_map_access_mutex_);
79 79

  
80
    // printf("> humotion: incoming joint position for joint id 0x%02X "
81
    // "= %4.2f (ts=%.2f)\n",joint_id,position,timestamp.to_seconds());
80
    //printf("> humotion: incoming joint position for joint id 0x%02X "
81
    //"= %4.2f (ts=%.2f)\n",joint_id,position,timestamp.to_seconds());
82 82
    joint_ts_position_map_[joint_id].insert(timestamp, position);
83 83

  
84 84
    incoming_position_count_++;
src/server/neck_motion_generator.cpp
141 141
    // get targets: this is the sum of stored neck target and up-to-date offset:
142 142
    float neck_pan_target  = requested_neck_state_.pan  + requested_gaze_state_.pan_offset;
143 143
    float neck_tilt_target = requested_neck_state_.tilt + requested_gaze_state_.tilt_offset;
144

  
144 145
    // roll is always equal to requested gaze (not neck) state
145 146
    float neck_roll_target = requested_gaze_state_.roll + requested_gaze_state_.roll_offset;
146 147

  
147 148
    // add breath wave to tilt
148 149
    neck_tilt_target += get_breath_offset();
149 150

  
151
    //neck_roll_target = 0.0;
152
    //printf("%f %f %f %f ROLL\n", neck_pan_target, neck_roll_target, neck_roll_now, neck_roll_speed);
153

  
150 154
    // pass parameters to reflexxes api
151 155
    setup_neckmotion(0, neck_pan_target,  neck_pan_now,  neck_pan_speed,  neck_pan_ts);
152 156
    setup_neckmotion(1, neck_tilt_target, neck_tilt_now, neck_tilt_speed, neck_tilt_ts);
153 157
    setup_neckmotion(2, neck_roll_target, neck_roll_now, neck_roll_speed, neck_roll_ts);
154 158

  
159

  
155 160
    // call reflexxes to handle profile calculation
156 161
    reflexxes_calculate_profile();
157 162

  
......
168 173
                                reflexxes_position_output->NewPositionVector->VecData[2],
169 174
                                reflexxes_position_output->NewVelocityVector->VecData[2]);
170 175

  
176
    //printf("%f %f %f RRR\n", );
177

  
171 178
    /*printf("\n%f %f %f %f %f DBG\n",
172 179
            neck_pan_now, neck_pan_target,
173 180
            reflexxes_position_output->NewPositionVector->VecData[0],
174
            joint_interface->get_ts_speed(JointInterface::ID_NECK_PAN).get_newest_value(),
181
            joint_interface_->get_ts_speed(JointInterface::ID_NECK_PAN).get_newest_value(),
175 182
            reflexxes_position_output->NewVelocityVector->VecData[0]
176 183
            );*/
177 184

  
......
216 223
    // get distance to target
217 224
    float distance_abs = fabs(target - current_position);
218 225

  
226

  
219 227
    // get max speed: according to the equation Hmax from [guitton87] there is a linear relation
220 228
    // between distance_abs and v_max_head:
221 229
    // v_max = 4.39 * d_total + 106.0 (in degrees)
......
226 234
    max_velocity = fmin(max_velocity, config->limit_velocity_neck);
227 235

  
228 236
    // max accel: assuming linear acceleration we have:
237

  
229 238
    /* v ^  _
230 239
    *   |  / \
231 240
    *   | /   \
......
239 248
    // d_total = a * 2 * d_total / (v_max^2)
240 249
    // and therefore
241 250
    // a = v_max^2 / d_total
242
    float max_accel = 0.0;
251
    float max_accel = 1.0;
243 252

  
244 253
    if (distance_abs > 0.0) {
245 254
        max_accel = pow(max_velocity, 2) / distance_abs;
......
250 259
    max_accel = fmin(max_accel, config->limit_acceleration_neck);
251 260

  
252 261
    // printf("MAX SPEED %4.2f / max accel %4.2f\n",max_speed, max_accel);
262
    // printf("%f %f %f ", distance_abs, max_velocity, max_accel);
253 263

  
254 264
    // feed reflexxes api with data
255 265
    reflexxes_set_input(dof, target, current_position, current_velocity,
src/server/reflexxes_motion_generator.cpp
42 42

  
43 43
    // synchronize phase
44 44
    reflexxes_motion_flags.SynchronizationBehavior =
45
            //RMLPositionFlags::NO_SYNCHRONIZATION;
45 46
            RMLPositionFlags::PHASE_SYNCHRONIZATION_IF_POSSIBLE;
46 47
}
47 48

  
src/timestamped_list.cpp
34 34

  
35 35
TimestampedList::TimestampedList(unsigned int s) {
36 36
    // initialize the list to its desired size:
37
    TimestampedFloat now;
37
    TimestampedFloat now(Timestamp::now(), 0.0);
38 38
    tsf_list_.resize(s, now);
39 39
}
40 40

  

Also available in: Unified diff