254 PolyDriver *_ddH, PolyDriver *_ddLL, PolyDriver *_ddLR,
255 PolyDriver *_ddT,
string _robot_name,
string _local_name,
257 ISixAxisForceTorqueSensors* m_left_arm_FT, ISixAxisForceTorqueSensors* m_right_arm_FT,
258 ISixAxisForceTorqueSensors* m_left_leg_FT, ISixAxisForceTorqueSensors* m_right_leg_FT):
259 PeriodicThread((double)_rate/1000.0), ddAL(_ddAL), ddAR(_ddAR), ddH(_ddH), ddLL(_ddLL),
260 ddLR(_ddLR), ddT(_ddT), robot_name(_robot_name), icub_type(_icub_type), local_name(_local_name),
261 zero_sens_tolerance (1
e-12), m_left_arm_FT(m_left_arm_FT), m_right_arm_FT(m_right_arm_FT),
262 m_left_leg_FT(m_left_leg_FT), m_right_leg_FT(m_right_leg_FT)
264 status_queue_size = 10;
265 autoconnect = _autoconnect;
277 skinContactsTimestamp = 0.0;
301 port_inertial_thread=
new BufferedPort<Vector>;
302 port_RATorques =
new BufferedPort<Bottle>;
303 port_LATorques =
new BufferedPort<Bottle>;
304 port_RLTorques =
new BufferedPort<Bottle>;
305 port_LLTorques =
new BufferedPort<Bottle>;
306 port_RWTorques =
new BufferedPort<Bottle>;
307 port_LWTorques =
new BufferedPort<Bottle>;
308 port_TOTorques =
new BufferedPort<Bottle>;
309 port_HDTorques =
new BufferedPort<Bottle>;
310 port_external_wrench_RA =
new BufferedPort<Vector>;
311 port_external_wrench_LA =
new BufferedPort<Vector>;
312 port_external_wrench_RL =
new BufferedPort<Vector>;
313 port_external_wrench_LL =
new BufferedPort<Vector>;
314 port_external_wrench_RF =
new BufferedPort<Vector>;
315 port_external_wrench_LF =
new BufferedPort<Vector>;
316#ifdef TEST_LEG_SENSOR
317 port_sensor_wrench_RL =
new BufferedPort<Vector>;
318 port_sensor_wrench_LL =
new BufferedPort<Vector>;
319 port_model_wrench_RL =
new BufferedPort<Vector>;
320 port_model_wrench_LL =
new BufferedPort<Vector>;
322 port_external_wrench_TO =
new BufferedPort<Vector>;
323 port_external_cartesian_wrench_RA =
new BufferedPort<Vector>;
324 port_external_cartesian_wrench_LA =
new BufferedPort<Vector>;
325 port_external_cartesian_wrench_RL =
new BufferedPort<Vector>;
326 port_external_cartesian_wrench_LL =
new BufferedPort<Vector>;
327 port_external_cartesian_wrench_RF =
new BufferedPort<Vector>;
328 port_external_cartesian_wrench_LF =
new BufferedPort<Vector>;
329 port_skin_contacts =
new BufferedPort<skinContactList>;
330 port_com_all =
new BufferedPort<Vector>;
331 port_com_lb =
new BufferedPort<Vector>;
332 port_com_ub =
new BufferedPort<Vector>;
333 port_com_la =
new BufferedPort<Vector>;
334 port_com_ra =
new BufferedPort<Vector>;
335 port_com_ll =
new BufferedPort<Vector>;
336 port_com_rl =
new BufferedPort<Vector>;
337 port_com_to =
new BufferedPort<Vector>;
338 port_com_hd =
new BufferedPort<Vector>;
339 port_com_all_foot =
new BufferedPort<Vector>;
340 port_monitor =
new BufferedPort<Vector>;
341 port_contacts =
new BufferedPort<skinContactList>;
342 port_dumpvel =
new BufferedPort<Vector>;
343 port_external_ft_arm_left =
new BufferedPort<Vector>;
344 port_external_ft_arm_right =
new BufferedPort<Vector>;
345 port_external_ft_leg_left =
new BufferedPort<Vector>;
346 port_external_ft_leg_right =
new BufferedPort<Vector>;
347 port_COM_vel =
new BufferedPort<Vector>;
348 port_COM_Jacobian =
new BufferedPort<Matrix>;
349 port_all_velocities =
new BufferedPort<Vector>;
350 port_all_positions =
new BufferedPort<Vector>;
351 port_root_position_mat =
new BufferedPort<Matrix>;
352 port_root_position_vec =
new BufferedPort<Vector>;
354 port_inertial_thread->open(
string(
"/"+local_name+
"/inertial:i").c_str());
355 port_RATorques->open(
string(
"/"+local_name+
"/right_arm/Torques:o").c_str());
356 port_LATorques->open(
string(
"/"+local_name+
"/left_arm/Torques:o").c_str());
357 port_RLTorques->open(
string(
"/"+local_name+
"/right_leg/Torques:o").c_str());
358 port_LLTorques->open(
string(
"/"+local_name+
"/left_leg/Torques:o").c_str());
359 port_RWTorques->open(
string(
"/"+local_name+
"/right_wrist/Torques:o").c_str());
360 port_LWTorques->open(
string(
"/"+local_name+
"/left_wrist/Torques:o").c_str());
361 port_TOTorques->open(
string(
"/"+local_name+
"/torso/Torques:o").c_str());
362 port_HDTorques->open(
string(
"/"+local_name+
"/head/Torques:o").c_str());
363 port_external_wrench_RA->open(
string(
"/"+local_name+
"/right_arm/endEffectorWrench:o").c_str());
364 port_external_wrench_LA->open(
string(
"/"+local_name+
"/left_arm/endEffectorWrench:o").c_str());
365 port_external_wrench_RL->open(
string(
"/"+local_name+
"/right_leg/endEffectorWrench:o").c_str());
366 port_external_wrench_LL->open(
string(
"/"+local_name+
"/left_leg/endEffectorWrench:o").c_str());
367 port_external_wrench_RF->open(
string(
"/"+local_name+
"/right_foot/endEffectorWrench:o").c_str());
368 port_external_wrench_LF->open(
string(
"/"+local_name+
"/left_foot/endEffectorWrench:o").c_str());
369#ifdef TEST_LEG_SENSOR
370 port_sensor_wrench_RL->open(
string(
"/"+local_name+
"/right_leg/sensorWrench:o").c_str());
371 port_sensor_wrench_LL->open(
string(
"/"+local_name+
"/left_leg/sensorWrench:o").c_str());
372 port_model_wrench_RL->open(
string(
"/"+local_name+
"/right_leg/modelWrench:o").c_str());
373 port_model_wrench_LL->open(
string(
"/"+local_name+
"/left_leg/modelWrench:o").c_str());
375 port_external_cartesian_wrench_RA->open(
string(
"/"+local_name+
"/right_arm/cartesianEndEffectorWrench:o").c_str());
376 port_external_cartesian_wrench_LA->open(
string(
"/"+local_name+
"/left_arm/cartesianEndEffectorWrench:o").c_str());
377 port_external_cartesian_wrench_RL->open(
string(
"/"+local_name+
"/right_leg/cartesianEndEffectorWrench:o").c_str());
378 port_external_cartesian_wrench_LL->open(
string(
"/"+local_name+
"/left_leg/cartesianEndEffectorWrench:o").c_str());
379 port_external_cartesian_wrench_RF->open(
string(
"/"+local_name+
"/right_foot/cartesianEndEffectorWrench:o").c_str());
380 port_external_cartesian_wrench_LF->open(
string(
"/"+local_name+
"/left_foot/cartesianEndEffectorWrench:o").c_str());
381 port_external_wrench_TO->open(
string(
"/"+local_name+
"/torso/Wrench:o").c_str());
382 port_com_all->open(
string(
"/"+local_name+
"/com:o").c_str());
383 port_com_lb->open (
string(
"/"+local_name+
"/lower_body/com:o").c_str());
384 port_com_ub->open (
string(
"/"+local_name+
"/upper_body/com:o").c_str());
385 port_com_la ->open(
string(
"/"+local_name+
"/left_arm/com:o").c_str());
386 port_com_ra ->open(
string(
"/"+local_name+
"/right_arm/com:o").c_str());
387 port_com_ll ->open(
string(
"/"+local_name+
"/left_leg/com:o").c_str());
388 port_com_rl ->open(
string(
"/"+local_name+
"/right_leg/com:o").c_str());
389 port_com_hd ->open(
string(
"/"+local_name+
"/head/com:o").c_str());
390 port_com_to ->open(
string(
"/"+local_name+
"/torso/com:o").c_str());
391 port_com_all_foot->open(
string(
"/"+local_name+
"/com_foot:o").c_str());
392 port_skin_contacts->open(
string(
"/"+local_name+
"/skin_contacts:i").c_str());
393 port_monitor->open(
string(
"/"+local_name+
"/monitor:o").c_str());
394 port_contacts->open(
string(
"/"+local_name+
"/contacts:o").c_str());
395 port_dumpvel->open(
string(
"/"+local_name+
"/va:o").c_str());
396 port_external_ft_arm_left->open(
string(
"/"+local_name+
"/left_arm/ext_ft_sens:o").c_str());
397 port_external_ft_arm_right->open(
string(
"/"+local_name+
"/right_arm/ext_ft_sens:o").c_str());
398 port_external_ft_leg_left->open(
string(
"/"+local_name+
"/left_leg/ext_ft_sens:o").c_str());
399 port_external_ft_leg_right->open(
string(
"/"+local_name+
"/right_leg/ext_ft_sens:o").c_str());
400 port_COM_vel->open(
string(
"/"+local_name+
"/com_vel:o").c_str());
401 port_COM_Jacobian->open(
string(
"/"+local_name+
"/com_jacobian:o").c_str());
402 port_all_velocities->open(
string(
"/"+local_name+
"/all_velocities:o").c_str());
403 port_all_positions->open(
string(
"/"+local_name+
"/all_positions:o").c_str());
404 port_root_position_mat->open(
string(
"/"+local_name+
"/root_position_mat:o").c_str());
405 port_root_position_vec->open(
string(
"/"+local_name+
"/root_position_vec:o").c_str());
407 yInfo (
"Waiting for port connections");
411 Network::connect(
string(
"/"+local_name+
"/filtered/inertial:o").c_str(),
string(
"/"+local_name+
"/inertial:i").c_str(),
"tcp",
false);
413 Network::connect(
string(
"/"+local_name+
"/left_arm/Torques:o").c_str(),
string(
"/"+robot_name+
"/joint_vsens/left_arm:i").c_str(),
"tcp",
false);
414 Network::connect(
string(
"/"+local_name+
"/right_arm/Torques:o").c_str(),
string(
"/"+robot_name+
"/joint_vsens/right_arm:i").c_str(),
"tcp",
false);
415 Network::connect(
string(
"/"+local_name+
"/left_leg/Torques:o").c_str(),
string(
"/"+robot_name+
"/joint_vsens/left_leg:i").c_str(),
"tcp",
false);
416 Network::connect(
string(
"/"+local_name+
"/right_leg/Torques:o").c_str(),
string(
"/"+robot_name+
"/joint_vsens/right_leg:i").c_str(),
"tcp",
false);
417 Network::connect(
string(
"/"+local_name+
"/torso/Torques:o").c_str(),
string(
"/"+robot_name+
"/joint_vsens/torso:i").c_str(),
"tcp",
false);
419 if (Network::exists(
string(
"/"+robot_name+
"/joint_vsens/left_wrist:i").c_str()))
420 Network::connect(
string(
"/"+local_name+
"/left_wrist/Torques:o").c_str(),
string(
"/"+robot_name+
"/joint_vsens/left_wrist:i").c_str(),
"tcp",
false);
421 if (Network::exists(
string(
"/"+robot_name+
"/joint_vsens/right_wrist:i").c_str()))
422 Network::connect(
string(
"/"+local_name+
"/right_wrist/Torques:o").c_str(),
string(
"/"+robot_name+
"/joint_vsens/right_wrist:i").c_str(),
"tcp",
false);
424 yInfo (
"Ports connected");
427 if (ddAL) {ddAL->view(iencs_arm_left); ddAL->view(iint_arm_left); ddAL->view(icmd_arm_left);}
428 if (ddAR) {ddAR->view(iencs_arm_right); ddAR->view(iint_arm_right); ddAR->view(icmd_arm_right);}
429 if (ddH) {ddH->view(iencs_head); ddH ->view(iint_head); ddH ->view(icmd_head);}
430 if (ddLL) {ddLL->view(iencs_leg_left); ddLL->view(iint_leg_left); ddLL->view(icmd_leg_left);}
431 if (ddLR) {ddLR->view(iencs_leg_right); ddLR->view(iint_leg_right); ddLR->view(icmd_leg_right);}
432 if (ddT) {ddT->view(iencs_torso); ddT ->view(iint_torso); ddT ->view(icmd_torso);}
447 F_ext_up.resize(6,3);
449 F_ext_low.resize(6,3);
451 F_ext_left_arm.resize(6,0.0);
452 F_ext_right_arm.resize(6,0.0);
453 F_ext_cartesian_left_arm.resize(6,0.0);
454 F_ext_cartesian_right_arm.resize(6,0.0);
455 F_ext_left_leg.resize(6,0.0);
456 F_ext_right_leg.resize(6,0.0);
457 F_ext_cartesian_left_leg.resize(6,0.0);
458 F_ext_cartesian_right_leg.resize(6,0.0);
459 F_ext_left_foot.resize(6,0.0);
460 F_ext_right_foot.resize(6,0.0);
461 F_ext_cartesian_left_foot.resize(6,0.0);
462 F_ext_cartesian_right_foot.resize(6,0.0);
463 com_jac.resize(6,32);
536 static int delay_check=0;
540 yWarning (
"network delays detected (%d/10)\n", delay_check);
543 yError (
"inverseDynamics thread lost connection with iCubInterface.\n");
553 F_LArm = -1.0 * (current_status.
ft_arm_left-Offset_LArm);
554 F_RArm = -1.0 * (current_status.
ft_arm_right-Offset_RArm);
555 F_LLeg = -1.0 * (current_status.
ft_leg_left-Offset_LLeg);
556 F_RLeg = -1.0 * (current_status.
ft_leg_right-Offset_RLeg);
557 F_LFoot = -1.0 * (current_status.
ft_foot_left-Offset_LFoot);
558 F_RFoot = -1.0 * (current_status.
ft_foot_right-Offset_RFoot);
566 not_moving_status.push_front(current_status);
567 if (not_moving_status.size()>status_queue_size)
569 not_moving_status.pop_back();
576 not_moving_status.clear();
593#ifdef DEBUG_PERFORMANCE
594 static double meanTime = 0.0;
595 static double startTime = 0;
596 startTime = Time::now();
601#ifdef DEBUG_PERFORMANCE
602 meanTime += Time::now()-startTime;
603 yDebug(
"Mean uppertorso NE time: %.4f\n", meanTime/getIterations());
607#ifdef DEBUG_KINEMATICS
609 yDebug (
"\nHEAD: %s \n", d2p0.toString().c_str());
619#ifdef DEBUG_KINEMATICS
621 yDebug (
"LOWTORSO->UP: %s *** %s *** %s\n",
624 cub->lowerTorso->up->getLinAcc(2).toString().c_str());
628 yDebug (
"LOWTORSO->RI: %s *** %s *** %s *** %s\n",
634 yDebug (
"LOWTORSO->LE: %s *** %s *** %s *** %s\n",
644 yDebug (
"LOWTORSO->UP: %s *** %s \n",
648 yDebug (
"LOWTORSO->RO: %s *** %s \n",
664 HDTorques[0] = HDtmp [0];
665 HDTorques[1] = HDtmp [1];
666 HDTorques[2] = HDtmp [2];
668 TOTorques[0] = TOtmp [2];
669 TOTorques[1] = TOtmp [1];
670 TOTorques[2] = TOtmp [0];
674 yDebug (
"TORQUES: %s *** \n\n", TOTorques.toString().c_str());
682 if (ddLR)
writeTorque(RLTorques, 2, port_RLTorques);
683 if (ddLL)
writeTorque(LLTorques, 2, port_LLTorques);
687 Vector com_all(7), com_ll(7), com_rl(7), com_la(7),com_ra(7), com_hd(7), com_to(7), com_lb(7), com_ub(7);
688 double mass_all , mass_ll , mass_rl , mass_la ,mass_ra , mass_hd, mass_to, mass_lb, mass_ub;
689 Vector com_v; com_v.resize(3); com_v.zero();
690 Vector all_dq; all_dq.resize(32,1); all_dq.zero();
691 Vector all_q; all_q.resize(32,1); all_q.zero();
694 yarp::sig::Vector com_all_foot; com_all_foot.resize(3); com_all_foot.zero();
695 yarp::sig::Matrix rTf; rTf.resize(4,4); rTf.zero();
696 yarp::sig::Matrix fTr; fTr.resize(4,4); fTr.zero();
697 yarp::sig::Matrix lastRotTrans; lastRotTrans.resize(4,4); lastRotTrans.zero();
698 lastRotTrans(2,0)=lastRotTrans(3,3)=lastRotTrans(0,2)=1;
699 lastRotTrans(1,1)=-1;
704 fTr.setSubmatrix(rTf.submatrix(0,2,0,2).transposed(), 0, 0);
705 fTr.setSubcol(-1*fTr.submatrix(0,2,0,2)*rTf.subcol(0,3,3), 0, 3);
709 lastRotTrans(1,3)=-rTf(1,3);
710 lastRotTrans(2,3)= -rTf(0,3);
734 com_lb.push_back(mass_lb);
735 com_ub.push_back(mass_ub);
736 com_all.push_back(mass_all);
737 com_ll.push_back (mass_ll);
738 com_rl.push_back (mass_rl);
739 com_la.push_back (mass_la);
740 com_ra.push_back (mass_ra);
741 com_hd.push_back (mass_hd);
742 com_to.push_back (mass_to);
746 com_all.push_back(com_v[0]);
747 com_all.push_back(com_v[1]);
748 com_all.push_back(com_v[2]);
752 com_all.push_back(0);
753 com_all.push_back(0);
754 com_all.push_back(0);
757 #ifdef MEASURE_FROM_FOOT
758 com_all_foot.setSubvector(0,com_all.subVector(0,2));
759 com_all_foot.push_back(1);
760 com_all_foot = fTr*com_all_foot;
766 mass_all=mass_ll=mass_rl=mass_la=mass_ra=mass_hd=mass_to=0.0;
767 com_all.zero(); com_ll.zero(); com_rl.zero(); com_la.zero(); com_ra.zero(); com_hd.zero(); com_to.zero();
773 dynContacts.insert(dynContacts.begin(), contactListR.begin(), contactListR.end());
776 bool contactFound=
false;
777 for(
unsigned int i=0; i<dynContacts.size(); i++)
779 cId = dynContacts[i].getId();
780 for(
unsigned int j=0; j<skinContacts.size(); j++)
782 if(cId == skinContacts[j].getId())
784 skinContacts[j].setForceMoment( dynContacts[i].getForceMoment() );
786 j = skinContacts.size();
791 skinContacts.push_back(
skinContact(dynContacts[i]));
792 contactFound =
false;
807 skinContacts.push_back(left_leg_contact);
808 skinContacts.push_back(right_leg_contact);
812 bool skin_lleg_found =
false;
813 bool skin_rleg_found =
false;
814 for(
unsigned int j=0; j<skinContacts.size(); j++)
818 skinContacts[j].setForceMoment(F_ext_left_leg);
819 skin_lleg_found =
true;
823 skinContacts[j].setForceMoment(F_ext_right_leg);
824 skin_rleg_found =
true;
827 if (!skin_rleg_found) {skinContacts.push_back(right_leg_contact);}
828 if (!skin_lleg_found) {skinContacts.push_back(left_leg_contact);}
832 F_ext_cartesian_left_arm = F_ext_cartesian_right_arm =
zeros(6);
833 F_ext_cartesian_left_leg = F_ext_cartesian_right_leg =
zeros(6);
841 F_ext_sens_right_arm = F_RArm - F_sensor_up.getCol(0);
842 F_ext_sens_left_arm = F_LArm - F_sensor_up.getCol(1);
844#ifdef TEST_LEG_SENSOR
845 setUpperMeasure(
true);
846 setLowerMeasure(
true);
850 F_ext_sens_right_leg = F_RLeg - F_sensor_low.getCol(0);
851 F_ext_sens_left_leg = F_LLeg - F_sensor_low.getCol(1);
853#ifdef TEST_LEG_SENSOR
854 F_mdl_right_leg = F_sensor_low.getCol(0);
855 F_mdl_left_leg = F_sensor_low.getCol(1);
856 F_sns_right_leg = F_RLeg;
857 F_sns_left_leg = F_LLeg;
866 yarp::sig::Vector tmp1,tmp2;
867 tmp1 = F_ext_left_arm.subVector(0,2); tmp1.push_back(0.0); tmp1 = ahl * tmp1;
868 tmp2 = F_ext_left_arm.subVector(3,5); tmp2.push_back(0.0); tmp2 = ahl * tmp2;
869 for (
int i=0; i<3; i++) F_ext_cartesian_left_arm[i] = tmp1[i];
870 for (
int i=3; i<6; i++) F_ext_cartesian_left_arm[i] = tmp2[i-3];
871 double n1=
norm(F_ext_cartesian_left_arm.subVector(0,2));
872 double n2=
norm(F_ext_cartesian_left_arm.subVector(3,5));
873 F_ext_cartesian_left_arm.push_back(n1);
874 F_ext_cartesian_left_arm.push_back(n2);
876 tmp1 = F_ext_right_arm.subVector(0,2); tmp1.push_back(0.0); tmp1 = ahr * tmp1;
877 tmp2 = F_ext_right_arm.subVector(3,5); tmp2.push_back(0.0); tmp2 = ahr * tmp2;
878 for (
int i=0; i<3; i++) F_ext_cartesian_right_arm[i] = tmp1[i];
879 for (
int i=3; i<6; i++) F_ext_cartesian_right_arm[i] = tmp2[i-3];
880 n1=
norm(F_ext_cartesian_right_arm.subVector(0,2));
881 n2=
norm(F_ext_cartesian_right_arm.subVector(3,5));
882 F_ext_cartesian_right_arm.push_back(n1);
883 F_ext_cartesian_right_arm.push_back(n2);
885 tmp1 = F_ext_left_leg.subVector(0,2); tmp1.push_back(0.0); tmp1 = lhl * tmp1;
886 tmp2 = F_ext_left_leg.subVector(3,5); tmp2.push_back(0.0); tmp2 = lhl * tmp2;
887 for (
int i=0; i<3; i++) F_ext_cartesian_left_leg[i] = tmp1[i];
888 for (
int i=3; i<6; i++) F_ext_cartesian_left_leg[i] = tmp2[i-3];
890 tmp1 = F_ext_right_leg.subVector(0,2); tmp1.push_back(0.0); tmp1 = lhr * tmp1;
891 tmp2 = F_ext_right_leg.subVector(3,5); tmp2.push_back(0.0); tmp2 = lhr * tmp2;
892 for (
int i=0; i<3; i++) F_ext_cartesian_right_leg[i] = tmp1[i];
893 for (
int i=3; i<6; i++) F_ext_cartesian_right_leg[i] = tmp2[i-3];
896 yarp::sig::Vector angles (3);
898 angles[1] = -90/180.0*
M_PI;
900 yarp::sig::Matrix r1 = yarp::math::euler2dcm(angles);
901 yarp::sig::Matrix ilhl = yarp::math::SE3inv(lhl);
902 yarp::sig::Matrix foot_root_mat = r1*ilhl;
904 yarp::sig::Vector foot_tmp = yarp::math::dcm2rpy(foot_root_mat);
906 yarp::sig::Vector foot_root_vec (6,0.0);
907 foot_root_vec[3] = foot_root_mat[0][3]*1000;
908 foot_root_vec[4] = foot_root_mat[1][3]*1000;
909 foot_root_vec[5] = foot_root_mat[2][3]*1000;
910 foot_root_vec[0] = foot_tmp[0]*180.0/
M_PI;
911 foot_root_vec[1] = foot_tmp[1]*180.0/
M_PI;
912 foot_root_vec[2] = foot_tmp[2]*180.0/
M_PI;
918 Matrix foot_hn(4,4); foot_hn.zero();
919 foot_hn(0,2)=1;foot_hn(0,3)=-7.75;
924 tmp1 = F_LFoot.subVector(0,2); tmp1.push_back(0.0); tmp1 = foot_hn * tmp1;
925 tmp2 = F_LFoot.subVector(3,5); tmp2.push_back(0.0); tmp2 = foot_hn * tmp2;
926 for (
int i=0; i<3; i++) F_ext_left_foot[i] = tmp1[i];
927 for (
int i=3; i<6; i++) F_ext_left_foot[i] = tmp2[i-3];
929 tmp1 = F_RFoot.subVector(0,2); tmp1.push_back(0.0); tmp1 = foot_hn * tmp1;
930 tmp2 = F_RFoot.subVector(3,5); tmp2.push_back(0.0); tmp2 = foot_hn * tmp2;
931 for (
int i=0; i<3; i++) F_ext_right_foot[i] = tmp1[i];
932 for (
int i=3; i<6; i++) F_ext_right_foot[i] = tmp2[i-3];
934 tmp1 = F_ext_left_foot.subVector(0,2); tmp1.push_back(0.0); tmp1 = lhl * tmp1;
935 tmp2 = F_ext_left_foot.subVector(3,5); tmp2.push_back(0.0); tmp2 = lhl * tmp2;
936 for (
int i=0; i<3; i++) F_ext_cartesian_left_foot[i] = tmp1[i];
937 for (
int i=3; i<6; i++) F_ext_cartesian_left_foot[i] = tmp2[i-3];
939 tmp1 = F_ext_right_foot.subVector(0,2); tmp1.push_back(0.0); tmp1 = lhr * tmp1;
940 tmp2 = F_ext_right_foot.subVector(3,5); tmp2.push_back(0.0); tmp2 = lhr * tmp2;
941 for (
int i=0; i<3; i++) F_ext_cartesian_right_foot[i] = tmp1[i];
942 for (
int i=3; i<6; i++) F_ext_cartesian_right_foot[i] = tmp2[i-3];
955 broadcastData<Vector> (com_v, port_COM_vel);
956 broadcastData<Vector> (all_dq, port_all_velocities);
957 broadcastData<Vector> (all_q, port_all_positions);
958 broadcastData<Matrix> (com_jac, port_COM_Jacobian);
960 broadcastData<Vector> (com_all, port_com_all);
961 broadcastData<Vector> (com_lb, port_com_lb);
962 broadcastData<Vector> (com_ub, port_com_ub);
963 broadcastData<Vector> (com_ll, port_com_ll);
964 broadcastData<Vector> (com_rl, port_com_rl);
965 broadcastData<Vector> (com_la, port_com_la);
966 broadcastData<Vector> (com_ra, port_com_ra);
967 broadcastData<Vector> (com_hd, port_com_hd);
968 broadcastData<Vector> (com_to, port_com_to);
969 broadcastData<Vector> (com_all_foot, port_com_all_foot);
971 broadcastData<Vector> (F_up, port_external_wrench_TO);
972 broadcastData<Vector> (F_ext_right_arm, port_external_wrench_RA);
973 broadcastData<Vector> (F_ext_left_arm, port_external_wrench_LA);
974 broadcastData<Vector> (F_ext_cartesian_right_arm, port_external_cartesian_wrench_RA);
975 broadcastData<Vector> (F_ext_cartesian_left_arm, port_external_cartesian_wrench_LA);
976 broadcastData<Vector> (F_ext_right_leg, port_external_wrench_RL);
977 broadcastData<Vector> (F_ext_left_leg, port_external_wrench_LL);
978 broadcastData<Vector> (F_ext_right_foot, port_external_wrench_RF);
979 broadcastData<Vector> (F_ext_left_foot, port_external_wrench_LF);
980#ifdef TEST_LEG_SENSOR
981 broadcastData<Vector> (F_sns_right_leg, port_sensor_wrench_RL);
982 broadcastData<Vector> (F_sns_left_leg, port_sensor_wrench_LL);
983 broadcastData<Vector> (F_mdl_right_leg, port_model_wrench_RL);
984 broadcastData<Vector> (F_mdl_left_leg, port_model_wrench_LL);
986 broadcastData<Vector> (F_ext_cartesian_right_leg, port_external_cartesian_wrench_RL);
987 broadcastData<Vector> (F_ext_cartesian_left_leg, port_external_cartesian_wrench_LL);
988 broadcastData<Vector> (F_ext_cartesian_right_foot, port_external_cartesian_wrench_RF);
989 broadcastData<Vector> (F_ext_cartesian_left_foot, port_external_cartesian_wrench_LF);
990 broadcastData<skinContactList>( skinContacts, port_contacts);
991 broadcastData<Vector> (F_ext_sens_right_arm, port_external_ft_arm_right);
992 broadcastData<Vector> (F_ext_sens_left_arm, port_external_ft_arm_left);
993 broadcastData<Vector> (F_ext_sens_right_leg, port_external_ft_leg_right);
994 broadcastData<Vector> (F_ext_sens_left_leg, port_external_ft_leg_left);
996 broadcastData<Matrix> (foot_root_mat, port_root_position_mat);
997 broadcastData<Vector> (foot_root_vec, port_root_position_vec);
1159 yInfo(
"calibrateOffset: starting calibration... \n");
1165 Offset_LFoot.zero();
1166 Offset_RFoot.zero();
1169 setUpperMeasure(
true);
1170 setLowerMeasure(
true);
1172 size_t Ntrials = previous_status.size();
1173 list<iCubStatus>::iterator it=previous_status.begin();
1180 for (it=previous_status.begin() ; it != previous_status.end(); it++ )
1187 F_iDyn_LArm = -1.0 * F_sensor_up.getCol(1);
1188 F_iDyn_RArm = -1.0 * F_sensor_up.getCol(0);
1189 F_iDyn_LLeg = -1.0 * F_sensor_low.getCol(1);
1190 F_iDyn_RLeg = -1.0 * F_sensor_low.getCol(0);
1191 F_iDyn_LFoot = Vector(6,0.0);
1192 F_iDyn_RFoot = Vector(6,0.0);
1194 Offset_LArm = Offset_LArm + (it->ft_arm_left-F_iDyn_LArm);
1195 Offset_RArm = Offset_RArm + (it->ft_arm_right-F_iDyn_RArm);
1196 Offset_LLeg = Offset_LLeg + (it->ft_leg_left-F_iDyn_LLeg);
1197 Offset_RLeg = Offset_RLeg + (it->ft_leg_right-F_iDyn_RLeg);
1198 Offset_LFoot = Offset_LFoot + (it->ft_foot_left-F_iDyn_LFoot);
1199 Offset_RFoot = Offset_RFoot + (it->ft_foot_right-F_iDyn_RFoot);
1202 Offset_LArm = 1.0/(double)Ntrials * Offset_LArm;
1203 Offset_RArm = 1.0/(double)Ntrials * Offset_RArm;
1204 Offset_LLeg = 1.0/(double)Ntrials * Offset_LLeg;
1205 Offset_RLeg = 1.0/(double)Ntrials * Offset_RLeg;
1206 Offset_LFoot = 1.0/(double)Ntrials * Offset_LFoot;
1207 Offset_RFoot = 1.0/(double)Ntrials * Offset_RFoot;
1209 it=previous_status.begin();
1211 yDebug(
"Ntrials: %d\n", (
int)Ntrials);
1212 yDebug(
"F_LArm: %s\n", it->ft_arm_left.toString().c_str());
1213 yDebug(
"F_idyn_LArm: %s\n", F_iDyn_LArm.toString().c_str());
1214 yDebug(
"F_RArm: %s\n", it->ft_arm_right.toString().c_str());
1215 yDebug(
"F_idyn_RArm: %s\n", F_iDyn_RArm.toString().c_str());
1216 yDebug(
"F_LLeg: %s\n", it->ft_leg_left.toString().c_str());
1217 yDebug(
"F_idyn_LLeg: %s\n", F_iDyn_LLeg.toString().c_str());
1218 yDebug(
"F_RLeg: %s\n", it->ft_leg_right.toString().c_str());
1219 yDebug(
"F_idyn_RLeg: %s\n", F_iDyn_RLeg.toString().c_str());
1221 yDebug(
"Left Arm: %s\n", Offset_LArm.toString().c_str());
1222 yDebug(
"Right Arm: %s\n", Offset_RArm.toString().c_str());
1223 yDebug(
"Left Leg: %s\n", Offset_LLeg.toString().c_str());
1224 yDebug(
"Right Leg: %s\n", Offset_RLeg.toString().c_str());
1225 yDebug(
"Left Foot: %s\n", Offset_LFoot.toString().c_str());
1226 yDebug(
"Right Foot: %s\n", Offset_RFoot.toString().c_str());