Revision 0d0f5ca1 src/server/neck_motion_generator.cpp

View differences:

src/server/neck_motion_generator.cpp
95 95
    float neck_pan_now  = get_current_position(JointInterface::ID_NECK_PAN);
96 96
    float neck_tilt_now = get_current_position(JointInterface::ID_NECK_TILT);
97 97
    float neck_roll_now = get_current_position(JointInterface::ID_NECK_ROLL);
98
    // fetch current velocities
99
    float neck_pan_speed  = get_current_speed(JointInterface::ID_NECK_PAN);
100
    float neck_tilt_speed = get_current_speed(JointInterface::ID_NECK_TILT);
101
    float neck_roll_speed = get_current_speed(JointInterface::ID_NECK_ROLL);
98 102

  
99 103
    //reached target?
100 104
    float goal_diff   = fabs(get_current_gaze().distance_pt_abs(requested_gaze_state));
......
143 147
    neck_tilt_target += get_breath_offset();
144 148

  
145 149
    //pass parameters to reflexxes api:
146
    setup_neckmotion(0, neck_pan_target,  neck_pan_now);
147
    setup_neckmotion(1, neck_tilt_target, neck_tilt_now);
148
    setup_neckmotion(2, neck_roll_target, neck_roll_now);
150
    setup_neckmotion(0, neck_pan_target,  neck_pan_now, neck_pan_speed);
151
    setup_neckmotion(1, neck_tilt_target, neck_tilt_now, neck_tilt_speed);
152
    setup_neckmotion(2, neck_roll_target, neck_roll_now, neck_roll_speed);
149 153

  
150 154
    //call reflexxes to handle profile calculation:
151 155
    reflexxes_calculate_profile();
......
158 162
    joint_interface->set_target_position(JointInterface::ID_NECK_TILT,
159 163
                                         reflexxes_position_output->NewPositionVector->VecData[1],
160 164
                                         reflexxes_position_output->NewVelocityVector->VecData[1]);
165

  
161 166
    joint_interface->set_target_position(JointInterface::ID_NECK_ROLL,
162 167
                                         reflexxes_position_output->NewPositionVector->VecData[2],
163 168
                                         reflexxes_position_output->NewVelocityVector->VecData[2]);
169

  
170
    printf("\n%f %f %f %f %f %f DBG\n",
171
            neck_pan_now, neck_pan_target,
172
            reflexxes_position_output->NewPositionVector->VecData[0],
173
            joint_interface->get_ts_speed(JointInterface::ID_NECK_PAN).get_newest_value(),
174
            reflexxes_position_output->NewVelocityVector->VecData[0]
175
            );
164 176
}
165 177

  
166 178
//! publish targets to motor boards:
......
179 191
//! \param dof id of joint
180 192
//! \param target angle
181 193
//! \param current angle
182
void NeckMotionGenerator::setup_neckmotion(int dof, float target, float now){
194
void NeckMotionGenerator::setup_neckmotion(int dof, float target, float current_position, float current_speed){
183 195
    //get distance to target:
184
    float distance_abs = fabs(target - now);
196
    float distance_abs = fabs(target - current_position);
185 197

  
186 198
    //get max speed: according to [guitton87] there is a relation between distance_abs and v_max_head:
187 199
    //v_max = 4.39 * d_total + 106.0 (in degrees)
......
216 228
    ///printf("MAX SPEED %4.2f / max accel %4.2f\n",max_speed, max_accel);
217 229

  
218 230
    //feed reflexxes api with data
219
    reflexxes_set_input(dof, target, now, max_speed, max_accel);
231
    reflexxes_set_input(dof, target, current_position, current_speed, max_speed, max_accel);
220 232
}

Also available in: Unified diff