humotion / examples / yarp_icub / src / icub_jointinterface.cpp @ d3aa8ab3
History | View | Annotate | Download (16.114 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 | d3aa8ab3 | Simon Schulz | cout << "store_icub_joint_target(" << icub_id << ", " << position << ", ..)\n"; |
172 | |||
173 | 6c028e11 | Simon Schulz | if (icub_id == ICUB_ID_NECK_PAN) {
|
174 | // icub uses an inverted neck pan specification
|
||
175 | position = -position; |
||
176 | velocity = -velocity; |
||
177 | } |
||
178 | d3aa8ab3 | Simon Schulz | |
179 | // store values
|
||
180 | 35b3ca25 | Simon Schulz | target_angle_[icub_id] = position; |
181 | target_velocity_[icub_id] = velocity; |
||
182 | 8c6c1163 | Simon Schulz | } |
183 | |||
184 | //! execute a move in velocity mode
|
||
185 | //! \param id of joint
|
||
186 | //! \param angle
|
||
187 | 35b3ca25 | Simon Schulz | void iCubJointInterface::set_target_in_velocitymode(int icub_id) { |
188 | // fetch humotion id from icub joint id
|
||
189 | 6c028e11 | Simon Schulz | int humotion_id = convert_icub_jointid_to_humotion(icub_id);
|
190 | 7adf90be | Simon Schulz | |
191 | 35b3ca25 | Simon Schulz | // fetch the target velocity
|
192 | float target_velocity = target_velocity_[icub_id];
|
||
193 | 7adf90be | Simon Schulz | |
194 | 35b3ca25 | Simon Schulz | float vmax = 150.0; |
195 | if (target_velocity > vmax) target_velocity = vmax;
|
||
196 | if (target_velocity < -vmax) target_velocity = -vmax;
|
||
197 | 497d9d24 | Simon Schulz | |
198 | 8c6c1163 | Simon Schulz | //execute:
|
199 | 7adf90be | Simon Schulz | //ivel->velocityMove(id, speed);
|
200 | 6c028e11 | Simon Schulz | /*if ((icub_id != ICUB_ID_NECK_PAN) &&
|
201 | 35b3ca25 | Simon Schulz | (icub_id != ICUB_ID_EYES_BOTH_UD) &&
|
202 | (icub_id != ICUB_ID_NECK_TILT) &&
|
||
203 | (icub_id != ICUB_ID_EYES_BOTH_UD) &&
|
||
204 | (icub_id != ICUB_ID_NECK_TILT)) {
|
||
205 | // limit to some joints for debugging...
|
||
206 | return;
|
||
207 | 6c028e11 | Simon Schulz | }*/
|
208 | 8c6c1163 | Simon Schulz | |
209 | 35b3ca25 | Simon Schulz | // we now add a pd control loop for velocity moves in order to handle position errors
|
210 | // TODO: add position interpolation into future. this requires to enable the velocity
|
||
211 | // broadcast in the torso and head ini file and fetch that velocity in the
|
||
212 | // icub_data_receiver as well. TODO: check if the can bus has enough bandwidth for that...
|
||
213 | |||
214 | // first: fetch the timstamp of the last known position
|
||
215 | humotion::Timestamp data_ts = get_ts_position(humotion_id).get_last_timestamp(); |
||
216 | |||
217 | // calculate position error:
|
||
218 | float position_error = target_angle_[icub_id] - get_ts_position(humotion_id).get_interpolated_value(data_ts);
|
||
219 | |||
220 | // calculate d term
|
||
221 | float error_d = (position_error - pv_mix_last_error_[icub_id]) / (framerate*1000.0); |
||
222 | pv_mix_last_error_[icub_id] = position_error; |
||
223 | |||
224 | // finally do a PD loop to get the target velocity
|
||
225 | float pv_mix_velocity = pv_mix_pid_p_[icub_id] * position_error
|
||
226 | + pv_mix_pid_p_[icub_id]*error_d |
||
227 | + target_velocity; |
||
228 | |||
229 | d3aa8ab3 | Simon Schulz | cout << "\n"
|
230 | << get_ts_position(humotion_id).get_interpolated_value(data_ts) << " "
|
||
231 | << target_angle_[icub_id] << " "
|
||
232 | << 123.4 << " " |
||
233 | << pv_mix_velocity << " "
|
||
234 | << target_velocity << " "
|
||
235 | << position_error << " "
|
||
236 | << icub_id << " PID\n";
|
||
237 | 35b3ca25 | Simon Schulz | |
238 | // execute velocity move
|
||
239 | yarp_ivel_->velocityMove(icub_id, pv_mix_velocity); |
||
240 | 8c6c1163 | Simon Schulz | } |
241 | |||
242 | //! actually execute the scheduled motion commands
|
||
243 | void iCubJointInterface::execute_motion(){
|
||
244 | |||
245 | 372eec67 | Simon Schulz | // set up neck and eye motion commands in velocitymode
|
246 | for(int i=ICUB_ID_NECK_TILT; i<=ICUB_ID_EYES_VERGENCE; i++){ |
||
247 | set_target_in_velocitymode(i); |
||
248 | 8c6c1163 | Simon Schulz | } |
249 | |||
250 | 1f748ce7 | Simon Schulz | // eyelids: unfortuantely the icub has only 1dof for eyelids
|
251 | // therefore we can only use an opening value
|
||
252 | float opening_left = target_angle_[ICUB_ID_EYES_LEFT_LID_UPPER]
|
||
253 | - target_angle_[ICUB_ID_EYES_LEFT_LID_LOWER]; |
||
254 | float opening_right = target_angle_[ICUB_ID_EYES_RIGHT_LID_UPPER]
|
||
255 | - target_angle_[ICUB_ID_EYES_RIGHT_LID_LOWER]; |
||
256 | float opening = (opening_left + opening_right) / 2.0; |
||
257 | // send it to icub face if
|
||
258 | face_interface_->set_eyelid_angle(opening); |
||
259 | 8c6c1163 | Simon Schulz | |
260 | //eyebrows are set using a special command as well:
|
||
261 | 35b3ca25 | Simon Schulz | face_interface_->set_eyebrow_angle(ICUB_ID_EYES_LEFT_BROW, target_angle_); |
262 | face_interface_->set_eyebrow_angle(ICUB_ID_EYES_RIGHT_BROW, target_angle_); |
||
263 | 8c6c1163 | Simon Schulz | |
264 | //mouth
|
||
265 | 35b3ca25 | Simon Schulz | face_interface_->set_mouth(target_angle_); |
266 | 8c6c1163 | Simon Schulz | |
267 | |||
268 | //store joint values which we do not handle on icub here:
|
||
269 | 35b3ca25 | Simon Schulz | double timestamp = humotion::Timestamp::now().to_seconds();
|
270 | JointInterface::store_incoming_position(ID_LIP_LEFT_UPPER, target_angle_[ICUB_ID_LIP_LEFT_UPPER], timestamp); |
||
271 | JointInterface::store_incoming_position(ID_LIP_LEFT_LOWER, target_angle_[ICUB_ID_LIP_LEFT_LOWER], timestamp); |
||
272 | JointInterface::store_incoming_position(ID_LIP_CENTER_UPPER, target_angle_[ICUB_ID_LIP_CENTER_UPPER], timestamp); |
||
273 | JointInterface::store_incoming_position(ID_LIP_CENTER_LOWER, target_angle_[ICUB_ID_LIP_CENTER_LOWER], timestamp); |
||
274 | JointInterface::store_incoming_position(ID_LIP_RIGHT_UPPER, target_angle_[ICUB_ID_LIP_RIGHT_UPPER], timestamp); |
||
275 | JointInterface::store_incoming_position(ID_LIP_RIGHT_LOWER, target_angle_[ICUB_ID_LIP_RIGHT_LOWER], timestamp); |
||
276 | 8c6c1163 | Simon Schulz | } |
277 | |||
278 | |||
279 | 372eec67 | Simon Schulz | void iCubJointInterface::set_joint_enable_state(int humotion_id, bool enable) { |
280 | int icub_jointid = convert_humotion_jointid_to_icub(humotion_id);
|
||
281 | /*
|
||
282 | 7adf90be | Simon Schulz | switch(e){
|
283 | default:
|
||
284 | break;
|
||
285 | 8c6c1163 | Simon Schulz | |
286 | 7adf90be | Simon Schulz | case(ID_NECK_PAN):
|
287 | icub_jointid = ICUB_ID_NECK_PAN;
|
||
288 | break;
|
||
289 | 8c6c1163 | Simon Schulz | |
290 | 7adf90be | Simon Schulz | case(ID_NECK_TILT):
|
291 | icub_jointid = ICUB_ID_NECK_TILT;
|
||
292 | break;
|
||
293 | 8c6c1163 | Simon Schulz | |
294 | 7adf90be | Simon Schulz | case(ID_NECK_ROLL):
|
295 | icub_jointid = ICUB_ID_NECK_ROLL;
|
||
296 | break;
|
||
297 | |||
298 | case(ID_EYES_BOTH_UD):
|
||
299 | icub_jointid = ICUB_ID_EYES_BOTH_UD;
|
||
300 | break;
|
||
301 | |||
302 | // icub handles eyes as pan angle + vergence...
|
||
303 | // -> hack: left eye enables pan and right eye enables vergence
|
||
304 | case(ID_EYES_LEFT_LR):
|
||
305 | icub_jointid = ICUB_ID_EYES_PAN;
|
||
306 | break;
|
||
307 | |||
308 | case(ID_EYES_RIGHT_LR):
|
||
309 | icub_jointid = ICUB_ID_EYES_VERGENCE;
|
||
310 | break;
|
||
311 | 8c6c1163 | Simon Schulz | }
|
312 | 372eec67 | Simon Schulz | */
|
313 | 8c6c1163 | Simon Schulz | |
314 | 372eec67 | Simon Schulz | if ((icub_jointid != -1) && (icub_jointid <= ICUB_ID_EYES_VERGENCE)) { |
315 | 7adf90be | Simon Schulz | if (enable) {
|
316 | 35b3ca25 | Simon Schulz | yarp_amp_->enableAmp(icub_jointid); |
317 | yarp_pid_->enablePid(icub_jointid); |
||
318 | 7adf90be | Simon Schulz | } else {
|
319 | 35b3ca25 | Simon Schulz | yarp_pid_->disablePid(icub_jointid); |
320 | yarp_amp_->disableAmp(icub_jointid); |
||
321 | 7adf90be | Simon Schulz | } |
322 | } |
||
323 | 8c6c1163 | Simon Schulz | } |
324 | |||
325 | //! prepare and enable a joint
|
||
326 | //! NOTE: this should also prefill the min/max positions for this joint
|
||
327 | //! \param the enum id of a joint
|
||
328 | void iCubJointInterface::enable_joint(int e){ |
||
329 | 7adf90be | Simon Schulz | set_joint_enable_state(e, true);
|
330 | } |
||
331 | 8c6c1163 | Simon Schulz | |
332 | 7adf90be | Simon Schulz | //! shutdown and disable a joint
|
333 | //! \param the enum id of a joint
|
||
334 | void iCubJointInterface::disable_joint(int e){ |
||
335 | set_joint_enable_state(e, false);
|
||
336 | 8c6c1163 | Simon Schulz | } |
337 | |||
338 | 372eec67 | Simon Schulz | void iCubJointInterface::store_min_max(yarp::dev::IControlLimits *ilimits, int icub_id){ |
339 | 8c6c1163 | Simon Schulz | double min, max;
|
340 | 372eec67 | Simon Schulz | int humotion_id = convert_icub_jointid_to_humotion(icub_id);
|
341 | |||
342 | ilimits->getLimits(icub_id, &min, &max); |
||
343 | joint_min[humotion_id] = min; |
||
344 | joint_max[humotion_id] = max; |
||
345 | 8c6c1163 | Simon Schulz | } |
346 | |||
347 | //! initialise a joint (set up controller mode etc)
|
||
348 | void iCubJointInterface::init_joints(){
|
||
349 | 372eec67 | Simon Schulz | store_min_max(yarp_ilimits_, ICUB_ID_NECK_TILT); |
350 | store_min_max(yarp_ilimits_, ICUB_ID_NECK_ROLL); |
||
351 | store_min_max(yarp_ilimits_, ICUB_ID_NECK_PAN); |
||
352 | store_min_max(yarp_ilimits_, ICUB_ID_EYES_BOTH_UD); |
||
353 | 8c6c1163 | Simon Schulz | |
354 | //icub handles eyes differently, we have to set pan angle + vergence
|
||
355 | double pan_min, pan_max, vergence_min, vergence_max;
|
||
356 | 35b3ca25 | Simon Schulz | yarp_ilimits_->getLimits(ICUB_ID_EYES_PAN, &pan_min, &pan_max); |
357 | yarp_ilimits_->getLimits(ICUB_ID_EYES_VERGENCE, &vergence_min, &vergence_max); |
||
358 | 8c6c1163 | Simon Schulz | |
359 | //this is not 100% correct, should be fixed:
|
||
360 | joint_min[ID_EYES_LEFT_LR] = pan_min; // - vergence_max/2;
|
||
361 | joint_max[ID_EYES_LEFT_LR] = pan_max; // - vergence_max/2;
|
||
362 | joint_min[ID_EYES_RIGHT_LR] = joint_min[ID_EYES_LEFT_LR]; |
||
363 | joint_max[ID_EYES_RIGHT_LR] = joint_max[ID_EYES_LEFT_LR]; |
||
364 | |||
365 | //eyelids:
|
||
366 | joint_min[ID_EYES_RIGHT_LID_UPPER] = -50; //24-30; |
||
367 | joint_max[ID_EYES_RIGHT_LID_UPPER] = 50; //48-30; |
||
368 | 0d0f5ca1 | Simon Schulz | //lid_angle = joint_max[ID_EYES_RIGHT_LID_UPPER];
|
369 | 8c6c1163 | Simon Schulz | |
370 | //eyebrows:
|
||
371 | joint_min[ID_EYES_LEFT_BROW] = -50;
|
||
372 | joint_max[ID_EYES_LEFT_BROW] = 50;
|
||
373 | joint_min[ID_EYES_RIGHT_BROW] = joint_min[ID_EYES_LEFT_BROW]; |
||
374 | joint_max[ID_EYES_RIGHT_BROW] = joint_max[ID_EYES_LEFT_BROW]; |
||
375 | |||
376 | //mouth:
|
||
377 | joint_min[ID_LIP_CENTER_UPPER] = 5;
|
||
378 | joint_max[ID_LIP_CENTER_UPPER] = 50;
|
||
379 | joint_min[ID_LIP_CENTER_LOWER] = 5;
|
||
380 | joint_max[ID_LIP_CENTER_LOWER] = 50;
|
||
381 | joint_min[ID_LIP_LEFT_UPPER] = 5;
|
||
382 | joint_max[ID_LIP_LEFT_UPPER] = 50;
|
||
383 | joint_min[ID_LIP_LEFT_LOWER] = 5;
|
||
384 | joint_max[ID_LIP_LEFT_LOWER] = 50;
|
||
385 | joint_min[ID_LIP_RIGHT_UPPER] = 5;
|
||
386 | joint_max[ID_LIP_RIGHT_UPPER] = 50;
|
||
387 | joint_min[ID_LIP_RIGHT_LOWER] = 5;
|
||
388 | joint_max[ID_LIP_RIGHT_LOWER] = 50;
|
||
389 | 35b3ca25 | Simon Schulz | } |
390 | |||
391 | //! conversion table for humotion joint id to icub joint id
|
||
392 | //! \param int value for humotion joint id from JointInterface::JOINT_ID_ENUM
|
||
393 | //! \return int value of icub joint id
|
||
394 | int iCubJointInterface::convert_humotion_jointid_to_icub(int humotion_id){ |
||
395 | enum_id_bimap_t::right_const_iterator it = enum_id_bimap.right.find(humotion_id); |
||
396 | if(it == enum_id_bimap.right.end()) {
|
||
397 | //key does not exist
|
||
398 | 372eec67 | Simon Schulz | cerr << "ERROR: invalid humotion joint id (" << humotion_id << ") given. can not convert this. exiting\n"; |
399 | 35b3ca25 | Simon Schulz | exit(EXIT_FAILURE); |
400 | } |
||
401 | return it->second;
|
||
402 | } |
||
403 | 8c6c1163 | Simon Schulz | |
404 | |||
405 | 35b3ca25 | Simon Schulz | //! conversion table for icub joint id to humotion joint id
|
406 | //! \param int value of icub joint id
|
||
407 | //! \return int value of humotion joint id from JointInterface::JOINT_ID_ENUM
|
||
408 | int iCubJointInterface::convert_icub_jointid_to_humotion(int icub_id){ |
||
409 | enum_id_bimap_t::left_const_iterator it = enum_id_bimap.left.find(icub_id); |
||
410 | if(it == enum_id_bimap.left.end()) {
|
||
411 | //key does not exist
|
||
412 | cout << "ERROR: invalid icub joint id given. can not convert this. exiting\n";
|
||
413 | exit(EXIT_FAILURE); |
||
414 | } |
||
415 | return it->second;
|
||
416 | 8c6c1163 | Simon Schulz | } |