humotion / examples / yarp_icub / src / icub_jointinterface.cpp @ 35b3ca25
History | View | Annotate | Download (19.171 KB)
1 |
#include "icub_jointinterface.h" |
---|---|
2 |
#include "icub_faceinterface.h" |
3 |
|
4 |
#include <yarp/os/Property.h> |
5 |
using namespace yarp::dev; |
6 |
using namespace yarp::sig; |
7 |
using namespace yarp::os; |
8 |
using namespace std; |
9 |
/*running:
|
10 |
/media/local_data/sschulz/iros15/icub-nightly/share/iCub/contexts/simConfig:> iCub_SIM
|
11 |
/media/local_data/sschulz/iros15/icub-nightly/share/iCub/contexts/simFaceExpressions:> ../../../../bin/simFaceExpressions
|
12 |
yarp connect /face/eyelids /icubSim/face/eyelids
|
13 |
yarp connect /face/image/out /icubSim/texture/face
|
14 |
|
15 |
TEST: yarp write /writer /icubSim/face/raw/in
|
16 |
|
17 |
http://wiki.icub.org/wiki/Motor_control
|
18 |
*/
|
19 |
|
20 |
#define POSITION_CONTROL 0 |
21 |
using std::cout;
|
22 |
|
23 |
//! constructor
|
24 |
iCubJointInterface::iCubJointInterface(string _scope) : humotion::server::JointInterface(){
|
25 |
scope = _scope; |
26 |
|
27 |
// add mappings from icub ids to humotion ids
|
28 |
init_id_map(); |
29 |
|
30 |
// initialise the pd controller for the velocity and position mixer
|
31 |
init_pv_mix_pid(); |
32 |
|
33 |
// intantiate the face interface
|
34 |
face_interface_ = new iCubFaceInterface(scope);
|
35 |
|
36 |
// intantiate the polydriver
|
37 |
Property options; |
38 |
options.put("device", "remote_controlboard"); |
39 |
options.put("local", "/local/head"); |
40 |
options.put("remote", scope + "/head"); |
41 |
yarp_polydriver_.open(options); |
42 |
|
43 |
// fetch yarp views:
|
44 |
bool success = true; |
45 |
//success &= yarp_polydriver_.view(yarp_iencs_);
|
46 |
success &= yarp_polydriver_.view(yarp_ipos_); |
47 |
success &= yarp_polydriver_.view(yarp_ivel_); |
48 |
success &= yarp_polydriver_.view(yarp_ilimits_); |
49 |
success &= yarp_polydriver_.view(yarp_pid_); |
50 |
success &= yarp_polydriver_.view(yarp_amp_); |
51 |
|
52 |
if (!success) {
|
53 |
cout << "ERROR: failed to fetch one or more yarp views... exiting\n";
|
54 |
exit(EXIT_FAILURE); |
55 |
} |
56 |
|
57 |
|
58 |
//tell humotion about min/max joint values:
|
59 |
init_joints(); |
60 |
|
61 |
//initialise joint controller
|
62 |
init_controller(); |
63 |
} |
64 |
|
65 |
//! destructor
|
66 |
iCubJointInterface::~iCubJointInterface(){ |
67 |
} |
68 |
|
69 |
//! init the controller that allows to write target angles or velocities
|
70 |
void iCubJointInterface::init_controller() {
|
71 |
int number_of_joints;
|
72 |
|
73 |
//set position mode:
|
74 |
if (POSITION_CONTROL){
|
75 |
// use position controller, first fetch no of axes:
|
76 |
yarp_ipos_->getAxes(&number_of_joints); |
77 |
|
78 |
// set ref acceleration to a value for all axes:
|
79 |
yarp_commands_.resize(number_of_joints); |
80 |
yarp_commands_ = 200000.0; |
81 |
yarp_ipos_->setRefAccelerations(yarp_commands_.data()); |
82 |
yarp_ipos_->setPositionMode(); |
83 |
}else{
|
84 |
// use position controller, first fetch no of axes:
|
85 |
yarp_ivel_->getAxes(&number_of_joints); |
86 |
|
87 |
// set ref acceleration to a value for all axes:
|
88 |
yarp_commands_.resize(number_of_joints); |
89 |
yarp_commands_=300.0; |
90 |
yarp_ivel_->setRefAccelerations(yarp_commands_.data()); |
91 |
yarp_ivel_->setVelocityMode(); |
92 |
} |
93 |
|
94 |
|
95 |
} |
96 |
|
97 |
//! initialise icub joint id to humotion joint id mappings
|
98 |
void iCubJointInterface::init_id_map() {
|
99 |
insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_LEFT_UPPER, ID_LIP_LEFT_UPPER); |
100 |
insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_LEFT_LOWER, ID_LIP_LEFT_LOWER); |
101 |
insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_CENTER_UPPER, ID_LIP_CENTER_UPPER); |
102 |
insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_CENTER_LOWER, ID_LIP_CENTER_LOWER); |
103 |
insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_RIGHT_UPPER, ID_LIP_RIGHT_UPPER); |
104 |
insert_icupid_to_humotionid_mapping(ICUB_ID_LIP_RIGHT_LOWER, ID_LIP_RIGHT_LOWER); |
105 |
insert_icupid_to_humotionid_mapping(ICUB_ID_NECK_PAN, ID_NECK_PAN); |
106 |
insert_icupid_to_humotionid_mapping(ICUB_ID_NECK_TILT, ID_NECK_TILT); |
107 |
insert_icupid_to_humotionid_mapping(ICUB_ID_NECK_ROLL, ID_NECK_ROLL); |
108 |
// FIXME: remove this hack tha repurposes LEFT/RIGHT eye pan from humotion as vergence/pan
|
109 |
insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_PAN, ID_EYES_LEFT_LR); |
110 |
insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_VERGENCE, ID_EYES_RIGHT_LR); |
111 |
insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_BOTH_UD, ID_EYES_BOTH_UD); |
112 |
insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_LEFT_LID_LOWER, ID_EYES_LEFT_LID_LOWER); |
113 |
insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_LEFT_LID_UPPER, ID_EYES_LEFT_LID_UPPER); |
114 |
insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_LEFT_BROW, ID_EYES_LEFT_BROW); |
115 |
insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_RIGHT_LID_LOWER, ID_EYES_RIGHT_LID_LOWER); |
116 |
insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_RIGHT_LID_UPPER,ID_EYES_RIGHT_LID_UPPER); |
117 |
insert_icupid_to_humotionid_mapping(ICUB_ID_EYES_RIGHT_BROW, ID_EYES_RIGHT_BROW); |
118 |
} |
119 |
|
120 |
//! initialize the position and velocity mixer PD controller
|
121 |
void iCubJointInterface::init_pv_mix_pid() {
|
122 |
// init control variables and last error variable for the internal
|
123 |
// position and velocity mixer PD controller:
|
124 |
pv_mix_pid_p_.resize(ICUB_JOINT_ID_ENUM_SIZE); |
125 |
pv_mix_pid_d_.resize(ICUB_JOINT_ID_ENUM_SIZE); |
126 |
pv_mix_last_error_.resize(ICUB_JOINT_ID_ENUM_SIZE); |
127 |
|
128 |
enum_id_bimap_t::const_iterator it; |
129 |
for(it = enum_id_bimap.begin(); it != enum_id_bimap.end(); ++it) {
|
130 |
int id = it->left;
|
131 |
pv_mix_pid_p_[id] = 4.5; |
132 |
pv_mix_pid_d_[id] = 0.3; |
133 |
pv_mix_last_error_[id] = 0.0; |
134 |
} |
135 |
|
136 |
} |
137 |
|
138 |
//! add mapping from icub joint ids to humotion ids
|
139 |
//! this might look strange at the first sight but we need to have a generic
|
140 |
//! way to acces joints from libhumotion. therefore the lib uses its enum with ID_* enum ids
|
141 |
//! to access the joints. now we need to define a mapping to map those to the icub motor ids.
|
142 |
void iCubJointInterface::insert_icupid_to_humotionid_mapping(int icubid, int humotionid) { |
143 |
enum_id_bimap.insert(enum_id_bimap_entry_t(icubid, humotionid)); |
144 |
} |
145 |
|
146 |
|
147 |
|
148 |
|
149 |
void iCubJointInterface::run(){
|
150 |
float loop_duration_ms = 1000.0 / MAIN_LOOP_FREQUENCY; |
151 |
iCubDataReceiver *data_receiver = new iCubDataReceiver(loop_duration_ms, this); |
152 |
data_receiver->start(); |
153 |
} |
154 |
|
155 |
//! stores the target position & velocity of a given joint
|
156 |
//! \param enum id of joint
|
157 |
//! \param float value
|
158 |
void iCubJointInterface::publish_target(int humotion_id, float position, float velocity){ |
159 |
// special handler for eye joints
|
160 |
if ((humotion_id == JointInterface::ID_EYES_LEFT_LR) ||
|
161 |
(humotion_id == JointInterface::ID_EYES_RIGHT_LR)){ |
162 |
// the icub has a combined pan angle for both eyes, so seperate this:
|
163 |
float target_position_left = get_target_position(JointInterface::ID_EYES_LEFT_LR);
|
164 |
float target_position_right = get_target_position(JointInterface::ID_EYES_RIGHT_LR);
|
165 |
float target_velocity_left = get_target_velocity(JointInterface::ID_EYES_LEFT_LR);
|
166 |
float target_velocity_right = get_target_velocity(JointInterface::ID_EYES_RIGHT_LR);
|
167 |
|
168 |
// 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);
|
171 |
|
172 |
// calculate target velocities
|
173 |
// for now just use the same velocity for pan and vergence
|
174 |
float target_velocity_pan = (target_velocity_left + target_velocity_right) / 2.0; |
175 |
float target_velocity_tilt = target_velocity_pan;
|
176 |
|
177 |
store_icub_joint_target(ICUB_ID_EYES_PAN, |
178 |
target_position_pan, target_velocity_pan); |
179 |
store_icub_joint_target(ICUB_ID_EYES_VERGENCE, |
180 |
target_position_vergence, target_velocity_tilt); |
181 |
}else{
|
182 |
// convert to icub joint id
|
183 |
int icub_id = convert_humotion_jointid_to_icub(humotion_id);
|
184 |
// store target data
|
185 |
store_icub_joint_target(icub_id, position, velocity); |
186 |
} |
187 |
} |
188 |
|
189 |
|
190 |
//! set the target data for a given icub joint
|
191 |
//! \param id of joint
|
192 |
//! \param float value of position
|
193 |
void iCubJointInterface::store_icub_joint_target(int icub_id, float position, float velocity) { |
194 |
printf("> set icub joint %d -> p = %f, v = %f\n",icub_id,position,velocity);
|
195 |
target_angle_[icub_id] = position; |
196 |
target_velocity_[icub_id] = velocity; |
197 |
} |
198 |
|
199 |
//! execute a move in position mode
|
200 |
//! \param id of joint
|
201 |
//! \param angle
|
202 |
void iCubJointInterface::set_target_in_positionmode(int id) { |
203 |
assert(POSITION_CONTROL); |
204 |
assert(id<=ICUB_ID_EYES_VERGENCE); |
205 |
|
206 |
// fetch the current target position
|
207 |
float target = target_angle_[id];
|
208 |
|
209 |
// execute motion as position control cmd
|
210 |
yarp_ipos_->positionMove(id, target); |
211 |
} |
212 |
|
213 |
//! execute a move in velocity mode
|
214 |
//! \param id of joint
|
215 |
//! \param angle
|
216 |
void iCubJointInterface::set_target_in_velocitymode(int icub_id) { |
217 |
assert(!POSITION_CONTROL); |
218 |
|
219 |
// fetch humotion id from icub joint id
|
220 |
int humotion_id = convert_humotion_jointid_to_icub(icub_id);
|
221 |
|
222 |
// fetch the target velocity
|
223 |
float target_velocity = target_velocity_[icub_id];
|
224 |
|
225 |
float vmax = 150.0; |
226 |
if (target_velocity > vmax) target_velocity = vmax;
|
227 |
if (target_velocity < -vmax) target_velocity = -vmax;
|
228 |
|
229 |
//execute:
|
230 |
//ivel->velocityMove(id, speed);
|
231 |
if ((icub_id != ICUB_ID_NECK_PAN) &&
|
232 |
(icub_id != ICUB_ID_EYES_BOTH_UD) && |
233 |
(icub_id != ICUB_ID_NECK_TILT) && |
234 |
(icub_id != ICUB_ID_EYES_BOTH_UD) && |
235 |
(icub_id != ICUB_ID_NECK_TILT)) { |
236 |
// limit to some joints for debugging...
|
237 |
return;
|
238 |
} |
239 |
|
240 |
// we now add a pd control loop for velocity moves in order to handle position errors
|
241 |
// TODO: add position interpolation into future. this requires to enable the velocity
|
242 |
// broadcast in the torso and head ini file and fetch that velocity in the
|
243 |
// icub_data_receiver as well. TODO: check if the can bus has enough bandwidth for that...
|
244 |
|
245 |
// first: fetch the timstamp of the last known position
|
246 |
humotion::Timestamp data_ts = get_ts_position(humotion_id).get_last_timestamp(); |
247 |
|
248 |
// calculate position error:
|
249 |
float position_error = target_angle_[icub_id] - get_ts_position(humotion_id).get_interpolated_value(data_ts);
|
250 |
|
251 |
// calculate d term
|
252 |
float error_d = (position_error - pv_mix_last_error_[icub_id]) / (framerate*1000.0); |
253 |
pv_mix_last_error_[icub_id] = position_error; |
254 |
|
255 |
// finally do a PD loop to get the target velocity
|
256 |
float pv_mix_velocity = pv_mix_pid_p_[icub_id] * position_error
|
257 |
+ pv_mix_pid_p_[icub_id]*error_d |
258 |
+ target_velocity; |
259 |
|
260 |
printf("%f %f %f %f %f %f PID%d\n",
|
261 |
get_ts_position(humotion_id).get_interpolated_value(data_ts), |
262 |
target_angle_[icub_id], |
263 |
123.4, //NOT USED ANYMORE//get_ts_speed(humotion_id).get_interpolated_value(data_ts), |
264 |
pv_mix_velocity, |
265 |
target_velocity, |
266 |
position_error, |
267 |
icub_id |
268 |
); |
269 |
|
270 |
// execute velocity move
|
271 |
yarp_ivel_->velocityMove(icub_id, pv_mix_velocity); |
272 |
} |
273 |
|
274 |
//! actually execute the scheduled motion commands
|
275 |
void iCubJointInterface::execute_motion(){
|
276 |
|
277 |
// set up neck and eye motion commands:
|
278 |
if (POSITION_CONTROL){
|
279 |
//position control
|
280 |
for(int i=ICUB_ID_NECK_TILT; i<=ICUB_ID_EYES_VERGENCE; i++){ |
281 |
set_target_in_positionmode(i); |
282 |
} |
283 |
}else{
|
284 |
//velocity control
|
285 |
for(int i=ICUB_ID_NECK_TILT; i<=ICUB_ID_EYES_VERGENCE; i++){ |
286 |
set_target_in_velocitymode(i); |
287 |
} |
288 |
} |
289 |
//printf("> TARGET PAN = %3.2f\n",target_angle[ICUB_ID_NECK_PAN]);
|
290 |
|
291 |
|
292 |
//eyelids: unfortuantely the icub has only 1dof for eyelids, so we use only one dof here:
|
293 |
face_interface_->set_eyelid_angle(target_angle_[ICUB_ID_EYES_RIGHT_LID_UPPER]); |
294 |
|
295 |
//eyebrows are set using a special command as well:
|
296 |
face_interface_->set_eyebrow_angle(ICUB_ID_EYES_LEFT_BROW, target_angle_); |
297 |
face_interface_->set_eyebrow_angle(ICUB_ID_EYES_RIGHT_BROW, target_angle_); |
298 |
|
299 |
//mouth
|
300 |
face_interface_->set_mouth(target_angle_); |
301 |
|
302 |
|
303 |
//store joint values which we do not handle on icub here:
|
304 |
double timestamp = humotion::Timestamp::now().to_seconds();
|
305 |
JointInterface::store_incoming_position(ID_LIP_LEFT_UPPER, target_angle_[ICUB_ID_LIP_LEFT_UPPER], timestamp); |
306 |
JointInterface::store_incoming_position(ID_LIP_LEFT_LOWER, target_angle_[ICUB_ID_LIP_LEFT_LOWER], timestamp); |
307 |
JointInterface::store_incoming_position(ID_LIP_CENTER_UPPER, target_angle_[ICUB_ID_LIP_CENTER_UPPER], timestamp); |
308 |
JointInterface::store_incoming_position(ID_LIP_CENTER_LOWER, target_angle_[ICUB_ID_LIP_CENTER_LOWER], timestamp); |
309 |
JointInterface::store_incoming_position(ID_LIP_RIGHT_UPPER, target_angle_[ICUB_ID_LIP_RIGHT_UPPER], timestamp); |
310 |
JointInterface::store_incoming_position(ID_LIP_RIGHT_LOWER, target_angle_[ICUB_ID_LIP_RIGHT_LOWER], timestamp); |
311 |
} |
312 |
|
313 |
|
314 |
//! set the current position of a joint
|
315 |
//! \param id of joint
|
316 |
//! \param float value of position
|
317 |
//! \param double timestamp
|
318 |
void iCubJointInterface::store_incoming_position(int id, double value, double timestamp){ |
319 |
//store joint based on id:
|
320 |
switch(id){
|
321 |
default:
|
322 |
printf("> ERROR: unhandled joint id %d\n",id);
|
323 |
return;
|
324 |
|
325 |
case(100): |
326 |
//JointInterface::store_incoming_position(ID_EYES_RIGHT_LID_UPPER, lid_angle, timestamp);
|
327 |
break;
|
328 |
|
329 |
case(ICUB_ID_NECK_PAN):
|
330 |
//PAN is inverted!
|
331 |
JointInterface::store_incoming_position(ID_NECK_PAN, value, timestamp); |
332 |
break;
|
333 |
|
334 |
case(ICUB_ID_NECK_TILT):
|
335 |
JointInterface::store_incoming_position(ID_NECK_TILT, value, timestamp); |
336 |
break;
|
337 |
|
338 |
case(ICUB_ID_NECK_ROLL):
|
339 |
JointInterface::store_incoming_position(ID_NECK_ROLL, value, timestamp); |
340 |
break;
|
341 |
|
342 |
case(ICUB_ID_EYES_BOTH_UD):
|
343 |
JointInterface::store_incoming_position(ID_EYES_BOTH_UD, value, timestamp); |
344 |
break;
|
345 |
|
346 |
//icub handles eyes differently, we have to set pan angle + vergence
|
347 |
case(ICUB_ID_EYES_PAN): {//pan |
348 |
last_pos_eye_pan = value; |
349 |
float left = last_pos_eye_pan + last_pos_eye_vergence/2.0; |
350 |
float right = last_pos_eye_pan - last_pos_eye_vergence/2.0; |
351 |
|
352 |
//printf("> eye: pan=%3.2f vergence=%3.2f --> L=%3.2f R=%3.2f\n", last_pos_eye_pan, last_pos_eye_vergence, left, right);
|
353 |
JointInterface::store_incoming_position(ID_EYES_LEFT_LR, left, timestamp); |
354 |
JointInterface::store_incoming_position(ID_EYES_RIGHT_LR, right, timestamp); |
355 |
break;
|
356 |
} |
357 |
|
358 |
case(ICUB_ID_EYES_VERGENCE): { //vergence |
359 |
last_pos_eye_vergence = value; |
360 |
float left = last_pos_eye_pan + last_pos_eye_vergence/2.0; |
361 |
float right = last_pos_eye_pan - last_pos_eye_vergence/2.0; |
362 |
|
363 |
//printf("> eye: pan=%3.2f vergence=%3.2f --> L=%3.2f R=%3.2f\n", last_pos_eye_pan, last_pos_eye_vergence, left, right);
|
364 |
JointInterface::store_incoming_position(ID_EYES_LEFT_LR, left, timestamp); |
365 |
JointInterface::store_incoming_position(ID_EYES_RIGHT_LR, right, timestamp); |
366 |
break;
|
367 |
} |
368 |
} |
369 |
|
370 |
|
371 |
} |
372 |
|
373 |
void iCubJointInterface::set_joint_enable_state(int e, bool enable) { |
374 |
int icub_jointid = -1; |
375 |
|
376 |
switch(e){
|
377 |
default:
|
378 |
break;
|
379 |
|
380 |
case(ID_NECK_PAN):
|
381 |
icub_jointid = ICUB_ID_NECK_PAN; |
382 |
break;
|
383 |
|
384 |
case(ID_NECK_TILT):
|
385 |
icub_jointid = ICUB_ID_NECK_TILT; |
386 |
break;
|
387 |
|
388 |
case(ID_NECK_ROLL):
|
389 |
icub_jointid = ICUB_ID_NECK_ROLL; |
390 |
break;
|
391 |
|
392 |
case(ID_EYES_BOTH_UD):
|
393 |
icub_jointid = ICUB_ID_EYES_BOTH_UD; |
394 |
break;
|
395 |
|
396 |
// icub handles eyes as pan angle + vergence...
|
397 |
// -> hack: left eye enables pan and right eye enables vergence
|
398 |
case(ID_EYES_LEFT_LR):
|
399 |
icub_jointid = ICUB_ID_EYES_PAN; |
400 |
break;
|
401 |
|
402 |
case(ID_EYES_RIGHT_LR):
|
403 |
icub_jointid = ICUB_ID_EYES_VERGENCE; |
404 |
break;
|
405 |
} |
406 |
|
407 |
if (icub_jointid != -1) { |
408 |
if (enable) {
|
409 |
yarp_amp_->enableAmp(icub_jointid); |
410 |
yarp_pid_->enablePid(icub_jointid); |
411 |
} else {
|
412 |
yarp_pid_->disablePid(icub_jointid); |
413 |
yarp_amp_->disableAmp(icub_jointid); |
414 |
} |
415 |
} |
416 |
} |
417 |
|
418 |
//! prepare and enable a joint
|
419 |
//! NOTE: this should also prefill the min/max positions for this joint
|
420 |
//! \param the enum id of a joint
|
421 |
void iCubJointInterface::enable_joint(int e){ |
422 |
set_joint_enable_state(e, true);
|
423 |
} |
424 |
|
425 |
//! shutdown and disable a joint
|
426 |
//! \param the enum id of a joint
|
427 |
void iCubJointInterface::disable_joint(int e){ |
428 |
set_joint_enable_state(e, false);
|
429 |
} |
430 |
|
431 |
void iCubJointInterface::store_min_max(IControlLimits *ilimits, int id, int e){ |
432 |
double min, max;
|
433 |
ilimits->getLimits(id, &min, &max); |
434 |
joint_min[e] = min; |
435 |
joint_max[e] = max; |
436 |
} |
437 |
|
438 |
//! initialise a joint (set up controller mode etc)
|
439 |
//! \param joint enum
|
440 |
void iCubJointInterface::init_joints(){
|
441 |
store_min_max(yarp_ilimits_, ICUB_ID_NECK_TILT, ID_NECK_TILT); |
442 |
store_min_max(yarp_ilimits_, ICUB_ID_NECK_ROLL, ID_NECK_ROLL); |
443 |
store_min_max(yarp_ilimits_, ICUB_ID_NECK_PAN, ID_NECK_PAN); |
444 |
store_min_max(yarp_ilimits_, ICUB_ID_EYES_BOTH_UD, ID_EYES_BOTH_UD); |
445 |
|
446 |
//icub handles eyes differently, we have to set pan angle + vergence
|
447 |
double pan_min, pan_max, vergence_min, vergence_max;
|
448 |
yarp_ilimits_->getLimits(ICUB_ID_EYES_PAN, &pan_min, &pan_max); |
449 |
yarp_ilimits_->getLimits(ICUB_ID_EYES_VERGENCE, &vergence_min, &vergence_max); |
450 |
|
451 |
//this is not 100% correct, should be fixed:
|
452 |
joint_min[ID_EYES_LEFT_LR] = pan_min; // - vergence_max/2;
|
453 |
joint_max[ID_EYES_LEFT_LR] = pan_max; // - vergence_max/2;
|
454 |
joint_min[ID_EYES_RIGHT_LR] = joint_min[ID_EYES_LEFT_LR]; |
455 |
joint_max[ID_EYES_RIGHT_LR] = joint_max[ID_EYES_LEFT_LR]; |
456 |
|
457 |
//eyelids:
|
458 |
joint_min[ID_EYES_RIGHT_LID_UPPER] = -50; //24-30; |
459 |
joint_max[ID_EYES_RIGHT_LID_UPPER] = 50; //48-30; |
460 |
//lid_angle = joint_max[ID_EYES_RIGHT_LID_UPPER];
|
461 |
|
462 |
//eyebrows:
|
463 |
joint_min[ID_EYES_LEFT_BROW] = -50;
|
464 |
joint_max[ID_EYES_LEFT_BROW] = 50;
|
465 |
joint_min[ID_EYES_RIGHT_BROW] = joint_min[ID_EYES_LEFT_BROW]; |
466 |
joint_max[ID_EYES_RIGHT_BROW] = joint_max[ID_EYES_LEFT_BROW]; |
467 |
|
468 |
//mouth:
|
469 |
joint_min[ID_LIP_CENTER_UPPER] = 5;
|
470 |
joint_max[ID_LIP_CENTER_UPPER] = 50;
|
471 |
joint_min[ID_LIP_CENTER_LOWER] = 5;
|
472 |
joint_max[ID_LIP_CENTER_LOWER] = 50;
|
473 |
joint_min[ID_LIP_LEFT_UPPER] = 5;
|
474 |
joint_max[ID_LIP_LEFT_UPPER] = 50;
|
475 |
joint_min[ID_LIP_LEFT_LOWER] = 5;
|
476 |
joint_max[ID_LIP_LEFT_LOWER] = 50;
|
477 |
joint_min[ID_LIP_RIGHT_UPPER] = 5;
|
478 |
joint_max[ID_LIP_RIGHT_UPPER] = 50;
|
479 |
joint_min[ID_LIP_RIGHT_LOWER] = 5;
|
480 |
joint_max[ID_LIP_RIGHT_LOWER] = 50;
|
481 |
} |
482 |
|
483 |
//! conversion table for humotion joint id to icub joint id
|
484 |
//! \param int value for humotion joint id from JointInterface::JOINT_ID_ENUM
|
485 |
//! \return int value of icub joint id
|
486 |
int iCubJointInterface::convert_humotion_jointid_to_icub(int humotion_id){ |
487 |
enum_id_bimap_t::right_const_iterator it = enum_id_bimap.right.find(humotion_id); |
488 |
if(it == enum_id_bimap.right.end()) {
|
489 |
//key does not exist
|
490 |
cout << "ERROR: invalid humotion joint id given. can not convert this. exiting\n";
|
491 |
exit(EXIT_FAILURE); |
492 |
} |
493 |
return it->second;
|
494 |
} |
495 |
|
496 |
|
497 |
//! conversion table for icub joint id to humotion joint id
|
498 |
//! \param int value of icub joint id
|
499 |
//! \return int value of humotion joint id from JointInterface::JOINT_ID_ENUM
|
500 |
int iCubJointInterface::convert_icub_jointid_to_humotion(int icub_id){ |
501 |
enum_id_bimap_t::left_const_iterator it = enum_id_bimap.left.find(icub_id); |
502 |
if(it == enum_id_bimap.left.end()) {
|
503 |
//key does not exist
|
504 |
cout << "ERROR: invalid icub joint id given. can not convert this. exiting\n";
|
505 |
exit(EXIT_FAILURE); |
506 |
} |
507 |
return it->second;
|
508 |
} |
509 |
|