Statistics
| Branch: | Tag: | Revision:

humotion / examples / yarp_icub / src / icub_jointinterface.cpp @ 5cd4364c

History | View | Annotate | Download (20.952 KB)

1
/*
2
* This file is part of humotion
3
*
4
* Copyright(c) sschulz <AT> techfak.uni-bielefeld.de
5
* http://opensource.cit-ec.de/projects/humotion
6
*
7
* This file may be licensed under the terms of the
8
* GNU Lesser General Public License Version 3 (the ``LGPL''),
9
* or (at your option) any later version.
10
*
11
* Software distributed under the License is distributed
12
* on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
13
* express or implied. See the LGPL for the specific language
14
* governing rights and limitations.
15
*
16
* You should have received a copy of the LGPL along with this
17
* program. If not, go to http://www.gnu.org/licenses/lgpl.html
18
* or write to the Free Software Foundation, Inc.,
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
*
21
* The development of this software was supported by the
22
* Excellence Cluster EXC 277 Cognitive Interaction Technology.
23
* The Excellence Cluster EXC 277 is a grant of the Deutsche
24
* Forschungsgemeinschaft (DFG) in the context of the German
25
* Excellence Initiative.
26
*/
27

    
28
#include "humotion_yarp_icub/icub_faceinterface.h"
29
#include "humotion_yarp_icub/icub_jointinterface.h"
30

    
31
#include <yarp/os/Property.h>
32
#include <string>
33

    
34
using std::cout;
35
using std::cerr;
36
using std::string;
37

    
38
//! constructor
39
iCubJointInterface::iCubJointInterface(string _scope) : humotion::server::JointInterface() {
40
    scope = _scope;
41

    
42
    // running in sim?
43
    if (scope == "/icubSim") {
44
        cout << "> icub simulation detected\n";
45
        running_in_simulation_ = true;
46
    } else {
47
        running_in_simulation_ = false;
48
    }
49

    
50

    
51
    // add mappings from icub ids to humotion ids
52
    init_id_map();
53

    
54
    // initialise the pd controller for the velocity and position mixer
55
    init_pv_mix_pid();
56

    
57
    // intantiate the face interface
58
    face_interface_ = new iCubFaceInterface(scope);
59

    
60
    // intantiate the polydriver
61
    yarp::os::Property options;
62
    options.put("device", "remote_controlboard");
63
    options.put("local", "/local/head");
64
    options.put("remote", scope + "/head");
65
    yarp_polydriver_.open(options);
66

    
67
    // fetch yarp views:
68
    bool success = true;
69
    // success &= yarp_polydriver_.view(yarp_iencs_);
70
    success &= yarp_polydriver_.view(yarp_ipos_);
71
    success &= yarp_polydriver_.view(yarp_ivel_);
72
    success &= yarp_polydriver_.view(yarp_ilimits_);
73
    success &= yarp_polydriver_.view(yarp_pid_);
74
    success &= yarp_polydriver_.view(yarp_amp_);
75

    
76
    if (!success) {
77
        cout << "ERROR: failed to fetch one or more yarp views... exiting\n";
78
        exit(EXIT_FAILURE);
79
    }
80

    
81

    
82
    // tell humotion about min/max joint values:
83
    init_joints();
84

    
85
    // initialise joint controller
86
    init_controller();
87
}
88

    
89
//! destructor
90
iCubJointInterface::~iCubJointInterface() {
91
    // stop controller on exit
92
    yarp_ivel_->stop();
93
    yarp_ipos_->stop();
94
}
95

    
96
//! init the controller that allows to write target angles or velocities
97
void iCubJointInterface::init_controller() {
98
    int number_of_joints;
99

    
100
    if (running_in_simulation_) {
101
        // running in simulation, use position control mode as velocity seems unsupported right now
102
        yarp_ipos_->getAxes(&number_of_joints);
103

    
104
        // prepare to set ref accel
105
        // yarp_commands_.resize(number_of_joints);
106
        // yarp_commands_ = 200000.0;
107
        // yarp_ipos_->setRefAccelerations(yarp_commands_.data());
108

    
109
        // enable position control
110
        yarp_ipos_->setPositionMode();
111
    } else {
112
        // use velocity controller, first fetch no of axes:
113
        yarp_ivel_->getAxes(&number_of_joints);
114

    
115
        // set ref acceleration to a value for all axes:
116
        yarp_commands_.resize(number_of_joints);
117
        yarp_commands_ = 1e6;
118
        yarp_ivel_->setRefAccelerations(yarp_commands_.data());
119

    
120
        // finally enable velocity control mode
121
        yarp_ivel_->setVelocityMode();
122
    }
123
}
124

    
125
//! initialise icub joint id to humotion joint id mappings
126
void iCubJointInterface::init_id_map() {
127
        insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_LEFT_UPPER,   ID_LIP_LEFT_UPPER);
128
        insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_LEFT_LOWER,   ID_LIP_LEFT_LOWER);
129
        insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_CENTER_UPPER, ID_LIP_CENTER_UPPER);
130
        insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_CENTER_LOWER, ID_LIP_CENTER_LOWER);
131
        insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_RIGHT_UPPER,  ID_LIP_RIGHT_UPPER);
132
        insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_RIGHT_LOWER,  ID_LIP_RIGHT_LOWER);
133
        insert_icupid_to_humotionid_mapping(ICUB_ID_NECK_PAN,    ID_NECK_PAN);
134
        insert_icupid_to_humotionid_mapping(ICUB_ID_NECK_TILT,   ID_NECK_TILT);
135
        insert_icupid_to_humotionid_mapping(ICUB_ID_NECK_ROLL,   ID_NECK_ROLL);
136
        //
137
        insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_PAN,   ID_EYES_LEFT_LR);
138
        insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_VERGENCE,   ID_EYES_RIGHT_LR);
139
        insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_BOTH_UD,   ID_EYES_BOTH_UD);
140
        insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_LEFT_LID_LOWER, ID_EYES_LEFT_LID_LOWER);
141
        insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_LEFT_LID_UPPER, ID_EYES_LEFT_LID_UPPER);
142
        insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_LEFT_BROW, ID_EYES_LEFT_BROW);
143
        insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_RIGHT_LID_LOWER, ID_EYES_RIGHT_LID_LOWER);
144
        insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_RIGHT_LID_UPPER, ID_EYES_RIGHT_LID_UPPER);
145
        insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_RIGHT_BROW, ID_EYES_RIGHT_BROW);
146
}
147

    
148
//! initialize the position and velocity mixer PD controller
149
void iCubJointInterface::init_pv_mix_pid() {
150
    // init control variables and last error variable for the internal
151
    // position and velocity mixer PD controller:
152
    pv_mix_pid_p_.resize(ICUB_JOINT_ID_ENUM_SIZE);
153
    pv_mix_pid_d_.resize(ICUB_JOINT_ID_ENUM_SIZE);
154
    pv_mix_last_error_.resize(ICUB_JOINT_ID_ENUM_SIZE);
155

    
156
    enum_id_bimap_t::const_iterator it;
157
    for (it = enum_id_bimap.begin(); it != enum_id_bimap.end(); ++it) {
158
        int id = it->left;
159
        pv_mix_pid_p_[id] = 5.5;
160
        pv_mix_pid_d_[id] = 0.3;
161
        pv_mix_last_error_[id] = 0.0;
162
    }
163
}
164

    
165
//! add mapping from icub joint ids to humotion ids
166
//! this might look strange at the first sight but we need to have a generic
167
//! way to acces joints from libhumotion. therefore the lib uses its enum with ID_* enum ids
168
//! to access the joints. now we need to define a mapping to map those to the icub motor ids.
169
void iCubJointInterface::insert_icupid_to_humotionid_mapping(int icubid, int humotionid) {
170
    enum_id_bimap.insert(enum_id_bimap_entry_t(icubid, humotionid));
171
}
172

    
173
void iCubJointInterface::run() {
174
    float loop_duration_ms = 1000.0 / MAIN_LOOP_FREQUENCY;
175
    iCubDataReceiver *data_receiver = new iCubDataReceiver(loop_duration_ms, this);
176
    data_receiver->start();
177
}
178

    
179
//! stores the target position & velocity of a given joint
180
//! \param enum id of joint
181
//! \param float value
182
void iCubJointInterface::publish_target(int humotion_id, float position, float velocity) {
183
    // special handler for eye joints
184
    if ((humotion_id == JointInterface::ID_EYES_LEFT_LR) ||
185
        (humotion_id == JointInterface::ID_EYES_RIGHT_LR)) {
186
        // the icub has a combined pan angle for both eyes, so seperate this:
187
        float target_position_left  = get_target_position(JointInterface::ID_EYES_LEFT_LR);
188
        float target_position_right = get_target_position(JointInterface::ID_EYES_RIGHT_LR);
189
        float target_velocity_left  = get_target_velocity(JointInterface::ID_EYES_LEFT_LR);
190
        float target_velocity_right = get_target_velocity(JointInterface::ID_EYES_RIGHT_LR);
191

    
192

    
193
        // calculate target angles
194
        float target_position_pan      = (target_position_right + target_position_left) / 2;
195
        float target_position_vergence = (target_position_right - target_position_left);
196

    
197
        /*cout << "LR " << target_position_left << " " << target_position_right <<
198
                " PAN " << target_position_pan << " VERGENCE " << target_position_vergence << "\n";*/
199

    
200
        // calculate target velocities
201
        // for now just use the same velocity for pan and vergence
202
        float target_velocity_pan = (target_velocity_left + target_velocity_right) / 2.0;
203
        float target_velocity_vergence = target_velocity_left - target_velocity_right;
204

    
205
        store_icub_joint_target(ICUB_ID_EYES_PAN,
206
                                target_position_pan, target_velocity_pan);
207
        store_icub_joint_target(ICUB_ID_EYES_VERGENCE,
208
                                target_position_vergence, target_velocity_vergence);
209
    } else {
210
        // convert to icub joint id
211
        int icub_id = convert_humotion_jointid_to_icub(humotion_id);
212
        // store target data
213
        store_icub_joint_target(icub_id, position, velocity);
214
    }
215
}
216

    
217

    
218
//! set the target data for a given icub joint
219
//! \param id of joint
220
//! \param float value of position
221
void iCubJointInterface::store_icub_joint_target(int icub_id, float position, float velocity) {
222
    // cout << "store_icub_joint_target(" << icub_id << ", " << position << ", ..)\n";
223

    
224
    if ((icub_id == ICUB_ID_NECK_PAN) || (icub_id == ICUB_ID_EYES_VERGENCE)) {
225
        // icub uses an inverted neck pan specification
226
        position = -position;
227
        velocity = -velocity;
228
    }
229

    
230
    // store values
231
    target_angle_[icub_id] = position;
232
    target_velocity_[icub_id] = velocity;
233
}
234

    
235
//! execute a move in velocity mode
236
//! \param id of joint
237
//! \param angle
238
void iCubJointInterface::set_target_in_velocitymode(int icub_id) {
239
    // fetch humotion id from icub joint id
240
    int humotion_id = convert_icub_jointid_to_humotion(icub_id);
241

    
242
    // fetch the target velocity
243
    float target_velocity = target_velocity_[icub_id];
244

    
245
    float vmax = 350.0;
246
    if (target_velocity > vmax)  target_velocity = vmax;
247
    if (target_velocity < -vmax) target_velocity = -vmax;
248

    
249
    // execute:
250
    if ((icub_id != ICUB_ID_NECK_PAN)
251
        && (icub_id != ICUB_ID_EYES_BOTH_UD)
252
        && (icub_id != ICUB_ID_NECK_TILT)
253
        && (icub_id != ICUB_ID_EYES_PAN)
254
        && (icub_id != ICUB_ID_EYES_VERGENCE)
255
        // && (icub_id != ICUB_ID_NECK_TILT)
256
            ) {
257
        // limit to some joints for debugging...
258
        return;
259
    }
260

    
261
    // we now add a pd control loop for velocity moves in order to handle position errors
262
    // FIXME: add position interpolation into future. this requires to enable the velocity
263
    //        broadcast in the torso and head ini file and fetch that velocity in the
264
    //        icub_data_receiver as well. TODO: check if the can bus has enough bandwidth for that
265

    
266
    // first: fetch the timstamp of the last known position
267
    humotion::Timestamp data_ts = get_ts_position(humotion_id).get_last_timestamp();
268

    
269
    // fetch current position & velocity
270
    float current_position = get_ts_position(humotion_id).get_interpolated_value(data_ts);
271
    float current_velocity = get_ts_speed(humotion_id).get_interpolated_value(data_ts);
272

    
273
    // the icub has a combined eye pan actuator, therefore
274
    // we have to calculate pan angle and vergence based on the left and right target angles:
275
    if (icub_id == ICUB_ID_EYES_PAN) {
276
        // fetch timestamp
277
        data_ts = get_ts_position(ID_EYES_LEFT_LR).get_last_timestamp();
278

    
279
        // get the left and right positions
280
        float pos_left  = get_ts_position(ID_EYES_LEFT_LR).get_interpolated_value(data_ts);
281
        float pos_right = get_ts_position(ID_EYES_RIGHT_LR).get_interpolated_value(data_ts);
282
        current_position = (pos_left + pos_right) / 2.0;
283

    
284
        // same for velocities:
285
        float vel_left  = get_ts_speed(ID_EYES_LEFT_LR).get_interpolated_value(data_ts);
286
        float vel_right = get_ts_speed(ID_EYES_RIGHT_LR).get_interpolated_value(data_ts);
287
        current_velocity = (vel_left + vel_right) / 2.0;
288

    
289
    } else if (icub_id == ICUB_ID_EYES_VERGENCE) {
290
        // fetch timestamp
291
        data_ts = get_ts_position(ID_EYES_LEFT_LR).get_last_timestamp();
292

    
293
        // get the left and right positions
294
        float pos_left  = get_ts_position(ID_EYES_LEFT_LR).get_interpolated_value(data_ts);
295
        float pos_right = get_ts_position(ID_EYES_RIGHT_LR).get_interpolated_value(data_ts);
296

    
297
        current_position = pos_left - pos_right;
298

    
299
        // same for velocities:
300
        float vel_left  = get_ts_speed(ID_EYES_LEFT_LR).get_interpolated_value(data_ts);
301
        float vel_right = get_ts_speed(ID_EYES_RIGHT_LR).get_interpolated_value(data_ts);
302
        current_velocity = (vel_left - vel_right);
303
    }
304

    
305
    // calculate position error:
306
    float position_error = target_angle_[icub_id] - current_position;
307

    
308
    // calculate d term
309
    float error_d = (position_error - pv_mix_last_error_[icub_id]) / (framerate*1000.0);
310
    pv_mix_last_error_[icub_id] = position_error;
311

    
312
    // finally do a PD loop to get the target velocity
313
    float pv_mix_velocity = pv_mix_pid_p_[icub_id] * position_error
314
                            + pv_mix_pid_p_[icub_id]*error_d
315
                            + target_velocity;
316

    
317

    
318
    /*cout << "\n"
319
         << current_position << " "
320
         << target_angle_[icub_id] << " "
321
         << current_velocity << " "
322
         << pv_mix_velocity  << " "
323
         << target_velocity  << " "
324
         << position_error << " "
325
         << " PID" << icub_id << "\n";*/
326

    
327

    
328
    if (icub_id > ICUB_ID_EYES_VERGENCE) {
329
        cerr << "> ERROR: set_target_positionmode(id=" << icub_id << ", ...) not supported\n";
330
        return;
331
    }
332

    
333

    
334
    // execute velocity move
335
    bool success;
336
    int count = 0;
337
    do {
338
        if (running_in_simulation_) {
339
            // running in sim, use position control
340
            success = yarp_ipos_->positionMove(icub_id, target_angle_[icub_id]);
341
        } else {
342
            // use smooth velocity control on real robot
343
            success = yarp_ivel_->velocityMove(icub_id, pv_mix_velocity);
344
        }
345

    
346
        if (count++ >= 10) {
347
            cerr << "ERROR: failed to send motion command! gave up after 10 trials\n";
348
            yarp_ivel_->stop();
349
            yarp_ipos_->stop();
350
            exit(EXIT_FAILURE);
351
        }
352
    } while (!success);
353
}
354

    
355
//! actually execute the scheduled motion commands
356
void iCubJointInterface::execute_motion() {
357
    // set up neck and eye motion commands in velocitymode
358
    for (int i = ICUB_ID_NECK_TILT; i <= ICUB_ID_EYES_VERGENCE; i++) {
359
        set_target_in_velocitymode(i);
360
    }
361

    
362
    // eyelids: unfortuantely the icub has only 1dof for eyelids
363
    // therefore we can only use an opening value
364
    float opening_left  = target_angle_[ICUB_ID_EYES_LEFT_LID_UPPER]
365
                          - target_angle_[ICUB_ID_EYES_LEFT_LID_LOWER];
366
    float opening_right = target_angle_[ICUB_ID_EYES_RIGHT_LID_UPPER]
367
                          - target_angle_[ICUB_ID_EYES_RIGHT_LID_LOWER];
368
    float opening = (opening_left + opening_right) / 2.0;
369
    // send it to icub face if
370
    face_interface_->set_eyelid_angle(opening);
371

    
372
    // eyebrows are set using a special command as well:
373
    face_interface_->set_eyebrow_angle(ICUB_ID_EYES_LEFT_BROW, target_angle_);
374
    face_interface_->set_eyebrow_angle(ICUB_ID_EYES_RIGHT_BROW, target_angle_);
375

    
376
    // mouth
377
    face_interface_->set_mouth(target_angle_);
378

    
379
    // store joint values which we do not handle on icub here:
380
    humotion::Timestamp timestamp = humotion::Timestamp::now();
381

    
382
    JointInterface::store_incoming_position(ID_LIP_LEFT_UPPER,
383
                                            target_angle_[ICUB_ID_LIP_LEFT_UPPER], timestamp);
384
    JointInterface::store_incoming_position(ID_LIP_LEFT_LOWER,
385
                                            target_angle_[ICUB_ID_LIP_LEFT_LOWER], timestamp);
386
    JointInterface::store_incoming_position(ID_LIP_CENTER_UPPER,
387
                                            target_angle_[ICUB_ID_LIP_CENTER_UPPER], timestamp);
388
    JointInterface::store_incoming_position(ID_LIP_CENTER_LOWER,
389
                                            target_angle_[ICUB_ID_LIP_CENTER_LOWER], timestamp);
390
    JointInterface::store_incoming_position(ID_LIP_RIGHT_UPPER,
391
                                            target_angle_[ICUB_ID_LIP_RIGHT_UPPER], timestamp);
392
    JointInterface::store_incoming_position(ID_LIP_RIGHT_LOWER,
393
                                            target_angle_[ICUB_ID_LIP_RIGHT_LOWER], timestamp);
394
}
395

    
396

    
397
void iCubJointInterface::set_joint_enable_state(int humotion_id, bool enable) {
398
    int icub_jointid = convert_humotion_jointid_to_icub(humotion_id);
399
/*
400
    switch(e){
401
        default:
402
            break;
403

404
    case(ID_NECK_PAN):
405
        icub_jointid = ICUB_ID_NECK_PAN;
406
        break;
407

408
    case(ID_NECK_TILT):
409
        icub_jointid = ICUB_ID_NECK_TILT;
410
        break;
411

412
    case(ID_NECK_ROLL):
413
        icub_jointid = ICUB_ID_NECK_ROLL;
414
        break;
415

416
    case(ID_EYES_BOTH_UD):
417
        icub_jointid = ICUB_ID_EYES_BOTH_UD;
418
        break;
419

420
    // icub handles eyes as pan angle + vergence...
421
    // -> hack: left eye enables pan and right eye enables vergence
422
    case(ID_EYES_LEFT_LR):
423
        icub_jointid = ICUB_ID_EYES_PAN;
424
        break;
425

426
    case(ID_EYES_RIGHT_LR):
427
        icub_jointid = ICUB_ID_EYES_VERGENCE;
428
        break;
429
    }
430
    */
431

    
432
    if ((icub_jointid != -1) && (icub_jointid <= ICUB_ID_EYES_VERGENCE)) {
433
        if (!running_in_simulation_) {
434
            // only set amp status on real robot. simulation crashes during this call ... :-X
435
            if (enable) {
436
                yarp_amp_->enableAmp(icub_jointid);
437
                yarp_pid_->enablePid(icub_jointid);
438
            } else {
439
                yarp_pid_->disablePid(icub_jointid);
440
                yarp_amp_->disableAmp(icub_jointid);
441
            }
442
        }
443
    }
444
}
445

    
446
//! prepare and enable a joint
447
//! NOTE: this should also prefill the min/max positions for this joint
448
//! \param the enum id of a joint
449
void iCubJointInterface::enable_joint(int e) {
450
    set_joint_enable_state(e, true);
451
}
452

    
453
//! shutdown and disable a joint
454
//! \param the enum id of a joint
455
void iCubJointInterface::disable_joint(int e)  {
456
    set_joint_enable_state(e, false);
457
}
458

    
459
void iCubJointInterface::store_min_max(yarp::dev::IControlLimits *ilimits, int icub_id) {
460
    double min, max;
461
    int humotion_id = convert_icub_jointid_to_humotion(icub_id);
462

    
463
    if (!ilimits->getLimits(icub_id, &min, &max)) {
464
        cerr << "ERROR: failed to call getLimits for icub joint " << icub_id << "\n";
465
        exit(EXIT_FAILURE);
466
    }
467

    
468
    joint_min[humotion_id] = min;
469
    joint_max[humotion_id] = max;
470
}
471

    
472
//! initialise a joint (set up controller mode etc)
473
void iCubJointInterface::init_joints() {
474
    store_min_max(yarp_ilimits_, ICUB_ID_NECK_TILT);
475
    store_min_max(yarp_ilimits_, ICUB_ID_NECK_ROLL);
476
    store_min_max(yarp_ilimits_, ICUB_ID_NECK_PAN);
477
    store_min_max(yarp_ilimits_, ICUB_ID_EYES_BOTH_UD);
478

    
479
    // icub handles eyes differently, we have to set pan angle + vergence
480
    double pan_min, pan_max, vergence_min, vergence_max;
481
    yarp_ilimits_->getLimits(ICUB_ID_EYES_PAN, &pan_min, &pan_max);
482
    yarp_ilimits_->getLimits(ICUB_ID_EYES_VERGENCE, &vergence_min, &vergence_max);
483

    
484
    // this is not 100% correct, should be fixed
485
    joint_min[ID_EYES_LEFT_LR] = pan_min;  // - vergence_max/2;
486
    joint_max[ID_EYES_LEFT_LR] = pan_max;  // - vergence_max/2;
487
    joint_min[ID_EYES_RIGHT_LR] = joint_min[ID_EYES_LEFT_LR];
488
    joint_max[ID_EYES_RIGHT_LR] = joint_max[ID_EYES_LEFT_LR];
489

    
490
    // eyelids
491
    joint_min[ID_EYES_RIGHT_LID_UPPER] = -50;  // 24-30;
492
    joint_max[ID_EYES_RIGHT_LID_UPPER] = 50;   // 48-30;
493
    // lid_angle = joint_max[ID_EYES_RIGHT_LID_UPPER];
494

    
495
    // eyebrows
496
    joint_min[ID_EYES_LEFT_BROW] = -50;
497
    joint_max[ID_EYES_LEFT_BROW] = 50;
498
    joint_min[ID_EYES_RIGHT_BROW] = joint_min[ID_EYES_LEFT_BROW];
499
    joint_max[ID_EYES_RIGHT_BROW] = joint_max[ID_EYES_LEFT_BROW];
500

    
501
    // mouth
502
    joint_min[ID_LIP_CENTER_UPPER] = 5;
503
    joint_max[ID_LIP_CENTER_UPPER] = 50;
504
    joint_min[ID_LIP_CENTER_LOWER] = 5;
505
    joint_max[ID_LIP_CENTER_LOWER] = 50;
506
    joint_min[ID_LIP_LEFT_UPPER] = 5;
507
    joint_max[ID_LIP_LEFT_UPPER] = 50;
508
    joint_min[ID_LIP_LEFT_LOWER] = 5;
509
    joint_max[ID_LIP_LEFT_LOWER] = 50;
510
    joint_min[ID_LIP_RIGHT_UPPER] = 5;
511
    joint_max[ID_LIP_RIGHT_UPPER] = 50;
512
    joint_min[ID_LIP_RIGHT_LOWER] = 5;
513
    joint_max[ID_LIP_RIGHT_LOWER] = 50;
514
}
515

    
516
//! conversion table for humotion joint id to icub joint id
517
//! \param int value for humotion joint id from JointInterface::JOINT_ID_ENUM
518
//! \return int value of icub joint id
519
int iCubJointInterface::convert_humotion_jointid_to_icub(int humotion_id) {
520
    enum_id_bimap_t::right_const_iterator it = enum_id_bimap.right.find(humotion_id);
521
    if (it == enum_id_bimap.right.end()) {
522
        // key does not exist
523
        cerr << "ERROR: invalid humotion joint id (" << humotion_id <<
524
                ") given. can not convert this. exiting\n";
525
        exit(EXIT_FAILURE);
526
    }
527
    return it->second;
528
}
529

    
530

    
531
//! conversion table for icub joint id to humotion joint id
532
//! \param  int value of icub joint id
533
//! \return int value of humotion joint id from JointInterface::JOINT_ID_ENUM
534
int iCubJointInterface::convert_icub_jointid_to_humotion(int icub_id) {
535
    enum_id_bimap_t::left_const_iterator it = enum_id_bimap.left.find(icub_id);
536
    if (it == enum_id_bimap.left.end()) {
537
        // key does not exist
538
        cout << "ERROR: invalid icub joint id given. can not convert this. exiting\n";
539
        exit(EXIT_FAILURE);
540
    }
541
    return it->second;
542
}
543