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