Statistics
| Branch: | Tag: | Revision:

humotion / examples / yarp_icub / src / icub_jointinterface.cpp @ 14831938

History | View | Annotate | Download (20.955 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

    
174

    
175

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

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

    
195

    
196
        // calculate target angles
197
        float target_position_pan      = (target_position_right + target_position_left) / 2;
198
        float target_position_vergence = (target_position_right - target_position_left);
199

    
200
        /*cout << "LR " << target_position_left << " " << target_position_right <<
201
                " PAN " << target_position_pan << " VERGENCE " << target_position_vergence << "\n";*/
202

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

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

    
220

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

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

    
233
    // store values
234
    target_angle_[icub_id] = position;
235
    target_velocity_[icub_id] = velocity;
236
}
237

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

    
245
    // fetch the target velocity
246
    float target_velocity = target_velocity_[icub_id];
247

    
248
    float vmax = 350.0;
249
    if (target_velocity > vmax)  target_velocity = vmax;
250
    if (target_velocity < -vmax) target_velocity = -vmax;
251

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

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

    
269
    // first: fetch the timstamp of the last known position
270
    humotion::Timestamp data_ts = get_ts_position(humotion_id).get_last_timestamp();
271

    
272
    // fetch current position & velocity
273
    float current_position = get_ts_position(humotion_id).get_interpolated_value(data_ts);
274
    float current_velocity = get_ts_speed(humotion_id).get_interpolated_value(data_ts);
275

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

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

    
287
        // same for velocities:
288
        float vel_left  = get_ts_speed(ID_EYES_LEFT_LR).get_interpolated_value(data_ts);
289
        float vel_right = get_ts_speed(ID_EYES_RIGHT_LR).get_interpolated_value(data_ts);
290
        current_velocity = (vel_left + vel_right) / 2.0;
291

    
292
    } else if (icub_id == ICUB_ID_EYES_VERGENCE) {
293
        // fetch timestamp
294
        data_ts = get_ts_position(ID_EYES_LEFT_LR).get_last_timestamp();
295

    
296
        // get the left and right positions
297
        float pos_left  = get_ts_position(ID_EYES_LEFT_LR).get_interpolated_value(data_ts);
298
        float pos_right = get_ts_position(ID_EYES_RIGHT_LR).get_interpolated_value(data_ts);
299

    
300
        current_position = pos_left - pos_right;
301

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

    
308
    // calculate position error:
309
    float position_error = target_angle_[icub_id] - current_position;
310

    
311
    // calculate d term
312
    float error_d = (position_error - pv_mix_last_error_[icub_id]) / (framerate*1000.0);
313
    pv_mix_last_error_[icub_id] = position_error;
314

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

    
320

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

    
330

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

    
336

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

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

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

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

    
375
    // eyebrows are set using a special command as well:
376
    face_interface_->set_eyebrow_angle(ICUB_ID_EYES_LEFT_BROW, target_angle_);
377
    face_interface_->set_eyebrow_angle(ICUB_ID_EYES_RIGHT_BROW, target_angle_);
378

    
379
    // mouth
380
    face_interface_->set_mouth(target_angle_);
381

    
382
    // store joint values which we do not handle on icub here:
383
    humotion::Timestamp timestamp = humotion::Timestamp::now();
384

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

    
399

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

407
    case(ID_NECK_PAN):
408
        icub_jointid = ICUB_ID_NECK_PAN;
409
        break;
410

411
    case(ID_NECK_TILT):
412
        icub_jointid = ICUB_ID_NECK_TILT;
413
        break;
414

415
    case(ID_NECK_ROLL):
416
        icub_jointid = ICUB_ID_NECK_ROLL;
417
        break;
418

419
    case(ID_EYES_BOTH_UD):
420
        icub_jointid = ICUB_ID_EYES_BOTH_UD;
421
        break;
422

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

429
    case(ID_EYES_RIGHT_LR):
430
        icub_jointid = ICUB_ID_EYES_VERGENCE;
431
        break;
432
    }
433
    */
434

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

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

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

    
462
void iCubJointInterface::store_min_max(yarp::dev::IControlLimits *ilimits, int icub_id) {
463
    double min, max;
464
    int humotion_id = convert_icub_jointid_to_humotion(icub_id);
465

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

    
471
    joint_min[humotion_id] = min;
472
    joint_max[humotion_id] = max;
473
}
474

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

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

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

    
493
    // eyelids
494
    joint_min[ID_EYES_RIGHT_LID_UPPER] = -50;  // 24-30;
495
    joint_max[ID_EYES_RIGHT_LID_UPPER] = 50;   // 48-30;
496
    // lid_angle = joint_max[ID_EYES_RIGHT_LID_UPPER];
497

    
498
    // eyebrows
499
    joint_min[ID_EYES_LEFT_BROW] = -50;
500
    joint_max[ID_EYES_LEFT_BROW] = 50;
501
    joint_min[ID_EYES_RIGHT_BROW] = joint_min[ID_EYES_LEFT_BROW];
502
    joint_max[ID_EYES_RIGHT_BROW] = joint_max[ID_EYES_LEFT_BROW];
503

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

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

    
533

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