humotion / examples / yarp_icub / src / icub_jointinterface.cpp @ 58c9f56c
History | View | Annotate | Download (17.976 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 |
//WARNING: DO NOT CHANGE THIS; VELOCITYMODE IS NOT YET IMPLEMENTED
|
21 |
#define POSITION_CONTROL 0 |
22 |
|
23 |
|
24 |
//! constructor
|
25 |
iCubJointInterface::iCubJointInterface(string _scope) : humotion::server::JointInterface(){
|
26 |
scope = _scope; |
27 |
face_interface = new iCubFaceInterface(scope);
|
28 |
|
29 |
//add mapping from ids to enums:
|
30 |
//this might look strange at the first sight but we need to have a generic
|
31 |
//way to acces joints from libhumotion. therefore the lib uses its enum with ID_* enum ids
|
32 |
//to access the joints. now we need to define a mapping to map those to our motor ids.
|
33 |
//this is what we use the enum bimap for (convertion fro/to motorid is handled
|
34 |
//by \sa convert_enum_to_motorid() and \sa convert_motorid_to_enum() lateron
|
35 |
|
36 |
//MOUTH
|
37 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_LIP_LEFT_UPPER, ID_LIP_LEFT_UPPER)); |
38 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_LIP_LEFT_LOWER, ID_LIP_LEFT_LOWER)); |
39 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_LIP_CENTER_UPPER, ID_LIP_CENTER_UPPER)); |
40 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_LIP_CENTER_LOWER, ID_LIP_CENTER_LOWER)); |
41 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_LIP_RIGHT_UPPER, ID_LIP_RIGHT_UPPER)); |
42 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_LIP_RIGHT_LOWER, ID_LIP_RIGHT_LOWER)); |
43 |
|
44 |
//NECK
|
45 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_NECK_PAN, ID_NECK_PAN)); |
46 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_NECK_TILT, ID_NECK_TILT)); |
47 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_NECK_ROLL, ID_NECK_ROLL)); |
48 |
|
49 |
//EYES
|
50 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_EYES_PAN, ID_EYES_LEFT_LR)); |
51 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_EYES_VERGENCE, ID_EYES_RIGHT_LR)); |
52 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_EYES_BOTH_UD, ID_EYES_BOTH_UD)); |
53 |
|
54 |
//EYELIDS
|
55 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_EYES_LEFT_LID_LOWER, ID_EYES_LEFT_LID_LOWER)); |
56 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_EYES_LEFT_LID_UPPER, ID_EYES_LEFT_LID_UPPER)); |
57 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_EYES_LEFT_BROW, ID_EYES_LEFT_BROW)); |
58 |
|
59 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_EYES_RIGHT_LID_LOWER, ID_EYES_RIGHT_LID_LOWER)); |
60 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_EYES_RIGHT_LID_UPPER,ID_EYES_RIGHT_LID_UPPER)); |
61 |
enum_id_bimap.insert(enum_id_bimap_entry_t(ICUB_ID_EYES_RIGHT_BROW, ID_EYES_RIGHT_BROW)); |
62 |
|
63 |
Property options; |
64 |
options.put("device", "remote_controlboard"); |
65 |
options.put("local", "/local/head"); |
66 |
options.put("remote", scope+"/head"); |
67 |
dd.open(options); |
68 |
|
69 |
//fetch views:
|
70 |
dd.view(iencs); |
71 |
dd.view(ipos); |
72 |
dd.view(ivel); |
73 |
dd.view(ilimits); |
74 |
dd.view(pid); |
75 |
dd.view(amp); |
76 |
|
77 |
|
78 |
if ( (!iencs) || (!ipos) || (!ilimits) || (!ivel) || (!amp) || (!pid)){
|
79 |
printf("> ERROR: failed to open icub views\n");
|
80 |
exit(EXIT_FAILURE); |
81 |
} |
82 |
|
83 |
int joints;
|
84 |
|
85 |
//tell humotion about min/max joint values:
|
86 |
init_joints(); |
87 |
|
88 |
iencs->getAxes(&joints); |
89 |
positions.resize(joints); |
90 |
velocities.resize(joints); |
91 |
commands.resize(joints); |
92 |
|
93 |
//set position mode:
|
94 |
if (POSITION_CONTROL){
|
95 |
commands=200000.0; |
96 |
ipos->setRefAccelerations(commands.data()); |
97 |
ipos->setPositionMode(); |
98 |
}else{
|
99 |
ivel->setVelocityMode(); |
100 |
commands=100.0; |
101 |
ivel->setRefAccelerations(commands.data()); |
102 |
} |
103 |
|
104 |
} |
105 |
|
106 |
//! destructor
|
107 |
iCubJointInterface::~iCubJointInterface(){ |
108 |
} |
109 |
|
110 |
|
111 |
|
112 |
//! conversion table for humotion motor ids to our ids:
|
113 |
//! \param enum from JointInterface::JOINT_ID_ENUM
|
114 |
//! \return int value of motor id
|
115 |
int iCubJointInterface::convert_enum_to_motorid(int e){ |
116 |
enum_id_bimap_t::right_const_iterator it = enum_id_bimap.right.find(e); |
117 |
if(it == enum_id_bimap.right.end()) {
|
118 |
//key does not exists, we are not interested in that dataset, return -1
|
119 |
return -1; |
120 |
} |
121 |
return it->second;
|
122 |
} |
123 |
|
124 |
|
125 |
//! conversion table for our ids to humotion motor ids:
|
126 |
//! \param int value of motor id
|
127 |
//! \return enum from JointInterface::JOINT_ID_ENUM
|
128 |
int iCubJointInterface::convert_motorid_to_enum(int id){ |
129 |
enum_id_bimap_t::left_const_iterator it = enum_id_bimap.left.find(id); |
130 |
if(it == enum_id_bimap.left.end()) {
|
131 |
//key does not exists, we are not interested in that dataset, return -1
|
132 |
return -1; |
133 |
} |
134 |
return it->second;
|
135 |
} |
136 |
|
137 |
|
138 |
void iCubJointInterface::run(){
|
139 |
iCubDataReceiver *data_receiver = new iCubDataReceiver(0.5 * 1000.0 / MAIN_LOOP_FREQUENCY, iencs, this); |
140 |
data_receiver->start(); |
141 |
} |
142 |
|
143 |
//! set the target position of a joint
|
144 |
//! \param enum id of joint
|
145 |
//! \param float value
|
146 |
void iCubJointInterface::publish_target_position(int e){ |
147 |
//first: convert humotion enum to our enum:
|
148 |
int id = convert_enum_to_motorid(e);
|
149 |
|
150 |
if (id == -1){ |
151 |
return; //we are not interested in that data, so we just return here |
152 |
} |
153 |
|
154 |
if (id == ICUB_ID_NECK_PAN){
|
155 |
//PAN seems to be swapped
|
156 |
store_joint(ICUB_ID_NECK_PAN, -joint_target[e]); |
157 |
}else if ((id == ICUB_ID_EYES_PAN) || ( id == ICUB_ID_EYES_VERGENCE)){ |
158 |
//icub handles eyes differently, we have to set pan angle + vergence
|
159 |
float pan = (joint_target[ID_EYES_LEFT_LR] + joint_target[ID_EYES_RIGHT_LR]) / 2; |
160 |
float vergence = (joint_target[ID_EYES_LEFT_LR] - joint_target[ID_EYES_RIGHT_LR]);
|
161 |
//printf("EYEDBG %3.2f %3.2f --_> pan %3.2f verg=%3.2f\n",joint_target[ID_EYES_LEFT_LR], joint_target[ID_EYES_RIGHT_LR],pan,vergence);
|
162 |
|
163 |
store_joint(ICUB_ID_EYES_PAN, pan); |
164 |
store_joint(ICUB_ID_EYES_VERGENCE, vergence); |
165 |
}else{
|
166 |
store_joint(id, joint_target[e]); |
167 |
} |
168 |
} |
169 |
|
170 |
|
171 |
//! set the target position of a joint
|
172 |
//! \param id of joint
|
173 |
//! \param float value of position
|
174 |
void iCubJointInterface::store_joint(int id, float value){ |
175 |
printf("> set joint %d = %f\n",id,value);
|
176 |
target_angle[id] = value; |
177 |
} |
178 |
|
179 |
//! execute a move in position mode
|
180 |
//! \param id of joint
|
181 |
//! \param angle
|
182 |
void iCubJointInterface::set_target_in_positionmode(int id, double value){ |
183 |
if (id>ICUB_ID_EYES_VERGENCE){
|
184 |
printf("> ERROR: set_target_positionmode(id=%d, %3.2f) not supported for this id\n",id,value);
|
185 |
return;
|
186 |
} |
187 |
|
188 |
// execute motion as position control cmd
|
189 |
ipos->positionMove(id, value); |
190 |
|
191 |
} |
192 |
|
193 |
//! execute a move in velocity mode
|
194 |
//! \param id of joint
|
195 |
//! \param angle
|
196 |
void iCubJointInterface::set_target_in_velocitymode(int id, double value){ |
197 |
// set speed cacluated as in velocity + set position -> replicates smoothmotion from flobi?!
|
198 |
//first: calculate necessary speed to reach the given target within the next clock tick:
|
199 |
double distance = value - target_angle_previous[id];
|
200 |
|
201 |
//make the motion smooth: we want to reach 85% of the target in the next iteration:
|
202 |
distance = 0.85 * distance; |
203 |
|
204 |
//distance = -5.0 / 50.0;
|
205 |
|
206 |
//calculate speed
|
207 |
//double speed = distance * ((double)MAIN_LOOP_FREQUENCY);
|
208 |
|
209 |
|
210 |
|
211 |
int e = convert_motorid_to_enum(id);
|
212 |
double speed = joint_target_speed[e];
|
213 |
|
214 |
double max = 150.0; |
215 |
if (speed > max) speed = max;
|
216 |
if (speed < -max) speed = -max;
|
217 |
|
218 |
//speed = -speed;
|
219 |
|
220 |
|
221 |
// find out the latency between incoming data and now:
|
222 |
float latency = get_ts_speed(e).get_last_timestamp().to_seconds() - humotion::Timestamp::now().to_seconds();
|
223 |
printf("TS DIFF %fms\n",latency*1000.0); |
224 |
|
225 |
//execute:
|
226 |
//ivel->velocityMove(id, speed);
|
227 |
if ((id == ICUB_ID_NECK_PAN) || (id == ICUB_ID_EYES_BOTH_UD) || (id == ICUB_ID_NECK_TILT) || (id == ICUB_ID_EYES_BOTH_UD) || (id == ICUB_ID_NECK_TILT) ){
|
228 |
//if (id == ICUB_ID_NECK_PAN) speed = -speed;
|
229 |
ivel->velocityMove(id, speed); |
230 |
printf("> VEL now=%3.2f target=%3.2f --> dist=%3.2f speed=%3.2f\n",target_angle_previous[id],value,distance,speed);
|
231 |
} |
232 |
|
233 |
target_angle_previous[id] = get_ts_position(convert_motorid_to_enum(id)).get_newest_value(); |
234 |
} |
235 |
|
236 |
//! actually execute the scheduled motion commands
|
237 |
void iCubJointInterface::execute_motion(){
|
238 |
|
239 |
// set up neck and eye motion commands:
|
240 |
if (POSITION_CONTROL){
|
241 |
//position control
|
242 |
for(int i=ICUB_ID_NECK_TILT; i<=ICUB_ID_EYES_VERGENCE; i++){ |
243 |
set_target_in_positionmode(i, target_angle[i]); |
244 |
} |
245 |
}else{
|
246 |
//velocity control
|
247 |
for(int i=ICUB_ID_NECK_TILT; i<=ICUB_ID_EYES_VERGENCE; i++){ |
248 |
set_target_in_velocitymode(i, target_angle[i]); |
249 |
} |
250 |
} |
251 |
//printf("> TARGET PAN = %3.2f\n",target_angle[ICUB_ID_NECK_PAN]);
|
252 |
|
253 |
|
254 |
//eyelids: unfortuantely the icub has only 1dof for eyelids, so we use only one dof here:
|
255 |
face_interface->set_eyelid_angle(target_angle[ICUB_ID_EYES_RIGHT_LID_UPPER]); |
256 |
|
257 |
//eyebrows are set using a special command as well:
|
258 |
face_interface->set_eyebrow_angle(ICUB_ID_EYES_LEFT_BROW, target_angle); |
259 |
face_interface->set_eyebrow_angle(ICUB_ID_EYES_RIGHT_BROW, target_angle); |
260 |
|
261 |
//mouth
|
262 |
face_interface->set_mouth(target_angle); |
263 |
|
264 |
|
265 |
//store joint values which we do not handle on icub here:
|
266 |
double timestamp = get_timestamp_ms();
|
267 |
JointInterface::store_incoming_position(ID_LIP_LEFT_UPPER, target_angle[ICUB_ID_LIP_LEFT_UPPER], timestamp); |
268 |
JointInterface::store_incoming_position(ID_LIP_LEFT_LOWER, target_angle[ICUB_ID_LIP_LEFT_LOWER], timestamp); |
269 |
JointInterface::store_incoming_position(ID_LIP_CENTER_UPPER, target_angle[ICUB_ID_LIP_CENTER_UPPER], timestamp); |
270 |
JointInterface::store_incoming_position(ID_LIP_CENTER_LOWER, target_angle[ICUB_ID_LIP_CENTER_LOWER], timestamp); |
271 |
JointInterface::store_incoming_position(ID_LIP_RIGHT_UPPER, target_angle[ICUB_ID_LIP_RIGHT_UPPER], timestamp); |
272 |
JointInterface::store_incoming_position(ID_LIP_RIGHT_LOWER, target_angle[ICUB_ID_LIP_RIGHT_LOWER], timestamp); |
273 |
} |
274 |
|
275 |
double iCubJointInterface::get_timestamp_ms(){
|
276 |
struct timespec spec;
|
277 |
clock_gettime(CLOCK_REALTIME, &spec); |
278 |
return spec.tv_sec*1000 + spec.tv_nsec / 1.0e6; |
279 |
} |
280 |
|
281 |
//! set the current position of a joint
|
282 |
//! \param id of joint
|
283 |
//! \param float value of position
|
284 |
//! \param double timestamp
|
285 |
void iCubJointInterface::fetch_position(int id, double value, double timestamp){ |
286 |
//store joint based on id:
|
287 |
switch(id){
|
288 |
default:
|
289 |
printf("> ERROR: unhandled joint id %d\n",id);
|
290 |
return;
|
291 |
|
292 |
case(100): |
293 |
//JointInterface::store_incoming_position(ID_EYES_RIGHT_LID_UPPER, lid_angle, timestamp);
|
294 |
break;
|
295 |
|
296 |
case(ICUB_ID_NECK_PAN):
|
297 |
//PAN is inverted!
|
298 |
JointInterface::store_incoming_position(ID_NECK_PAN, value, timestamp); |
299 |
break;
|
300 |
|
301 |
case(ICUB_ID_NECK_TILT):
|
302 |
JointInterface::store_incoming_position(ID_NECK_TILT, value, timestamp); |
303 |
break;
|
304 |
|
305 |
case(ICUB_ID_NECK_ROLL):
|
306 |
JointInterface::store_incoming_position(ID_NECK_ROLL, value, timestamp); |
307 |
break;
|
308 |
|
309 |
case(ICUB_ID_EYES_BOTH_UD):
|
310 |
JointInterface::store_incoming_position(ID_EYES_BOTH_UD, value, timestamp); |
311 |
break;
|
312 |
|
313 |
//icub handles eyes differently, we have to set pan angle + vergence
|
314 |
case(ICUB_ID_EYES_PAN): {//pan |
315 |
last_pos_eye_pan = value; |
316 |
float left = last_pos_eye_pan + last_pos_eye_vergence/2.0; |
317 |
float right = last_pos_eye_pan - last_pos_eye_vergence/2.0; |
318 |
|
319 |
//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);
|
320 |
JointInterface::store_incoming_position(ID_EYES_LEFT_LR, left, timestamp); |
321 |
JointInterface::store_incoming_position(ID_EYES_RIGHT_LR, right, timestamp); |
322 |
break;
|
323 |
} |
324 |
|
325 |
case(ICUB_ID_EYES_VERGENCE): { //vergence |
326 |
last_pos_eye_vergence = value; |
327 |
float left = last_pos_eye_pan + last_pos_eye_vergence/2.0; |
328 |
float right = last_pos_eye_pan - last_pos_eye_vergence/2.0; |
329 |
|
330 |
//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);
|
331 |
JointInterface::store_incoming_position(ID_EYES_LEFT_LR, left, timestamp); |
332 |
JointInterface::store_incoming_position(ID_EYES_RIGHT_LR, right, timestamp); |
333 |
break;
|
334 |
} |
335 |
} |
336 |
|
337 |
|
338 |
} |
339 |
|
340 |
//! set the current speed of a joint
|
341 |
//! \param enum id of joint
|
342 |
//! \param float value of speed
|
343 |
//! \param double timestamp
|
344 |
void iCubJointInterface::fetch_speed(int id, double value, double timestamp){ |
345 |
|
346 |
switch(id){
|
347 |
default:
|
348 |
printf("> ERROR: unhandled joint id %d\n",id);
|
349 |
return;
|
350 |
|
351 |
case(ICUB_ID_NECK_PAN):
|
352 |
//PAN IS INVERTED
|
353 |
JointInterface::store_incoming_speed(ID_NECK_PAN, value, timestamp); |
354 |
break;
|
355 |
|
356 |
case(ICUB_ID_NECK_TILT):
|
357 |
JointInterface::store_incoming_speed(ID_NECK_TILT, value, timestamp); |
358 |
break;
|
359 |
|
360 |
case(ICUB_ID_NECK_ROLL):
|
361 |
JointInterface::store_incoming_speed(ID_NECK_ROLL, value, timestamp); |
362 |
break;
|
363 |
|
364 |
case(ICUB_ID_EYES_BOTH_UD):
|
365 |
JointInterface::store_incoming_speed(ID_EYES_BOTH_UD, value, timestamp); |
366 |
break;
|
367 |
|
368 |
//icub handles eyes differently, we have to set pan angle + vergence
|
369 |
case(ICUB_ID_EYES_PAN): {//pan |
370 |
last_vel_eye_pan = value; |
371 |
float left = last_vel_eye_pan + last_vel_eye_vergence/2.0; |
372 |
float right = last_vel_eye_pan - last_vel_eye_vergence/2.0; |
373 |
|
374 |
//printf("> eye: velocity pan=%3.2f vergence=%3.2f --> L=%3.2f R=%3.2f\n", last_vel_eye_pan, last_vel_eye_vergence, left, right);
|
375 |
JointInterface::store_incoming_speed(ID_EYES_LEFT_LR, left, timestamp); |
376 |
JointInterface::store_incoming_speed(ID_EYES_RIGHT_LR, right, timestamp); |
377 |
break;
|
378 |
} |
379 |
|
380 |
case(ICUB_ID_EYES_VERGENCE): { //vergence |
381 |
last_vel_eye_pan = value; |
382 |
float left = last_vel_eye_pan + last_vel_eye_vergence/2.0; |
383 |
float right = last_vel_eye_pan - last_vel_eye_vergence/2.0; |
384 |
|
385 |
//printf("> eye: velocity pan=%3.2f vergence=%3.2f --> L=%3.2f R=%3.2f\n", last_vel_eye_pan, last_vel_eye_vergence, left, right);
|
386 |
JointInterface::store_incoming_speed(ID_EYES_LEFT_LR, left, timestamp); |
387 |
JointInterface::store_incoming_speed(ID_EYES_RIGHT_LR, right, timestamp); |
388 |
break;
|
389 |
} |
390 |
} |
391 |
} |
392 |
|
393 |
void iCubJointInterface::set_joint_enable_state(int e, bool enable) { |
394 |
int icub_jointid = -1; |
395 |
|
396 |
switch(e){
|
397 |
default:
|
398 |
break;
|
399 |
|
400 |
case(ID_NECK_PAN):
|
401 |
icub_jointid = ICUB_ID_NECK_PAN; |
402 |
break;
|
403 |
|
404 |
case(ID_NECK_TILT):
|
405 |
icub_jointid = ICUB_ID_NECK_TILT; |
406 |
break;
|
407 |
|
408 |
case(ID_NECK_ROLL):
|
409 |
icub_jointid = ICUB_ID_NECK_ROLL; |
410 |
break;
|
411 |
|
412 |
case(ID_EYES_BOTH_UD):
|
413 |
icub_jointid = ICUB_ID_EYES_BOTH_UD; |
414 |
break;
|
415 |
|
416 |
// icub handles eyes as pan angle + vergence...
|
417 |
// -> hack: left eye enables pan and right eye enables vergence
|
418 |
case(ID_EYES_LEFT_LR):
|
419 |
icub_jointid = ICUB_ID_EYES_PAN; |
420 |
break;
|
421 |
|
422 |
case(ID_EYES_RIGHT_LR):
|
423 |
icub_jointid = ICUB_ID_EYES_VERGENCE; |
424 |
break;
|
425 |
} |
426 |
|
427 |
if (icub_jointid != -1) { |
428 |
if (enable) {
|
429 |
amp->enableAmp(icub_jointid); |
430 |
pid->enablePid(icub_jointid); |
431 |
} else {
|
432 |
pid->disablePid(icub_jointid); |
433 |
amp->disableAmp(icub_jointid); |
434 |
} |
435 |
} |
436 |
} |
437 |
|
438 |
//! prepare and enable a joint
|
439 |
//! NOTE: this should also prefill the min/max positions for this joint
|
440 |
//! \param the enum id of a joint
|
441 |
void iCubJointInterface::enable_joint(int e){ |
442 |
set_joint_enable_state(e, true);
|
443 |
} |
444 |
|
445 |
//! shutdown and disable a joint
|
446 |
//! \param the enum id of a joint
|
447 |
void iCubJointInterface::disable_joint(int e){ |
448 |
set_joint_enable_state(e, false);
|
449 |
} |
450 |
|
451 |
void iCubJointInterface::store_min_max(IControlLimits *ilimits, int id, int e){ |
452 |
double min, max;
|
453 |
ilimits->getLimits(id, &min, &max); |
454 |
joint_min[e] = min; |
455 |
joint_max[e] = max; |
456 |
} |
457 |
|
458 |
//! initialise a joint (set up controller mode etc)
|
459 |
//! \param joint enum
|
460 |
void iCubJointInterface::init_joints(){
|
461 |
store_min_max(ilimits, ICUB_ID_NECK_TILT, ID_NECK_TILT); |
462 |
store_min_max(ilimits, ICUB_ID_NECK_ROLL, ID_NECK_ROLL); |
463 |
store_min_max(ilimits, ICUB_ID_NECK_PAN, ID_NECK_PAN); |
464 |
store_min_max(ilimits, ICUB_ID_EYES_BOTH_UD, ID_EYES_BOTH_UD); |
465 |
|
466 |
//icub handles eyes differently, we have to set pan angle + vergence
|
467 |
double pan_min, pan_max, vergence_min, vergence_max;
|
468 |
ilimits->getLimits(ICUB_ID_EYES_PAN, &pan_min, &pan_max); |
469 |
ilimits->getLimits(ICUB_ID_EYES_VERGENCE, &vergence_min, &vergence_max); |
470 |
|
471 |
//this is not 100% correct, should be fixed:
|
472 |
joint_min[ID_EYES_LEFT_LR] = pan_min; // - vergence_max/2;
|
473 |
joint_max[ID_EYES_LEFT_LR] = pan_max; // - vergence_max/2;
|
474 |
joint_min[ID_EYES_RIGHT_LR] = joint_min[ID_EYES_LEFT_LR]; |
475 |
joint_max[ID_EYES_RIGHT_LR] = joint_max[ID_EYES_LEFT_LR]; |
476 |
|
477 |
//eyelids:
|
478 |
joint_min[ID_EYES_RIGHT_LID_UPPER] = -50; //24-30; |
479 |
joint_max[ID_EYES_RIGHT_LID_UPPER] = 50; //48-30; |
480 |
//lid_angle = joint_max[ID_EYES_RIGHT_LID_UPPER];
|
481 |
|
482 |
//eyebrows:
|
483 |
joint_min[ID_EYES_LEFT_BROW] = -50;
|
484 |
joint_max[ID_EYES_LEFT_BROW] = 50;
|
485 |
joint_min[ID_EYES_RIGHT_BROW] = joint_min[ID_EYES_LEFT_BROW]; |
486 |
joint_max[ID_EYES_RIGHT_BROW] = joint_max[ID_EYES_LEFT_BROW]; |
487 |
|
488 |
//mouth:
|
489 |
joint_min[ID_LIP_CENTER_UPPER] = 5;
|
490 |
joint_max[ID_LIP_CENTER_UPPER] = 50;
|
491 |
joint_min[ID_LIP_CENTER_LOWER] = 5;
|
492 |
joint_max[ID_LIP_CENTER_LOWER] = 50;
|
493 |
joint_min[ID_LIP_LEFT_UPPER] = 5;
|
494 |
joint_max[ID_LIP_LEFT_UPPER] = 50;
|
495 |
joint_min[ID_LIP_LEFT_LOWER] = 5;
|
496 |
joint_max[ID_LIP_LEFT_LOWER] = 50;
|
497 |
joint_min[ID_LIP_RIGHT_UPPER] = 5;
|
498 |
joint_max[ID_LIP_RIGHT_UPPER] = 50;
|
499 |
joint_min[ID_LIP_RIGHT_LOWER] = 5;
|
500 |
joint_max[ID_LIP_RIGHT_LOWER] = 50;
|
501 |
|
502 |
|
503 |
} |