20 #ifdef FARSA_USE_YARP_AND_ICUB
24 #include "phycylinder.h"
25 #include "physphere.h"
28 #include "phyuniversal.h"
29 #include "phycompoundobject.h"
30 #include "motorcontrollers.h"
34 #pragma GCC diagnostic ignored "-Wunused-parameter"
36 #include "yarp/os/ResourceFinder.h"
37 #include "yarp/os/Bottle.h"
38 #include "yarp/os/Property.h"
39 #include "yarp/dev/PolyDriverList.h"
40 #include "yarp/dev/Wrapper.h"
41 #include "yarp/os/RateThread.h"
42 #include "yarp/os/Network.h"
44 #pragma GCC diagnostic warning "-Wunused-parameter"
47 using namespace yarp::os;
48 using namespace yarp::dev;
49 using namespace iCub::iKin;
56 #warning AD ELIO IL ROBOT DINAMICO BALLA MOLTO (DOPO QUALCHE STEP, CIRCA 350)
58 PhyiCub::PhyiCub(
World* world, QString name,
const wMatrix& torso0_tm,
bool createServerControlBoards) :
77 ignoreEyeSignals(false),
92 cartServLeftArm(NULL),
93 cartCtrlLeftArm(NULL),
94 cartSolvLeftArm(NULL),
95 cartThreadLeftArm(NULL),
96 cartServRightArm(NULL),
97 cartCtrlRightArm(NULL),
98 cartSolvRightArm(NULL),
101 enabledLeftLeg(true),
102 enabledRightLeg(true),
104 enabledLeftArm(true),
105 enabledRightArm(true),
107 enabledCameras(false),
108 blockedTorso0(false),
109 enabledRightKinematicHand(true),
110 enabledLeftKinematicHand(true),
111 enabledServerControlBoards(createServerControlBoards),
112 alwaysUpdateKinematicChains(false),
113 kinRightArm(
"right"),
115 kinRightLeg(
"right"),
117 kinRightEye(
"right"),
119 kinematicSimulation(false)
124 kinRightArm.setAllConstraints(
false);
125 kinLeftArm.setAllConstraints(
false);
126 kinRightLeg.setAllConstraints(
false);
127 kinLeftLeg.setAllConstraints(
false);
128 kinRightEye.setAllConstraints(
false);
129 kinLeftEye.setAllConstraints(
false);
142 for (
unsigned int i = 0; i < kinRightEye.getN(); i++) {
143 kinRightEye.setAng(i, 0.0);
145 for (
unsigned int i = 0; i < kinLeftEye.getN(); i++) {
146 kinLeftEye.setAng(i, 0.0);
148 for (
unsigned int i = 0; i < kinRightLeg.getN(); i++) {
149 kinRightLeg.setAng(i, 0.0);
151 for (
unsigned int i = 0; i < kinLeftLeg.getN(); i++) {
152 kinLeftLeg.setAng(i, 0.0);
154 for (
unsigned int i = 0; i < kinRightArm.getN(); i++) {
155 kinRightArm.setAng(i, 0.0);
157 for (
unsigned int i = 0; i < kinLeftArm.getN(); i++) {
158 kinLeftArm.setAng(i, 0.0);
185 PhyBox* torso0 =
new PhyBox( 0.11443f, 0.064f, 0.0470f, world, name+
":torso0" );
189 PhyBox* torso1 =
new PhyBox( 0.127f, 0.176f, 0.063f, world, name+
":torso1" );
197 QVector<PhyObject*> torsoCentre;
201 torsoCentre << torso3a;
202 PhyBox* torso3b =
new PhyBox( 0.1169f, 0.076f, 0.118f, world, name+
":torso3b" );
205 torsoCentre << torso3b;
206 PhyBox* torso3c =
new PhyBox( 0.1169f, 0.076f, 0.118f, world, name+
":torso3c" );
209 torsoCentre << torso3c;
229 real rotAng = PI_GRECO / 4.0f;
235 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
236 transl =
wVector(0.0, 0.0, 0.0);
242 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
245 rotAx =
wVector(1.0, 0.0, 0.0);
246 rotAng = PI_GRECO * 0.5f - PI_GRECO * 0.0833f;
247 transl =
wVector(0.0, 0.0, 0.0);
252 torsoJointv.resize(0);
270 leftLegv << leftLeg0;
274 leftLegv << leftLeg1;
277 QVector<PhyObject*> legsComp;
281 leftLeg2a->
setMass( 0.79206f );
282 legsComp << leftLeg2a;
285 legsComp << leftLeg2b;
287 leftLegv << leftLeg2;
293 leftLeg3a->
setMass( 0.14801f );
294 legsComp << leftLeg3a;
296 leftLeg3b->
setMass( 0.95262f );
297 legsComp << leftLeg3b;
299 leftLegv << leftLeg3;
303 leftLegv << leftLeg4;
305 PhyBox* leftLeg5 =
new PhyBox( 0.13f, 0.054f, 0.004f, world, name+
":leftLeg5" );
307 leftLegv << leftLeg5;
314 real rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
315 wVector transl =
wVector(0.0, -(leftLeg1->radius() + (leftLeg0->height() / 2.0)), 0.0);
320 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
321 transl =
wVector(0.0, 0.0, 0.0);
326 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
327 transl =
wVector(0.0, (leftLeg2b->height() / 2.0), 0.0);
332 mtr.w_pos =
wVector((leftLeg3b->height() / 2.0), 0.0, 0.0, 1.0);
336 rotAng = -PI_GRECO * 0.5f;
337 transl =
wVector(0.0, 0.0, 0.0105f);
342 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
343 transl =
wVector(leftLeg5->sideZ() / 2.0, 0.0, 0.0235f);
350 leftLegJointv.resize(0);
376 rightLeg0->
setMass( 0.32708f );
377 rightLegv << rightLeg0;
380 rightLeg1->
setMass( 0.85061f );
381 rightLegv << rightLeg1;
384 QVector<PhyObject*> legsComp;
388 rightLeg2a->
setMass( 0.79206f );
389 legsComp << rightLeg2a;
391 rightLeg2b->
setMass( 1.5304f );
392 legsComp << rightLeg2b;
394 rightLegv << rightLeg2;
400 rightLeg3a->
setMass( 0.14801f );
401 legsComp << rightLeg3a;
403 rightLeg3b->
setMass( 0.95262f );
404 legsComp << rightLeg3b;
406 rightLegv << rightLeg3;
409 rightLeg4->
setMass( 0.59285f );
410 rightLegv << rightLeg4;
412 PhyBox* rightLeg5 =
new PhyBox( 0.13f, 0.054f, 0.004f, world, name+
":rightLeg5" );
413 rightLeg5->
setMass( 0.08185f );
414 rightLegv << rightLeg5;
421 real rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
422 wVector transl =
wVector(0.0, -(rightLeg1->radius() + (rightLeg0->height() / 2.0)), 0.0);
427 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
428 transl =
wVector(0.0, 0.0, 0.0);
433 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
434 transl =
wVector(0.0, (rightLeg2b->height() / 2.0), 0.0);
439 mtr.w_pos =
wVector((rightLeg3b->height() / 2.0), 0.0, 0.0, 1.0);
443 rotAng = PI_GRECO * 0.5f;
444 transl =
wVector(0.0, 0.0, -0.0105f);
449 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
450 transl =
wVector(rightLeg5->sideZ() / 2.0f, 0.0, 0.0235f);
457 rightLegJointv.resize(0);
459 rightLegJointv << j1;
462 rightLegJointv << j2;
465 rightLegJointv << j3;
468 rightLegJointv << j4;
471 rightLegJointv << j5;
474 rightLegJointv << j6;
484 leftArmv << leftArm0;
488 leftArmv << leftArm1;
492 leftArmv << leftArm2;
495 #warning SAREBBE MEGLIO SE INVECE DELLA SFERA CI FOSSE UN CILINDRO CON L'ASSE DI ROTAZIONE SULL'ASSE DEL GIUNTO (IL SEGMENTO SUCCESSIVO SAREBBE POI DISASSATO)
498 leftArm3->
setMass( 0.050798f );
499 leftArmv << leftArm3;
503 leftArmv << leftArm4;
512 leftArmv << leftArm5;
539 PhyBox* leftArmPalm6 =
new PhyBox( leftArmPalm6X, 0.065f, 0.018f, world, name+
":leftArmPalm6" );
540 leftArmPalm6->
setMass( 0.19099f );
541 leftArmv << leftArmPalm6;
544 leftHandGroup =
new PhyObjectsGroup(leftArmPalm6, world, name+
":leftHandGroup");
545 leftHandGroup->
setOwner(
this,
false);
548 #warning ============= AREN T FINGER PIECES A BIT TOO HEAVY? =============
551 leftArmIndex7->
setMass( 0.2f );
552 leftArmv << leftArmIndex7;
555 leftArmMiddle8->
setMass( 0.2f );
556 leftArmv << leftArmMiddle8;
560 leftArmv << leftArmRing9;
563 leftArmPinky10->
setMass( 0.2f );
564 leftArmv << leftArmPinky10;
567 leftArmIndex11->
setMass( 0.2f );
568 leftArmv << leftArmIndex11;
571 leftArmMiddle12->
setMass( 0.2f );
572 leftArmv << leftArmMiddle12;
575 leftArmRing13->
setMass( 0.2f );
576 leftArmv << leftArmRing13;
579 leftArmPinky14->
setMass( 0.2f );
580 leftArmv << leftArmPinky14;
583 leftArmIndex15->
setMass( 0.2f );
584 leftArmv << leftArmIndex15;
587 leftArmMiddle16->
setMass( 0.2f );
588 leftArmv << leftArmMiddle16;
591 leftArmRing17->
setMass( 0.2f );
592 leftArmv << leftArmRing17;
595 leftArmPinky18->
setMass( 0.2f );
596 leftArmv << leftArmPinky18;
599 leftArmIndex19->
setMass( 0.2f );
600 leftArmv << leftArmIndex19;
603 leftArmMiddle20->
setMass( 0.2f );
604 leftArmv << leftArmMiddle20;
607 leftArmRing21->
setMass( 0.2f );
608 leftArmv << leftArmRing21;
611 leftArmPinky22->
setMass( 0.2f );
612 leftArmv << leftArmPinky22;
615 leftArmThumb23->
setMass( 0.2f );
616 leftArmv << leftArmThumb23;
619 leftArmThumb24->
setMass( 0.2f );
620 leftArmv << leftArmThumb24;
623 leftArmThumb25->
setMass( 0.2f );
624 leftArmv << leftArmThumb25;
627 leftArmThumb26->
setMass( 0.2f );
628 leftArmv << leftArmThumb26;
635 real rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
636 wVector transl =
wVector(0.0, leftArm0->height() / 2.0 + leftArm1->radius(), 0.0);
641 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
642 transl =
wVector(0.0, 0.0, 0.0);
647 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
648 transl =
wVector(0.0, leftArm2->height() / 2.0, 0.0);
656 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
657 transl =
wVector(0.0, -leftArm4->height() / 2.0, 0.0);
662 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
663 transl =
wVector(0.0, 0.0, 0.0);
668 mtr.w_pos =
wVector(-leftArmPalm6->sideX() / 2.0, 0.0, leftArmPalm6->sideZ() / 2.0, 1.0);
674 mtr = leftHandGroup->
matrix();
675 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmPalm6->sideX() + leftArmIndex7->height()) / 2.0f, -0.02275f, 0.0));
676 leftArmIndex7->setMatrix(mtr);
677 leftHandGroup->
addObject(leftArmIndex7, IndexChain);
678 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmIndex7->height() + leftArmIndex11->height()) / 2.0, 0.0, 0.0));
679 leftArmIndex11->setMatrix(mtr);
680 leftHandGroup->
addObject(leftArmIndex11, IndexChain);
681 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmIndex11->height() + leftArmIndex15->height()) / 2.0, 0.0, 0.0));
682 leftArmIndex15->setMatrix(mtr);
683 leftHandGroup->
addObject(leftArmIndex15, IndexChain);
684 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmIndex15->height() + leftArmIndex19->height()) / 2.0, 0.0, 0.0));
685 leftArmIndex19->setMatrix(mtr);
686 leftHandGroup->
addObject(leftArmIndex19, IndexChain);
689 mtr = leftHandGroup->
matrix();
690 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmPalm6->sideX() + leftArmMiddle8->height()) / 2.0, -0.0065f, 0.0));
691 leftArmMiddle8->setMatrix(mtr);
692 leftHandGroup->
addObject(leftArmMiddle8, MiddleChain);
693 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmMiddle8->height() + leftArmMiddle12->height()) / 2.0, 0.0, 0.0));
694 leftArmMiddle12->setMatrix(mtr);
695 leftHandGroup->
addObject(leftArmMiddle12, MiddleChain);
696 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmMiddle12->height() + leftArmMiddle16->height()) / 2.0, 0.0, 0.0));
697 leftArmMiddle16->setMatrix(mtr);
698 leftHandGroup->
addObject(leftArmMiddle16, MiddleChain);
699 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmMiddle16->height() + leftArmMiddle20->height()) / 2.0, 0.0, 0.0));
700 leftArmMiddle20->setMatrix(mtr);
701 leftHandGroup->
addObject(leftArmMiddle20, MiddleChain);
704 mtr = leftHandGroup->
matrix();
705 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmPalm6->sideX() + leftArmRing9->height()) / 2.0, 0.00975f, 0.0));
706 leftArmRing9->setMatrix(mtr);
707 leftHandGroup->
addObject(leftArmRing9, RingChain);
708 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmRing9->height() + leftArmRing13->height()) / 2.0, 0.0, 0.0));
709 leftArmRing13->setMatrix(mtr);
710 leftHandGroup->
addObject(leftArmRing13, RingChain);
711 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmRing13->height() + leftArmRing17->height()) / 2.0, 0.0, 0.0));
712 leftArmRing17->setMatrix(mtr);
713 leftHandGroup->
addObject(leftArmRing17, RingChain);
714 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmRing17->height() + leftArmRing21->height()) / 2.0, 0.0, 0.0));
715 leftArmRing21->setMatrix(mtr);
716 leftHandGroup->
addObject(leftArmRing21, RingChain);
719 mtr = leftHandGroup->
matrix();
720 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmPalm6->sideX() + leftArmPinky10->height()) / 2.0, 0.026f, 0.0));
721 leftArmPinky10->setMatrix(mtr);
722 leftHandGroup->
addObject(leftArmPinky10, PinkyChain);
723 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmPinky10->height() + leftArmPinky14->height()) / 2.0, 0.0, 0.0));
724 leftArmPinky14->setMatrix(mtr);
725 leftHandGroup->
addObject(leftArmPinky14, PinkyChain);
726 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmPinky14->height() + leftArmPinky18->height()) / 2.0, 0.0, 0.0));
727 leftArmPinky18->setMatrix(mtr);
728 leftHandGroup->
addObject(leftArmPinky18, PinkyChain);
729 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmPinky18->height() + leftArmPinky22->height()) / 2.0, 0.0, 0.0));
730 leftArmPinky22->setMatrix(mtr);
731 leftHandGroup->
addObject(leftArmPinky22, PinkyChain);
734 mtr = leftHandGroup->
matrix().
rotateAround(leftArmPalm6->matrix().z_ax, leftArmPalm6->matrix().w_pos, -PI_GRECO * 0.5f);
735 mtr.w_pos += mtr.
rotateVector(
wVector(0.015f + leftArmThumb23->height() / 2.0, leftArmPalm6->sideY() / 2.0 - 0.035f, -leftArmPalm6->sideZ() / 2.0));
736 leftArmThumb23->setMatrix(mtr);
737 leftHandGroup->
addObject(leftArmThumb23, ThumbChain);
738 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmThumb23->height() + leftArmThumb24->height()) / 2.0, 0.0, 0.0));
739 leftArmThumb24->setMatrix(mtr);
740 leftHandGroup->
addObject(leftArmThumb24, ThumbChain);
741 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmThumb24->height() + leftArmThumb25->height()) / 2.0, 0.0, 0.0));
742 leftArmThumb25->setMatrix(mtr);
743 leftHandGroup->
addObject(leftArmThumb25, ThumbChain);
744 mtr.w_pos += mtr.
rotateVector(
wVector((leftArmThumb25->height() + leftArmThumb26->height()) / 2.0, 0.0, 0.0));
745 leftArmThumb26->setMatrix(mtr);
746 leftHandGroup->
addObject(leftArmThumb26, ThumbChain);
751 leftArmJointv.resize(0);
783 leftArmJointv << j10;
787 leftArmJointv << j11;
791 leftArmJointv << j12;
795 leftArmJointv << j13;
799 leftArmJointv << j14;
803 leftArmJointv << j15;
807 leftArmJointv << j16;
811 leftArmJointv << j17;
815 leftArmJointv << j18;
819 leftArmJointv << j19;
823 leftArmJointv << j20;
827 leftArmJointv << j21;
831 leftArmJointv << j22;
835 leftArmJointv << j23;
839 leftArmJointv << j24;
843 leftArmJointv << j25;
847 leftArmJointv << j26;
851 leftArmJointv << j27;
855 connect( leftArmJointv[7]->dofs()[0], SIGNAL( changedPosition( real ) ),
856 leftArmJointv[9]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
857 connect( leftArmJointv[7]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
858 leftArmJointv[9]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
859 connect( leftArmJointv[7]->dofs()[0], SIGNAL( changedPosition( real ) ),
860 leftArmJointv[10]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
861 connect( leftArmJointv[7]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
862 leftArmJointv[10]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
864 connect( leftArmJointv[12]->dofs()[0], SIGNAL( changedPosition( real ) ),
865 leftArmJointv[13]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
866 connect( leftArmJointv[12]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
867 leftArmJointv[13]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
868 connect( leftArmJointv[15]->dofs()[0], SIGNAL( changedPosition( real ) ),
869 leftArmJointv[16]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
870 connect( leftArmJointv[15]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
871 leftArmJointv[16]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
872 connect( leftArmJointv[25]->dofs()[0], SIGNAL( changedPosition( real ) ),
873 leftArmJointv[26]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
874 connect( leftArmJointv[25]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
875 leftArmJointv[26]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
877 connect( leftArmJointv[17]->dofs()[0], SIGNAL( changedPosition( real ) ),
878 leftArmJointv[18]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
879 connect( leftArmJointv[17]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
880 leftArmJointv[18]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
881 connect( leftArmJointv[17]->dofs()[0], SIGNAL( changedPosition( real ) ),
882 leftArmJointv[19]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
883 connect( leftArmJointv[17]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
884 leftArmJointv[19]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
885 connect( leftArmJointv[17]->dofs()[0], SIGNAL( changedPosition( real ) ),
886 leftArmJointv[20]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
887 connect( leftArmJointv[17]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
888 leftArmJointv[20]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
889 connect( leftArmJointv[17]->dofs()[0], SIGNAL( changedPosition( real ) ),
890 leftArmJointv[21]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
891 connect( leftArmJointv[17]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
892 leftArmJointv[21]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
893 connect( leftArmJointv[17]->dofs()[0], SIGNAL( changedPosition( real ) ),
894 leftArmJointv[22]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
895 connect( leftArmJointv[17]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
896 leftArmJointv[22]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
905 rightArm0->
setMass( 0.48278f );
906 rightArmv << rightArm0;
909 rightArm1->
setMass( 0.20779f );
910 rightArmv << rightArm1;
914 rightArmv << rightArm2;
917 #warning SAREBBE MEGLIO SE INVECE DELLA SFERA CI FOSSE UN CILINDRO CON L'ASSE DI ROTAZIONE SULL'ASSE DEL GIUNTO (IL SEGMENTO SUCCESSIVO SAREBBE POI DISASSATO)
920 rightArm3->
setMass( 0.050798f );
921 rightArmv << rightArm3;
924 rightArm4->
setMass( 0.48774f );
925 rightArmv << rightArm4;
932 rightArmv << rightArm5;
940 PhyBox* rightArmPalm6 =
new PhyBox( rightArmPalm6X, 0.065f, 0.018f, world, name+
":rightArmPalm6" );
941 rightArmPalm6->
setMass( 0.19099f );
942 rightArmv << rightArmPalm6;
945 rightHandGroup =
new PhyObjectsGroup(rightArmPalm6, world, name+
":rightHandGroup");
946 rightHandGroup->
setOwner(
this,
false);
949 #warning ============= AREN T FINGER PIECES A BIT TOO HEAVY? =============
952 rightArmIndex7->
setMass( 0.2f );
953 rightArmv << rightArmIndex7;
956 rightArmMiddle8->
setMass( 0.2f );
957 rightArmv << rightArmMiddle8;
960 rightArmRing9->
setMass( 0.2f );
961 rightArmv << rightArmRing9;
964 rightArmPinky10->
setMass( 0.2f );
965 rightArmv << rightArmPinky10;
968 rightArmIndex11->
setMass( 0.2f );
969 rightArmv << rightArmIndex11;
972 rightArmMiddle12->
setMass( 0.2f );
973 rightArmv << rightArmMiddle12;
976 rightArmRing13->
setMass( 0.2f );
977 rightArmv << rightArmRing13;
980 rightArmPinky14->
setMass( 0.2f );
981 rightArmv << rightArmPinky14;
984 rightArmIndex15->
setMass( 0.2f );
985 rightArmv << rightArmIndex15;
988 rightArmMiddle16->
setMass( 0.2f );
989 rightArmv << rightArmMiddle16;
992 rightArmRing17->
setMass( 0.2f );
993 rightArmv << rightArmRing17;
996 rightArmPinky18->
setMass( 0.2f );
997 rightArmv << rightArmPinky18;
1000 rightArmIndex19->
setMass( 0.2f );
1001 rightArmv << rightArmIndex19;
1004 rightArmMiddle20->
setMass( 0.2f );
1005 rightArmv << rightArmMiddle20;
1008 rightArmRing21->
setMass( 0.2f );
1009 rightArmv << rightArmRing21;
1012 rightArmPinky22->
setMass( 0.2f );
1013 rightArmv << rightArmPinky22;
1016 rightArmThumb23->
setMass( 0.2f );
1017 rightArmv << rightArmThumb23;
1020 rightArmThumb24->
setMass( 0.2f );
1021 rightArmv << rightArmThumb24;
1024 rightArmThumb25->
setMass( 0.2f );
1025 rightArmv << rightArmThumb25;
1028 rightArmThumb26->
setMass( 0.2f );
1029 rightArmv << rightArmThumb26;
1036 real rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
1037 wVector transl =
wVector(0.0, rightArm0->height() / 2.0 + rightArm1->radius(), 0.0);
1042 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
1043 transl =
wVector(0.0, 0.0, 0.0);
1048 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
1049 transl =
wVector(0.0, -rightArm2->height() / 2.0, 0.0);
1057 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
1058 transl =
wVector(0.0, rightArm4->height() / 2.0, 0.0);
1063 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
1064 transl =
wVector(0.0, 0.0, 0.0);
1069 mtr.w_pos =
wVector(-rightArmPalm6->sideX() / 2.0, 0.0, -rightArmPalm6->sideZ() / 2.0, 1.0);
1075 mtr = rightArmPalm6->matrix();
1076 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmPalm6->sideX() + rightArmIndex7->height()) / 2.0f, -0.02275f, 0.0));
1077 rightArmIndex7->setMatrix(mtr);
1078 rightHandGroup->
addObject(rightArmIndex7, IndexChain);
1079 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmIndex7->height() + rightArmIndex11->height()) / 2.0, 0.0, 0.0));
1080 rightArmIndex11->setMatrix(mtr);
1081 rightHandGroup->
addObject(rightArmIndex11, IndexChain);
1082 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmIndex11->height() + rightArmIndex15->height()) / 2.0, 0.0, 0.0));
1083 rightArmIndex15->setMatrix(mtr);
1084 rightHandGroup->
addObject(rightArmIndex15, IndexChain);
1085 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmIndex15->height() + rightArmIndex19->height()) / 2.0, 0.0, 0.0));
1086 rightArmIndex19->setMatrix(mtr);
1087 rightHandGroup->
addObject(rightArmIndex19, IndexChain);
1090 mtr = rightArmPalm6->matrix();
1091 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmPalm6->sideX() + rightArmMiddle8->height()) / 2.0, -0.0065f, 0.0));
1092 rightArmMiddle8->setMatrix(mtr);
1093 rightHandGroup->
addObject(rightArmMiddle8, MiddleChain);
1094 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmMiddle8->height() + rightArmMiddle12->height()) / 2.0, 0.0, 0.0));
1095 rightArmMiddle12->setMatrix(mtr);
1096 rightHandGroup->
addObject(rightArmMiddle12, MiddleChain);
1097 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmMiddle12->height() + rightArmMiddle16->height()) / 2.0, 0.0, 0.0));
1098 rightArmMiddle16->setMatrix(mtr);
1099 rightHandGroup->
addObject(rightArmMiddle16, MiddleChain);
1100 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmMiddle16->height() + rightArmMiddle20->height()) / 2.0, 0.0, 0.0));
1101 rightArmMiddle20->setMatrix(mtr);
1102 rightHandGroup->
addObject(rightArmMiddle20, MiddleChain);
1105 mtr = rightArmPalm6->matrix();
1106 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmPalm6->sideX() + rightArmRing9->height()) / 2.0, 0.00975f, 0.0));
1107 rightArmRing9->setMatrix(mtr);
1108 rightHandGroup->
addObject(rightArmRing9, RingChain);
1109 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmRing9->height() + rightArmRing13->height()) / 2.0, 0.0, 0.0));
1110 rightArmRing13->setMatrix(mtr);
1111 rightHandGroup->
addObject(rightArmRing13, RingChain);
1112 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmRing13->height() + rightArmRing17->height()) / 2.0, 0.0, 0.0));
1113 rightArmRing17->setMatrix(mtr);
1114 rightHandGroup->
addObject(rightArmRing17, RingChain);
1115 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmRing17->height() + rightArmRing21->height()) / 2.0, 0.0, 0.0));
1116 rightArmRing21->setMatrix(mtr);
1117 rightHandGroup->
addObject(rightArmRing21, RingChain);
1120 mtr = rightArmPalm6->matrix();
1121 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmPalm6->sideX() + rightArmPinky10->height()) / 2.0, 0.026f, 0.0));
1122 rightArmPinky10->setMatrix(mtr);
1123 rightHandGroup->
addObject(rightArmPinky10, PinkyChain);
1124 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmPinky10->height() + rightArmPinky14->height()) / 2.0, 0.0, 0.0));
1125 rightArmPinky14->setMatrix(mtr);
1126 rightHandGroup->
addObject(rightArmPinky14, PinkyChain);
1127 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmPinky14->height() + rightArmPinky18->height()) / 2.0, 0.0, 0.0));
1128 rightArmPinky18->setMatrix(mtr);
1129 rightHandGroup->
addObject(rightArmPinky18, PinkyChain);
1130 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmPinky18->height() + rightArmPinky22->height()) / 2.0, 0.0, 0.0));
1131 rightArmPinky22->setMatrix(mtr);
1132 rightHandGroup->
addObject(rightArmPinky22, PinkyChain);
1135 mtr = rightArmPalm6->matrix().
rotateAround(rightArmPalm6->matrix().z_ax, rightArmPalm6->matrix().w_pos, -PI_GRECO * 0.5f);
1136 mtr.w_pos += mtr.
rotateVector(
wVector(0.015 + rightArmThumb23->height() / 2.0, rightArmPalm6->sideY() / 2.0 - 0.035, rightArmPalm6->sideZ() / 2.0));
1137 rightArmThumb23->setMatrix(mtr);
1138 rightHandGroup->
addObject(rightArmThumb23, ThumbChain);
1139 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmThumb23->height() + rightArmThumb24->height()) / 2.0, 0.0, 0.0));
1140 rightArmThumb24->setMatrix(mtr);
1141 rightHandGroup->
addObject(rightArmThumb24, ThumbChain);
1142 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmThumb24->height() + rightArmThumb25->height()) / 2.0, 0.0, 0.0));
1143 rightArmThumb25->setMatrix(mtr);
1144 rightHandGroup->
addObject(rightArmThumb25, ThumbChain);
1145 mtr.w_pos += mtr.
rotateVector(
wVector((rightArmThumb25->height() + rightArmThumb26->height()) / 2.0, 0.0, 0.0));
1146 rightArmThumb26->setMatrix(mtr);
1147 rightHandGroup->
addObject(rightArmThumb26, ThumbChain);
1152 rightArmJointv.resize(0);
1154 rightArmJointv << j1;
1157 rightArmJointv << j2;
1160 rightArmJointv << j3;
1163 rightArmJointv << j4;
1166 rightArmJointv << j5;
1169 rightArmJointv << j6;
1172 rightArmJointv << j7;
1176 rightArmJointv << j8;
1180 rightArmJointv << j9;
1184 rightArmJointv << j10;
1188 rightArmJointv << j11;
1192 rightArmJointv << j12;
1196 rightArmJointv << j13;
1200 rightArmJointv << j14;
1204 rightArmJointv << j15;
1208 rightArmJointv << j16;
1212 rightArmJointv << j17;
1216 rightArmJointv << j18;
1220 rightArmJointv << j19;
1224 rightArmJointv << j20;
1228 rightArmJointv << j21;
1232 rightArmJointv << j22;
1236 rightArmJointv << j23;
1240 rightArmJointv << j24;
1244 rightArmJointv << j25;
1248 rightArmJointv << j26;
1252 rightArmJointv << j27;
1256 connect( rightArmJointv[7]->dofs()[0], SIGNAL( changedPosition( real ) ),
1257 rightArmJointv[9]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
1258 connect( rightArmJointv[7]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
1259 rightArmJointv[9]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
1260 connect( rightArmJointv[7]->dofs()[0], SIGNAL( changedPosition( real ) ),
1261 rightArmJointv[10]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
1262 connect( rightArmJointv[7]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
1263 rightArmJointv[10]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
1265 connect( rightArmJointv[12]->dofs()[0], SIGNAL( changedPosition( real ) ),
1266 rightArmJointv[13]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
1267 connect( rightArmJointv[12]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
1268 rightArmJointv[13]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
1269 connect( rightArmJointv[15]->dofs()[0], SIGNAL( changedPosition( real ) ),
1270 rightArmJointv[16]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
1271 connect( rightArmJointv[15]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
1272 rightArmJointv[16]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
1273 connect( rightArmJointv[25]->dofs()[0], SIGNAL( changedPosition( real ) ),
1274 rightArmJointv[26]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
1275 connect( rightArmJointv[25]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
1276 rightArmJointv[26]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
1278 connect( rightArmJointv[17]->dofs()[0], SIGNAL( changedPosition( real ) ),
1279 rightArmJointv[18]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
1280 connect( rightArmJointv[17]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
1281 rightArmJointv[18]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
1282 connect( rightArmJointv[17]->dofs()[0], SIGNAL( changedPosition( real ) ),
1283 rightArmJointv[19]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
1284 connect( rightArmJointv[17]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
1285 rightArmJointv[19]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
1286 connect( rightArmJointv[17]->dofs()[0], SIGNAL( changedPosition( real ) ),
1287 rightArmJointv[20]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
1288 connect( rightArmJointv[17]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
1289 rightArmJointv[20]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
1290 connect( rightArmJointv[17]->dofs()[0], SIGNAL( changedPosition( real ) ),
1291 rightArmJointv[21]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
1292 connect( rightArmJointv[17]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
1293 rightArmJointv[21]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
1294 connect( rightArmJointv[17]->dofs()[0], SIGNAL( changedPosition( real ) ),
1295 rightArmJointv[22]->dofs()[0], SLOT( setDesiredPosition( real ) ), Qt::DirectConnection );
1296 connect( rightArmJointv[17]->dofs()[0], SIGNAL( changedLimits( real, real ) ),
1297 rightArmJointv[22]->dofs()[0], SLOT( setLimits( real, real ) ), Qt::DirectConnection );
1306 headNeck0->
setMass( 0.28252f );
1307 headNeckv << headNeck0;
1311 headNeckv << headNeck1;
1315 QVector<PhyObject*> headObj;
1318 headNeck2a->
setMass( 0.13913f );
1319 headObj << headNeck2a;
1320 PhyBox* headNeck2b =
new PhyBox( 0.052f,0.104f, 0.002f, world, name+
":headNeck2b" );
1321 headNeck2b->
setMass( 0.1562f );
1322 headObj << headNeck2b;
1323 PhyBox* headNeck2c =
new PhyBox( 0.052f,0.002f, 0.093f, world, name+
":headNeck2c" );
1324 headNeck2c->
setMass( 0.1562f );
1325 headObj << headNeck2c;
1326 PhyBox* headNeck2d =
new PhyBox( 0.052f,0.002f, 0.093f, world, name+
":headNeck2d" );
1327 headNeck2d->
setMass( 0.1562f );
1328 headObj << headNeck2d;
1329 PhyBox* headNeck2e =
new PhyBox( 0.032f, 0.104f, 0.002f, world, name+
":headNeck2e" );
1331 headObj << headNeck2e;
1332 PhyBox* headNeck2f =
new PhyBox( 0.025f, 0.011f, 0.026f, world, name+
":headNeck2f" );
1333 headNeck2f->
setMass( 0.0278f );
1334 headObj << headNeck2f;
1335 PhyBox* headNeck2g =
new PhyBox( 0.012f, 0.011f, 0.051f, world, name+
":headNeck2g" );
1337 headNeck2g->
setMass( 0.0278f );
1338 headObj << headNeck2g;
1339 PhyBox* headNeck2h =
new PhyBox( 0.012f, 0.02f, 0.022f, world, name+
":headNeck2h" );
1340 headNeck2h->
setMass( 0.0278f );
1341 headObj << headNeck2h;
1344 headObj << headNeck2i;
1347 headNeck2j->
setMass( 0.0387f );
1348 headObj << headNeck2j;
1350 headNeck2l->
setMass( 0.0234f );
1351 headObj << headNeck2l;
1354 headNeck2m->
setMass( 0.0387f );
1355 headObj << headNeck2m;
1357 headNeck2b->setPosition(
wVector( -0.0125f, 0.0, -0.011f ) );
1358 headNeck2c->setPosition(
wVector( -0.0125f, 0.052f, 0.0355f ) );
1359 headNeck2d->setPosition(
wVector( -0.0125f, -0.052f, 0.0355f ) );
1360 headNeck2e->setPosition(
wVector( -0.0125f, 0.0, 0.0355f ) );
1361 headNeck2f->setPosition(
wVector( 0.0275f, 0.0, -0.01f ) );
1362 headNeck2g->setPosition(
wVector( 0.05f, 0.0, 0.001f ) );
1363 headNeck2h->setPosition(
wVector( 0.064f, 0.0, 0.028f ) );
1364 headNeck2i->setPosition(
wVector( 0.049f, +0.034f, 0.052f ) );
1365 headNeck2j->setPosition(
wVector( 0.034f, +0.034f, 0.037f ) );
1366 headNeck2l->setPosition(
wVector( 0.049f, -0.034f, 0.052f ) );
1367 headNeck2m->setPosition(
wVector( 0.034f, -0.034f, 0.037f ) );
1369 headNeckv << headNeck2;
1372 headNeckEye3->
setMass( 0.0059678f );
1373 headNeckv << headNeckEye3;
1376 headNeckEye4->
setMass( 0.0234f );
1377 headNeckv << headNeckEye4;
1380 headNeckEye5->
setMass( 0.0234f );
1381 headNeckv << headNeckEye5;
1390 real rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
1396 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
1402 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
1406 rotAx =
wVector(0.0, 0.0, 1.0);
1408 transl =
wVector(0.0, 0.0, 0.0);
1413 rotAng = asin(
ramp( -1.0, +1.0, rotAx.
norm() ) );
1431 headNeckJointv.resize(0);
1433 headNeckJointv << j1;
1436 headNeckJointv << j2;
1439 headNeckJointv << j3;
1442 headNeckJointv << j4;
1445 headNeckJointv << j5;
1446 rightEyeDOF = j5->dofs()[0];
1449 headNeckJointv << j6;
1450 leftEyeDOF = j6->dofs()[0];
1461 connect(versionDOF, SIGNAL(changedLimits(real, real)),
this, SLOT(
versionChangedLimits(real, real)));
1467 connect(vergenceDOF, SIGNAL(changedLimits(real, real)),
this, SLOT(
vergenceChangedLimits(real, real)));
1473 connect(rightEyeDOF, SIGNAL(changedLimits(real, real)),
this, SLOT(
rightEyeChangedLimits(real, real)));
1479 connect(leftEyeDOF, SIGNAL(changedLimits(real, real)),
this, SLOT(
leftEyeChangedLimits(real, real)));
1483 kinRightArm.setAllConstraints(
true);
1484 kinLeftArm.setAllConstraints(
true);
1485 kinRightLeg.setAllConstraints(
true);
1486 kinLeftLeg.setAllConstraints(
true);
1487 kinRightEye.setAllConstraints(
true);
1488 kinLeftEye.setAllConstraints(
true);
1495 obj->setMaterial(
"iCubMaterial" );
1498 obj->setMaterial(
"iCubMaterial" );
1501 obj->setMaterial(
"iCubMaterial" );
1504 obj->setMaterial(
"iCubMaterial" );
1507 obj->setMaterial(
"iCubMaterial" );
1510 obj->setMaterial(
"iCubMaterial" );
1520 rf.configure(
"ICUB_ROOT", 0, NULL );
1521 rf.setVerbose(
false );
1524 QString phyiCubConfTmpl = qApp->applicationDirPath() +
"/../conf/worldsim/phyicub/%1";
1526 QString phyiCubConfTmpl = qApp->applicationDirPath() +
"/../share/FARSA/conf/worldsim/phyicub/%1";
1529 if ( QFile::exists(rf.findFile(
"icub_head_torso.ini").c_str()) ) {
1530 prop.fromConfigFile( rf.findFile(
"icub_head_torso.ini"), true );
1532 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_head_torso.ini").toAscii().data() );
1534 Bottle lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1535 Bottle lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1536 QVector<double> headMax(6), headMin(6), torsoMax(3), torsoMin(3);
1537 for(
int i=0; i<6; i++ ) {
1538 headMax[i] = lstM.get(i+1).asDouble();
1539 headMin[i] = lstm.get(i+1).asDouble();
1541 for(
int i=6; i<9; i++ ) {
1542 torsoMax[i-6] = lstM.get(i+1).asDouble();
1543 torsoMin[i-6] = lstm.get(i+1).asDouble();
1545 if ( QFile::exists(rf.findFile(
"icub_left_leg.ini").c_str()) ) {
1546 prop.fromConfigFile( rf.findFile(
"icub_left_leg.ini"), true );
1548 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_left_leg.ini").toAscii().data() );
1550 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1551 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1552 QVector<double> leftLegMax(6), leftLegMin(6);
1553 for(
int i=0; i<6; i++ ) {
1554 leftLegMax[i] = lstM.get(i+1).asDouble();
1555 leftLegMin[i] = lstm.get(i+1).asDouble();
1557 if ( QFile::exists(rf.findFile(
"icub_right_leg.ini").c_str()) ) {
1558 prop.fromConfigFile( rf.findFile(
"icub_right_leg.ini"), true );
1560 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_right_leg.ini").toAscii().data() );
1562 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1563 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1564 QVector<double> rightLegMax(6), rightLegMin(6);
1565 for(
int i=0; i<6; i++ ) {
1566 rightLegMax[i] = lstM.get(i+1).asDouble();
1567 rightLegMin[i] = lstm.get(i+1).asDouble();
1569 if ( QFile::exists(rf.findFile(
"icub_left_arm.ini").c_str()) ) {
1570 prop.fromConfigFile( rf.findFile(
"icub_left_arm.ini"), true );
1572 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_left_arm.ini").toAscii().data() );
1574 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1575 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1576 QVector<double> leftArmMax(16), leftArmMin(16);
1579 for(
int i=0; i<8; i++ ) {
1580 leftArmMax[i] = lstM.get(i+1).asDouble();
1581 leftArmMin[i] = lstm.get(i+1).asDouble();
1583 if ( QFile::exists(rf.findFile(
"icub_left_hand.ini").c_str()) ) {
1584 prop.fromConfigFile( rf.findFile(
"icub_left_hand.ini"), true );
1586 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_left_hand.ini").toAscii().data() );
1588 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1589 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1590 for(
int i=0; i<8; i++ ) {
1591 leftArmMax[8+i] = lstM.get(i+1).asDouble();
1592 leftArmMin[8+i] = lstm.get(i+1).asDouble();
1594 if ( QFile::exists(rf.findFile(
"icub_right_arm.ini").c_str()) ) {
1595 prop.fromConfigFile( rf.findFile(
"icub_right_arm.ini"), true );
1597 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_right_arm.ini").toAscii().data() );
1599 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1600 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1601 QVector<double> rightArmMax(16), rightArmMin(16);
1604 for(
int i=0; i<8; i++ ) {
1605 rightArmMax[i] = lstM.get(i+1).asDouble();
1606 rightArmMin[i] = lstm.get(i+1).asDouble();
1608 if ( QFile::exists(rf.findFile(
"icub_right_hand.ini").c_str()) ) {
1609 prop.fromConfigFile( rf.findFile(
"icub_right_hand.ini"), true );
1611 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_right_hand.ini").toAscii().data() );
1613 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1614 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1615 for(
int i=0; i<8; i++ ) {
1616 rightArmMax[8+i] = lstM.get(i+1).asDouble();
1617 rightArmMin[8+i] = lstm.get(i+1).asDouble();
1621 QVector<PhyDOF*> motors;
1626 for(
int i=0; i<torsoJointv.size(); i++ ) {
1627 motors << torsoJointv[i]->dofs()[0];
1628 motors[i]->setLimits(
toRad(torsoMin[i]),
toRad(torsoMax[i]) );
1629 motors[i]->enableLimits();
1633 kinRightArm.
getLinkInfo(torsoJointv.size() - i - 1).setiKinLinkLimits(
toRad(torsoMin[i]),
toRad(torsoMax[i]));
1637 if ( enabledServerControlBoards ) {
1640 counter += motors.size();
1644 motors << leftArmJointv[0]->dofs()[0];
1645 motors << leftArmJointv[1]->dofs()[0];
1646 motors << leftArmJointv[2]->dofs()[0];
1647 motors << leftArmJointv[3]->dofs()[0];
1648 motors << leftArmJointv[4]->dofs()[0];
1649 motors << leftArmJointv[5]->dofs()[0];
1650 motors << leftArmJointv[6]->dofs()[0];
1651 motors << leftArmJointv[7]->dofs()[0];
1652 motors << leftArmJointv[23]->dofs()[0];
1653 motors << leftArmJointv[24]->dofs()[0];
1654 motors << leftArmJointv[25]->dofs()[0];
1655 motors << leftArmJointv[11]->dofs()[0];
1656 motors << leftArmJointv[12]->dofs()[0];
1657 motors << leftArmJointv[14]->dofs()[0];
1658 motors << leftArmJointv[15]->dofs()[0];
1659 motors << leftArmJointv[17]->dofs()[0];
1662 for(
unsigned int i=0; i<16; i++ ) {
1665 leftArmCtrl->
setLimitsRaw( i, leftArmMin[i], leftArmMax[i] );
1667 leftArmCtrl->
setLimits( i, leftArmMin[i], leftArmMax[i] );
1670 if ((i + 3) < kinLeftArm.getN()) {
1686 leftArmCtrl->
setOwner(
this,
false);
1687 if ( enabledServerControlBoards ) {
1690 counter += motors.size();
1694 motors << rightArmJointv[0]->dofs()[0];
1695 motors << rightArmJointv[1]->dofs()[0];
1696 motors << rightArmJointv[2]->dofs()[0];
1697 motors << rightArmJointv[3]->dofs()[0];
1698 motors << rightArmJointv[4]->dofs()[0];
1699 motors << rightArmJointv[5]->dofs()[0];
1700 motors << rightArmJointv[6]->dofs()[0];
1701 motors << rightArmJointv[7]->dofs()[0];
1702 motors << rightArmJointv[23]->dofs()[0];
1703 motors << rightArmJointv[24]->dofs()[0];
1704 motors << rightArmJointv[25]->dofs()[0];
1705 motors << rightArmJointv[11]->dofs()[0];
1706 motors << rightArmJointv[12]->dofs()[0];
1707 motors << rightArmJointv[14]->dofs()[0];
1708 motors << rightArmJointv[15]->dofs()[0];
1709 motors << rightArmJointv[17]->dofs()[0];
1712 for(
unsigned int i=0; i<16; i++ ) {
1715 rightArmCtrl->
setLimitsRaw( i, rightArmMin[i], rightArmMax[i] );
1717 rightArmCtrl->
setLimits( i, rightArmMin[i], rightArmMax[i] );
1720 if ((i + 3) < kinRightArm.getN()) {
1736 rightArmCtrl->
setOwner(
this,
false);
1737 if ( enabledServerControlBoards ) {
1740 counter += motors.size();
1744 motors << headNeckJointv[0]->dofs()[0];
1745 motors << headNeckJointv[1]->dofs()[0];
1746 motors << headNeckJointv[2]->dofs()[0];
1747 motors << headNeckJointv[3]->dofs()[0];
1748 motors << versionDOF;
1749 motors << vergenceDOF;
1750 for(
int i=0; i<6; i++ ) {
1752 motors[i]->enableLimits();
1760 const real minEye =
max(headMin[4] + headMin[5], -179.99999);
1761 const real maxEye =
min(headMax[4] + headMax[5], +179.99999);
1762 headNeckJointv[4]->dofs()[0]->setLimits(
toRad(minEye),
toRad(maxEye) );
1763 headNeckJointv[4]->dofs()[0]->enableLimits();
1764 headNeckJointv[5]->dofs()[0]->setLimits(
toRad(minEye),
toRad(maxEye) );
1765 headNeckJointv[5]->dofs()[0]->enableLimits();
1770 headNeckCtrl->
setOwner(
this,
false);
1771 if ( enabledServerControlBoards ) {
1774 counter += motors.size();
1778 for(
int i=0; i<leftLegJointv.size(); i++ ) {
1779 motors << leftLegJointv[i]->dofs()[0];
1780 motors[i]->setLimits(
toRad(leftLegMin[i]),
toRad(leftLegMax[i]) );
1781 motors[i]->enableLimits();
1787 leftLegCtrl->
setOwner(
this,
false);
1788 if ( enabledServerControlBoards ) {
1791 counter += motors.size();
1795 for(
int i=0; i<rightLegJointv.size(); i++ ) {
1796 motors << rightLegJointv[i]->dofs()[0];
1797 motors[i]->setLimits(
toRad(rightLegMin[i]),
toRad(rightLegMax[i]) );
1798 motors[i]->enableLimits();
1804 rightLegCtrl->
setOwner(
this,
false);
1805 if ( enabledServerControlBoards ) {
1808 counter += motors.size();
1814 WMesh* mesh =
new WMesh( world, name+
":faceCover", matrix );
1823 foreach(
PhyJoint* joint, leftLegJointv ) {
1827 foreach(
PhyJoint* joint, rightLegJointv ) {
1831 foreach(
PhyJoint* joint, torsoJointv ) {
1835 foreach(
PhyJoint* joint, leftArmJointv ) {
1839 foreach(
PhyJoint* joint, rightArmJointv ) {
1843 foreach(
PhyJoint* joint, headNeckJointv ) {
1854 leftLegMasses.resize(0);
1856 mass += obj->
mass();
1857 leftLegMasses << obj->
mass();
1861 rightLegMasses.resize(0);
1863 mass += obj->
mass();
1864 rightLegMasses << obj->
mass();
1868 torsoMasses.resize(0);
1870 mass += obj->
mass();
1871 torsoMasses << obj->
mass();
1875 leftArmMasses.resize(0);
1877 mass += obj->
mass();
1878 leftArmMasses << obj->
mass();
1882 rightArmMasses.resize(0);
1884 mass += obj->
mass();
1885 rightArmMasses << obj->
mass();
1889 headNeckMasses.resize(0);
1891 mass += obj->
mass();
1892 headNeckMasses << obj->
mass();
1896 headNeckv[4]->setTexture(
"blueye" );
1897 headNeckv[5]->setTexture(
"blueye" );
1901 world->pushObject(
this );
1905 if ( cartCtrlLeftArm ) {
1907 delete cartServLeftArm;
1908 delete cartSolvLeftArm;
1910 if ( cartCtrlRightArm ) {
1912 delete cartServRightArm;
1913 delete cartSolvRightArm;
1915 if ( enabledServerControlBoards ) {
1917 QStringList servers;
1918 servers <<
"torso" <<
"left_arm" <<
"right_arm" <<
"head" <<
"left_leg" <<
"right_leg";
1919 foreach( QString srv, servers ) {
1927 delete rightArmCtrl;
1928 delete headNeckCtrl;
1930 delete rightLegCtrl;
1936 for(
int i=0; i<coversv.size(); i++ ) {
1937 delete (coversv[i]);
1939 foreach(
PhyJoint* joint, leftLegJointv ) {
1942 foreach(
PhyJoint* joint, rightLegJointv ) {
1945 foreach(
PhyJoint* joint, torsoJointv ) {
1948 foreach(
PhyJoint* joint, leftArmJointv ) {
1951 foreach(
PhyJoint* joint, rightArmJointv ) {
1954 foreach(
PhyJoint* joint, headNeckJointv ) {
1975 delete leftHandGroup;
1976 delete rightHandGroup;
1983 kinematicSimulation = k;
1984 collidingLeftHand = clh;
1985 collidingRightHand = crh;
1987 if (kinematicSimulation) {
1989 for (
int i = 0; i < leftLegJointv.size(); i++) {
1990 leftLegJointv[i]->enable(
false);
1992 for (
int i = 0; i < rightLegJointv.size(); i++) {
1993 rightLegJointv[i]->enable(
false);
1995 for (
int i = 0; i < torsoJointv.size(); i++) {
1996 torsoJointv[i]->enable(
false);
1998 for (
int i = 0; i < leftArmJointv.size(); i++) {
1999 if (collidingLeftHand && (i >= 6)) {
2000 leftArmJointv[i]->enable(
true);
2002 leftArmJointv[i]->enable(
false);
2005 for (
int i = 0; i < rightArmJointv.size(); i++) {
2006 if (collidingRightHand && (i >= 6)) {
2007 rightArmJointv[i]->enable(
true);
2009 rightArmJointv[i]->enable(
false);
2012 for (
int i = 0; i < headNeckJointv.size(); i++) {
2013 headNeckJointv[i]->enable(
false);
2017 for (
int i = 0; i < leftLegv.size(); i++) {
2018 leftLegv[i]->setKinematic(
true);
2020 for (
int i = 0; i < rightLegv.size(); i++) {
2021 rightLegv[i]->setKinematic(
true);
2023 for (
int i = 0; i < torsov.size(); i++) {
2024 torsov[i]->setKinematic(
true);
2026 for (
int i = 0; i < leftArmv.size(); i++) {
2027 if (collidingLeftHand) {
2029 leftArmv[i]->setKinematic(
true,
false);
2030 }
else if (i == 5) {
2031 leftArmv[i]->setKinematic(
true,
true);
2033 leftArmv[i]->setKinematic(
false);
2036 leftArmv[i]->setKinematic(
true,
false);
2039 for (
int i = 0; i < rightArmv.size(); i++) {
2040 if (collidingRightHand) {
2042 rightArmv[i]->setKinematic(
true,
false);
2043 }
else if (i == 5) {
2044 rightArmv[i]->setKinematic(
true,
true);
2046 rightArmv[i]->setKinematic(
false);
2049 rightArmv[i]->setKinematic(
true,
false);
2052 for (
int i = 0; i < headNeckv.size(); i++) {
2053 headNeckv[i]->setKinematic(
true);
2057 for (
int i = 0; i < leftLegv.size(); i++) {
2058 leftLegv[i]->setKinematic( !enabledLeftLeg );
2060 for (
int i = 0; i < rightLegv.size(); i++) {
2061 rightLegv[i]->setKinematic( !enabledRightLeg );
2063 for (
int i = 0; i < torsov.size(); i++) {
2064 torsov[i]->setKinematic( !enabledTorso );
2066 for (
int i = 0; i < leftArmv.size(); i++) {
2067 leftArmv[i]->setKinematic( !enabledLeftArm );
2069 for (
int i = 0; i < rightArmv.size(); i++) {
2070 rightArmv[i]->setKinematic( !enabledRightArm );
2072 for (
int i = 0; i < headNeckv.size(); i++) {
2073 headNeckv[i]->setKinematic( !enabledHead );
2077 for (
int i = 0; i < leftLegJointv.size(); i++) {
2078 leftLegJointv[i]->enable(enabledLeftLeg);
2079 if (enabledLeftLeg) {
2080 leftLegJointv[i]->updateJointInfo();
2083 for (
int i = 0; i < rightLegJointv.size(); i++) {
2084 rightLegJointv[i]->enable(enabledRightLeg);
2085 if (enabledRightLeg) {
2086 rightLegJointv[i]->updateJointInfo();
2089 for (
int i = 0; i < torsoJointv.size(); i++) {
2090 torsoJointv[i]->enable(enabledTorso);
2092 torsoJointv[i]->updateJointInfo();
2095 for (
int i = 0; i < leftArmJointv.size(); i++) {
2096 leftArmJointv[i]->enable(enabledLeftArm);
2097 if (enabledLeftArm) {
2098 leftArmJointv[i]->updateJointInfo();
2101 for (
int i = 0; i < rightArmJointv.size(); i++) {
2102 rightArmJointv[i]->enable(enabledRightArm);
2103 if (enabledRightArm) {
2104 rightArmJointv[i]->updateJointInfo();
2107 for (
int i = 0; i < headNeckJointv.size(); i++) {
2108 headNeckJointv[i]->enable(enabledHead);
2110 headNeckJointv[i]->updateJointInfo();
2119 #warning QUI ESPLODE (MATRICI DIVENTANO INVALIDE) SE CHIAMATA MOLTE VOLTE CON GLI STESSI ANGOLI. INOLTRE SUCCEDE MOLTO SPESSO CHE ESPLODA SE SIAMO IN CINEMATICO E LE MANI SONO ABILITATE (MENTRE SE LE MANI SONO DISABILITATE SUCCEDE MOLTO PIÙ DI RADO). PROVARE A RIPRODURRE QUESTA COSA PER CAPIRE DOVE STA IL PROBLEMA (CONTROLLARE SE QUESTO PROBLEMA C È ANCORA)
2122 #warning PROBLEMA DI GIANLUCA: IN UNA SIMULAZIONE DINAMICA, LA PRIMA CONFIGURE POSTURE FUNZIONA BENE (GLI ANGOLI LETTI DAGLI ENCODER IMMEDIATAMENTE DOPO LA CHIAMATA A QUESTA FUNZIONE SONO ESATTAMENTE QUELLI RICHIESTI), MENTRE LE SUCCESSIVE SONO MENO PRECISE. TRA CHIAMATE SUCCESSIVE A QUESTA FUNZIONE IL ROBOT VIENE MOSSO IN DINAMICA. FORSE O GIUNTI NON SONO RESETTATI BENE?
2129 for (QMap<int, real>::const_iterator it = jointSetup.begin(); it != jointSetup.end(); it++) {
2142 case left_shoulder_pitch:
2145 case left_shoulder_roll:
2148 case left_shoulder_yaw:
2154 case left_wrist_prosup:
2157 case left_wrist_pitch:
2160 case left_wrist_yaw:
2163 case right_shoulder_pitch:
2166 case right_shoulder_roll:
2169 case right_shoulder_yaw:
2175 case right_wrist_prosup:
2178 case right_wrist_pitch:
2181 case right_wrist_yaw:
2196 case eyes_version:
case eyes_vergence:
2201 if (jointSetup. contains(eyes_version)) {
2202 versionAngle =
toRad(jointSetup[eyes_version]);
2204 versionAngle = versionDOF->
position();
2207 if (jointSetup. contains(eyes_vergence)) {
2208 vergenceAngle =
toRad(jointSetup[eyes_vergence]);
2210 vergenceAngle = vergenceDOF->
position();
2222 case left_hip_pitch:
2234 case left_ankle_pitch:
2237 case left_ankle_roll:
2240 case right_hip_pitch:
2243 case right_hip_roll:
2252 case right_ankle_pitch:
2255 case right_ankle_roll:
2276 foreach(
PhyJoint* joint, leftLegJointv ) {
2279 foreach(
PhyJoint* joint, rightLegJointv ) {
2282 foreach(
PhyJoint* joint, torsoJointv ) {
2285 foreach(
PhyJoint* joint, leftArmJointv ) {
2288 foreach(
PhyJoint* joint, rightArmJointv ) {
2291 foreach(
PhyJoint* joint, headNeckJointv ) {
2297 for (QMap<int, real>::const_iterator it = jointSetup.begin(); it != jointSetup.end(); it++) {
2299 case left_hand_finger:
2304 case left_thumb_oppose:
2307 case left_thumb_proximal:
2310 case left_thumb_distal:
2314 case left_index_proximal:
2317 case left_index_distal:
2321 case left_middle_proximal:
2324 case left_middle_distal:
2336 case right_hand_finger:
2341 case right_thumb_oppose:
2344 case right_thumb_proximal:
2347 case right_thumb_distal:
2351 case right_index_proximal:
2354 case right_index_distal:
2358 case right_middle_proximal:
2361 case right_middle_distal:
2380 leftArmCtrl->
stop();
2381 rightArmCtrl->
stop();
2382 headNeckCtrl->
stop();
2383 leftLegCtrl->
stop();
2384 rightLegCtrl->
stop();
2426 if (kinematicSimulation) {
2427 bool torsoUpdated =
false;
2428 int lastLinkRight = -1;
2429 int lastLinkLeft = -1;
2430 if (enabledRightArm || alwaysUpdateKinematicChains) {
2431 if (enabledRightArm && collidingRightHand) {
2435 torsoUpdated =
true;
2437 if (enabledLeftArm || alwaysUpdateKinematicChains) {
2438 if (enabledLeftArm && collidingLeftHand) {
2442 torsoUpdated =
true;
2444 if (enabledRightLeg || alwaysUpdateKinematicChains) {
2447 if (enabledLeftLeg || alwaysUpdateKinematicChains) {
2450 if (enabledHead || alwaysUpdateKinematicChains) {
2453 torsoUpdated =
true;
2457 if (!torsoUpdated && enabledTorso) {
2462 if (!collidingRightHand && (enabledRightArm || alwaysUpdateKinematicChains)) {
2464 if (enabledRightKinematicHand) {
2468 if (!collidingLeftHand && (enabledLeftArm || alwaysUpdateKinematicChains)) {
2470 if (enabledLeftKinematicHand) {
2481 if (alwaysUpdateKinematicChains && !kinematicSimulation) {
2482 int upperBodyUpdateStartingChainLink = 3;
2483 if (!enabledTorso) {
2486 upperBodyUpdateStartingChainLink = 0;
2488 if (!enabledRightArm) {
2491 if (!enabledLeftArm) {
2494 if (!enabledRightLeg) {
2497 if (!enabledLeftLeg) {
2508 if ( enabledLeftLeg == b )
return;
2520 if ( enabledRightLeg == b )
return;
2521 enabledRightLeg = b;
2536 if ( enabledTorso == b )
return;
2539 for (
int i = 0; i < torsov.size(); i++) {
2540 torsov[i]->setStatic(
false);
2542 if (!kinematicSimulation) {
2543 for (
int i = 0; i < torsoJointv.size(); i++) {
2544 torsoJointv[i]->enable(
true);
2545 torsoJointv[i]->updateJointInfo();
2551 if (!kinematicSimulation) {
2552 for (
int i = 0; i < torsoJointv.size(); i++) {
2553 torsoJointv[i]->enable(
false);
2556 for (
int i = 0; i < torsov.size(); i++) {
2557 torsov[i]->setStatic(
true);
2563 if ( enabledHead == b )
return;
2575 if ( enabledCameras == b )
return;
2577 if ( b && !leftcam ) {
2578 leftcam =
new WCamera(
world(),
name()+
"/cam/left", headNeckv[5], 640, 480 );
2579 rightcam =
new WCamera(
world(),
name()+
"/cam/right", headNeckv[4], 640, 480 );
2581 if ( !b && leftcam ) {
2590 if ( enabledLeftArm == b )
return;
2602 if ( enabledRightArm == b )
return;
2603 enabledRightArm = b;
2614 if ( blockedTorso0 == b )
return;
2617 torsov[0]->setMass( 0 );
2619 torsov[0]->setMass( torsoMasses[0] );
2625 enabledLeftKinematicHand = b;
2630 enabledRightKinematicHand = b;
2633 YARP_DECLARE_PLUGINS( icubmod )
2634 void
PhyiCub::enableLeftArmCartesianController() {
2635 YARP_REGISTER_PLUGINS( icubmod );
2638 cartSolvLeftArm =
new iCubArmCartesianSolver(
2639 QString(
"%1/%2/cartesianSolver/left_arm" )
2640 .arg( world()->name() )
2644 Property options( QString(
"\
2648 (dof (1 1 1 1 1 1 1 1 1 1) ) \
2650 .arg( world()->name() )
2652 .toAscii().data() );
2653 cartSolvLeftArm->open( options );
2659 Property optServerLeftArm( QString(
"\
2660 (device cartesiancontrollerserver) \
2661 (GENERAL (ControllerName %1/%2/cartesianController/left_arm) \
2662 (ControllerPeriod 10) \
2663 (SolverNameToConnect %1/%2/cartesianSolver/left_arm) \
2664 (KinematicPart arm) \
2665 (KinematicType left) \
2666 (NumberOfDrivers 2)) \
2667 (DRIVER_0 (Key torso) (JointsOrder reversed)) \
2668 (DRIVER_1 (Key left_arm) (JointsOrder direct))" )
2669 .arg( world()->name() )
2671 .toAscii().data() );
2672 cartServLeftArm =
new PolyDriver();
2673 if ( !cartServLeftArm->open( optServerLeftArm ) ) {
2677 PolyDriverList listL;
2678 listL.push( polydriver(
"torso"),
"torso" );
2679 listL.push( polydriver(
"left_arm"),
"left_arm" );
2680 IMultipleWrapper *wrapperL;
2681 cartServLeftArm->view( wrapperL );
2682 if ( !wrapperL->attachAll(listL) ) {
2684 qDebug() <<
"Errore nell'attaccare i PolyDriver al Server Cartesiano";
2687 cartServLeftArm->view( cartCtrlLeftArm );
2695 YARP_REGISTER_PLUGINS( icubmod );
2698 cartSolvRightArm =
new iCubArmCartesianSolver(
2699 QString(
"%1/%2/cartesianSolver/right_arm" )
2704 Property options( QString(
"\
2711 .toAscii().data() );
2712 cartSolvRightArm->open( options );
2718 Property optServerRightArm( QString(
"\
2719 (device cartesiancontrollerserver) \
2720 (GENERAL (ControllerName %1/%2/cartesianController/right_arm) \
2721 (ControllerPeriod 10) \
2722 (SolverNameToConnect %1/%2/cartesianSolver/right_arm) \
2723 (KinematicPart arm) \
2724 (KinematicType right) \
2725 (NumberOfDrivers 2)) \
2726 (DRIVER_0 (Key torso) (JointsOrder reversed)) \
2727 (DRIVER_1 (Key right_arm) (JointsOrder direct))" )
2730 .toAscii().data() );
2731 cartServRightArm =
new PolyDriver();
2732 if ( !cartServRightArm->open( optServerRightArm ) ) {
2736 PolyDriverList listL;
2738 listL.push(
polydriver(
"right_arm"),
"right_arm" );
2739 IMultipleWrapper *wrapperL;
2740 cartServRightArm->view( wrapperL );
2741 if ( !wrapperL->attachAll(listL) ) {
2743 qDebug() <<
"Errore nell'attaccare i PolyDriver al Server Cartesiano";
2746 cartServRightArm->view( cartCtrlRightArm );
2767 foreach(
PhyJoint* joint, leftLegJointv ) {
2770 foreach(
PhyJoint* joint, rightLegJointv ) {
2773 foreach(
PhyJoint* joint, torsoJointv ) {
2776 foreach(
PhyJoint* joint, leftArmJointv ) {
2779 foreach(
PhyJoint* joint, rightArmJointv ) {
2782 foreach(
PhyJoint* joint, headNeckJointv ) {
2793 convertYarpMatrixToWorldMatrix(kinRightArm.getH0(), torso0Matrix);
2794 torso0Matrix = torso0Matrix *
tm;
2795 const real torso0Height = (
dynamic_cast<PhyBox*
>(torsov[0]))->sideX();
2799 torso0Matrix.w_pos +=
wVector(0.0, 0.0, kinRightLeg.getH0()(2, 3) + torso0Height / 4.0);
2800 torsov[0]->setMatrix(torso0Matrix);
2808 for (
int i = 0; i < objects.size(); i++) {
2809 objects[i]->setKinematic(
false);
2811 if (!kinematicSimulation) {
2812 for (
int i = 0; i < joints.size(); i++) {
2813 joints[i]->enable(
true);
2814 joints[i]->updateJointInfo();
2818 if (!kinematicSimulation) {
2819 for (
int i = 0; i < joints.size(); i++) {
2820 joints[i]->enable(
false);
2823 for (
int i = 0; i < objects.size(); i++) {
2824 objects[i]->setKinematic(
true);
2831 return -version - vergence;
2836 return -version + vergence;
2841 return (-left - right) / 2.0;
2846 return (left - right) / 2.0;
2851 const real lowEyeLimit = versionLow + vergenceLow;
2853 return (lowEyeLimit < -PI_GRECO) ? -(PI_GRECO - 0.000001) : lowEyeLimit;
2858 const real highEyeLimit = versionHigh + vergenceHigh;
2860 return (highEyeLimit > PI_GRECO) ? (PI_GRECO - 0.000001) : highEyeLimit;
2864 #warning I IGNORE CHANGES IN FORCE AND STIFFNESS OF THE VIRTUAL DOF BECAUSE I DON T KNOW HOW TO MAP THEM TO DOFS OF THE REAL JOINTS AND VICE-VERSA
2869 if (ignoreEyeSignals) {
2877 ignoreEyeSignals =
true;
2880 ignoreEyeSignals =
false;
2885 if (ignoreEyeSignals) {
2893 ignoreEyeSignals =
true;
2896 ignoreEyeSignals =
false;
2901 if (ignoreEyeSignals) {
2905 const real curVergence = vergenceDOF->
position();
2909 ignoreEyeSignals =
true;
2910 rightEyeDOF->setPosition(rightEyeAngle);
2911 leftEyeDOF->setPosition(leftEyeAngle);
2912 ignoreEyeSignals =
false;
2917 if (ignoreEyeSignals) {
2921 const real curVergenceVelocity = vergenceDOF->
velocity();
2925 ignoreEyeSignals =
true;
2926 rightEyeDOF->setVelocity(rightEyeVelocity);
2927 leftEyeDOF->setVelocity(leftEyeVelocity);
2928 ignoreEyeSignals =
false;
2933 if (ignoreEyeSignals) {
2937 real curVergenceLow, curVergenceHigh;
2938 vergenceDOF->
limits(curVergenceLow, curVergenceHigh);
2942 ignoreEyeSignals =
true;
2943 rightEyeDOF->
setLimits(eyeLow, eyeHigh);
2945 ignoreEyeSignals =
false;
2950 if (ignoreEyeSignals) {
2958 ignoreEyeSignals =
true;
2961 ignoreEyeSignals =
false;
2966 if (ignoreEyeSignals) {
2974 ignoreEyeSignals =
true;
2977 ignoreEyeSignals =
false;
2982 if (ignoreEyeSignals) {
2986 const real curVersion = versionDOF->
position();
2990 ignoreEyeSignals =
true;
2991 rightEyeDOF->setPosition(rightEyeAngle);
2992 leftEyeDOF->setPosition(leftEyeAngle);
2993 ignoreEyeSignals =
false;
2998 if (ignoreEyeSignals) {
3002 const real curVersionVelocity = versionDOF->
velocity();
3006 ignoreEyeSignals =
true;
3007 rightEyeDOF->setVelocity(rightEyeVelocity);
3008 leftEyeDOF->setVelocity(leftEyeVelocity);
3009 ignoreEyeSignals =
false;
3014 if (ignoreEyeSignals) {
3018 real curVersionLow, curVersionHigh;
3019 vergenceDOF->
limits(curVersionLow, curVersionHigh);
3023 ignoreEyeSignals =
true;
3024 rightEyeDOF->
setLimits(eyeLow, eyeHigh);
3026 ignoreEyeSignals =
false;
3031 if (ignoreEyeSignals) {
3035 const real curLeftEyeAngle = leftEyeDOF->
position();
3039 ignoreEyeSignals =
true;
3042 ignoreEyeSignals =
false;
3047 if (ignoreEyeSignals) {
3051 const real curLeftEyeVelocity = leftEyeDOF->
position();
3055 ignoreEyeSignals =
true;
3058 ignoreEyeSignals =
false;
3063 if (ignoreEyeSignals) {
3067 const real curLeftEyeAngle = leftEyeDOF->
position();
3071 ignoreEyeSignals =
true;
3072 versionDOF->setPosition(versionAngle);
3073 vergenceDOF->setPosition(vergenceAngle);
3074 ignoreEyeSignals =
false;
3079 if (ignoreEyeSignals) {
3083 const real curLeftEyeVelocity = leftEyeDOF->
position();
3087 ignoreEyeSignals =
true;
3088 versionDOF->setVelocity(versionVelocity);
3089 vergenceDOF->setVelocity(vergenceVelocity);
3090 ignoreEyeSignals =
false;
3102 if (ignoreEyeSignals) {
3106 const real curRightEyeAngle = rightEyeDOF->
position();
3110 ignoreEyeSignals =
true;
3113 ignoreEyeSignals =
false;
3118 if (ignoreEyeSignals) {
3122 const real curRightEyeVelocity = rightEyeDOF->
position();
3126 ignoreEyeSignals =
true;
3129 ignoreEyeSignals =
false;
3134 if (ignoreEyeSignals) {
3138 const real curRightEyeAngle = rightEyeDOF->
position();
3142 ignoreEyeSignals =
true;
3143 versionDOF->setPosition(versionAngle);
3144 vergenceDOF->setPosition(vergenceAngle);
3145 ignoreEyeSignals =
false;
3150 if (ignoreEyeSignals) {
3154 const real curRightEyeVelocity = rightEyeDOF->
position();
3158 ignoreEyeSignals =
true;
3159 versionDOF->setVelocity(versionVelocity);
3160 vergenceDOF->setVelocity(vergenceVelocity);
3161 ignoreEyeSignals =
false;
3172 #endif // FARSA_USE_YARP_AND_ICUB