Revision 6c028e11

View differences:

examples/yarp_icub/include/icub_jointinterface.h
25 25
    iCubJointInterface(std::string scope);
26 26
    ~iCubJointInterface();
27 27

  
28
    void store_incoming_position(int humotion_id, double value, double timestamp);
28
    void store_incoming_position(int humotion_id, double position, double timestamp);
29 29
    void run();
30 30

  
31 31
    int convert_icub_jointid_to_humotion(int id);
examples/yarp_icub/src/icub_data_receiver.cpp
57 57
}
58 58

  
59 59
void iCubDataReceiver::store_incoming_position(int icub_id, double value, double timestamp) {
60
    cout << "iCubDataReceiver::store_incoming_position(" << icub_id << ", " << value << "..)\n";
60
    cout << "iCubDataReceiver::store_incoming_position(icubid=" << icub_id << ", " << value << "..)\n";
61

  
61 62
    // store joint position in humotion backend
62 63
    if ((icub_id == iCubJointInterface::ICUB_ID_EYES_PAN) ||
63 64
            (icub_id == iCubJointInterface::ICUB_ID_EYES_VERGENCE)) {
......
67 68
        if (icub_id == iCubJointInterface::ICUB_ID_EYES_PAN) {
68 69
            target_eye_pan_ = value;
69 70
        } else {
70
            target_eye_vergence_ = value;
71
            target_eye_vergence_ = -value;
71 72
        }
72 73

  
73 74
        float left  = target_eye_pan_ + target_eye_vergence_/2.0;
......
82 83
        //icub_jointinterface->store_incoming_position(ID_EYES_RIGHT_LID_UPPER,
83 84
        //                                             lid_angle, timestamp);
84 85
    } else {
86
        if (icub_id == iCubJointInterface::ID_NECK_PAN) {
87
            // icub uses an inverted neck pan specification
88
            value = -value;
89
        }
90

  
85 91
        // known configured mapping between joint ids
86 92
        int humotion_id = icub_jointinterface_->convert_icub_jointid_to_humotion(icub_id);
87 93
        icub_jointinterface_->store_incoming_position(humotion_id, value, timestamp);
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