Revision 6c028e11 examples/yarp_icub/src/icub_jointinterface.cpp

View differences:

examples/yarp_icub/src/icub_jointinterface.cpp
165 165
        float target_velocity_left  = get_target_velocity(JointInterface::ID_EYES_LEFT_LR);
166 166
        float target_velocity_right = get_target_velocity(JointInterface::ID_EYES_RIGHT_LR);
167 167

  
168

  
168 169
        // calculate target angles
169
        float target_position_pan      = (target_position_left + target_position_right) / 2;
170
        float target_position_vergence = (target_position_left - target_position_right);
170
        float target_position_pan      = (target_position_right + target_position_left) / 2;
171
        float target_position_vergence = (target_position_right - target_position_left);
172

  
173
        cout << "LR " << target_position_left << " " << target_position_right <<
174
                " PAN " << target_position_pan << " VERGENCE " << target_position_vergence << "\n";
171 175

  
172 176
        // calculate target velocities
173 177
        // for now just use the same velocity for pan and vergence
......
192 196
//! \param float value of position
193 197
void iCubJointInterface::store_icub_joint_target(int icub_id, float position, float velocity) {
194 198
    printf("> set icub joint %d -> p = %f, v = %f\n",icub_id,position,velocity);
199
    if (icub_id == ICUB_ID_NECK_PAN) {
200
        // icub uses an inverted neck pan specification
201
        position = -position;
202
        velocity = -velocity;
203
    }
195 204
    target_angle_[icub_id] = position;
196 205
    target_velocity_[icub_id] = velocity;
197 206
}
......
217 226
    assert(!POSITION_CONTROL);
218 227

  
219 228
    // fetch humotion id from icub joint id
220
    int humotion_id = convert_humotion_jointid_to_icub(icub_id);
229
    int humotion_id = convert_icub_jointid_to_humotion(icub_id);
221 230

  
222 231
    // fetch the target velocity
223 232
    float target_velocity = target_velocity_[icub_id];
......
228 237

  
229 238
    //execute:
230 239
    //ivel->velocityMove(id, speed);
231
    if ((icub_id != ICUB_ID_NECK_PAN)  &&
240
    /*if ((icub_id != ICUB_ID_NECK_PAN)  &&
232 241
        (icub_id != ICUB_ID_EYES_BOTH_UD) &&
233 242
        (icub_id != ICUB_ID_NECK_TILT) &&
234 243
        (icub_id != ICUB_ID_EYES_BOTH_UD) &&
235 244
        (icub_id != ICUB_ID_NECK_TILT)) {
236 245
        // limit to some joints for debugging...
237 246
        return;
238
    }
247
    }*/
239 248

  
240 249
    // we now add a pd control loop for velocity moves in order to handle position errors
241 250
    // TODO: add position interpolation into future. this requires to enable the velocity
......
315 324
//! \param id of joint
316 325
//! \param float value of position
317 326
//! \param double timestamp
318
void iCubJointInterface::store_incoming_position(int humotion_id, double value, double timestamp){
319
    JointInterface::store_incoming_position(humotion_id, value, timestamp);
327
void iCubJointInterface::store_incoming_position(int humotion_id, double position, double timestamp){
328
    cout << "iCubJointInterface::store_incoming_position(humotionid=" << humotion_id <<
329
            ", " << position << ", ...)\n";
330

  
331
    JointInterface::store_incoming_position(humotion_id, position, timestamp);
320 332
}
321 333
/*
322 334
    //store joint based on id:

Also available in: Unified diff