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 phyiCubConfTmpl = QDir::toNativeSeparators(QDir::cleanPath(phyiCubConfTmpl));
1531 if ( QFile::exists(rf.findFile(
"icub_head_torso.ini").c_str()) ) {
1532 prop.fromConfigFile( rf.findFile(
"icub_head_torso.ini"), true );
1534 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_head_torso.ini").toAscii().data() );
1536 Bottle lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1537 Bottle lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1538 QVector<double> headMax(6), headMin(6), torsoMax(3), torsoMin(3);
1539 for(
int i=0; i<6; i++ ) {
1540 headMax[i] = lstM.get(i+1).asDouble();
1541 headMin[i] = lstm.get(i+1).asDouble();
1543 for(
int i=6; i<9; i++ ) {
1544 torsoMax[i-6] = lstM.get(i+1).asDouble();
1545 torsoMin[i-6] = lstm.get(i+1).asDouble();
1547 if ( QFile::exists(rf.findFile(
"icub_left_leg.ini").c_str()) ) {
1548 prop.fromConfigFile( rf.findFile(
"icub_left_leg.ini"), true );
1550 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_left_leg.ini").toAscii().data() );
1552 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1553 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1554 QVector<double> leftLegMax(6), leftLegMin(6);
1555 for(
int i=0; i<6; i++ ) {
1556 leftLegMax[i] = lstM.get(i+1).asDouble();
1557 leftLegMin[i] = lstm.get(i+1).asDouble();
1559 if ( QFile::exists(rf.findFile(
"icub_right_leg.ini").c_str()) ) {
1560 prop.fromConfigFile( rf.findFile(
"icub_right_leg.ini"), true );
1562 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_right_leg.ini").toAscii().data() );
1564 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1565 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1566 QVector<double> rightLegMax(6), rightLegMin(6);
1567 for(
int i=0; i<6; i++ ) {
1568 rightLegMax[i] = lstM.get(i+1).asDouble();
1569 rightLegMin[i] = lstm.get(i+1).asDouble();
1571 if ( QFile::exists(rf.findFile(
"icub_left_arm.ini").c_str()) ) {
1572 prop.fromConfigFile( rf.findFile(
"icub_left_arm.ini"), true );
1574 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_left_arm.ini").toAscii().data() );
1576 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1577 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1578 QVector<double> leftArmMax(16), leftArmMin(16);
1581 for(
int i=0; i<8; i++ ) {
1582 leftArmMax[i] = lstM.get(i+1).asDouble();
1583 leftArmMin[i] = lstm.get(i+1).asDouble();
1585 if ( QFile::exists(rf.findFile(
"icub_left_hand.ini").c_str()) ) {
1586 prop.fromConfigFile( rf.findFile(
"icub_left_hand.ini"), true );
1588 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_left_hand.ini").toAscii().data() );
1590 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1591 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1592 for(
int i=0; i<8; i++ ) {
1593 leftArmMax[8+i] = lstM.get(i+1).asDouble();
1594 leftArmMin[8+i] = lstm.get(i+1).asDouble();
1596 if ( QFile::exists(rf.findFile(
"icub_right_arm.ini").c_str()) ) {
1597 prop.fromConfigFile( rf.findFile(
"icub_right_arm.ini"), true );
1599 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_right_arm.ini").toAscii().data() );
1601 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1602 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1603 QVector<double> rightArmMax(16), rightArmMin(16);
1606 for(
int i=0; i<8; i++ ) {
1607 rightArmMax[i] = lstM.get(i+1).asDouble();
1608 rightArmMin[i] = lstm.get(i+1).asDouble();
1610 if ( QFile::exists(rf.findFile(
"icub_right_hand.ini").c_str()) ) {
1611 prop.fromConfigFile( rf.findFile(
"icub_right_hand.ini"), true );
1613 prop.fromConfigFile( phyiCubConfTmpl.arg(
"icub_right_hand.ini").toAscii().data() );
1615 lstM = prop.findGroup(
"LIMITS").findGroup(
"Max");
1616 lstm = prop.findGroup(
"LIMITS").findGroup(
"Min");
1617 for(
int i=0; i<8; i++ ) {
1618 rightArmMax[8+i] = lstM.get(i+1).asDouble();
1619 rightArmMin[8+i] = lstm.get(i+1).asDouble();
1623 QVector<PhyDOF*> motors;
1628 for(
int i=0; i<torsoJointv.size(); i++ ) {
1629 motors << torsoJointv[i]->dofs()[0];
1630 motors[i]->setLimits(
toRad(torsoMin[i]),
toRad(torsoMax[i]) );
1631 motors[i]->enableLimits();
1635 kinRightArm.
getLinkInfo(torsoJointv.size() - i - 1).setiKinLinkLimits(
toRad(torsoMin[i]),
toRad(torsoMax[i]));
1639 if ( enabledServerControlBoards ) {
1642 counter += motors.size();
1646 motors << leftArmJointv[0]->dofs()[0];
1647 motors << leftArmJointv[1]->dofs()[0];
1648 motors << leftArmJointv[2]->dofs()[0];
1649 motors << leftArmJointv[3]->dofs()[0];
1650 motors << leftArmJointv[4]->dofs()[0];
1651 motors << leftArmJointv[5]->dofs()[0];
1652 motors << leftArmJointv[6]->dofs()[0];
1653 motors << leftArmJointv[7]->dofs()[0];
1654 motors << leftArmJointv[23]->dofs()[0];
1655 motors << leftArmJointv[24]->dofs()[0];
1656 motors << leftArmJointv[25]->dofs()[0];
1657 motors << leftArmJointv[11]->dofs()[0];
1658 motors << leftArmJointv[12]->dofs()[0];
1659 motors << leftArmJointv[14]->dofs()[0];
1660 motors << leftArmJointv[15]->dofs()[0];
1661 motors << leftArmJointv[17]->dofs()[0];
1664 for(
unsigned int i=0; i<16; i++ ) {
1667 leftArmCtrl->
setLimitsRaw( i, leftArmMin[i], leftArmMax[i] );
1669 leftArmCtrl->
setLimits( i, leftArmMin[i], leftArmMax[i] );
1672 if ((i + 3) < kinLeftArm.getN()) {
1688 leftArmCtrl->
setOwner(
this,
false);
1689 if ( enabledServerControlBoards ) {
1692 counter += motors.size();
1696 motors << rightArmJointv[0]->dofs()[0];
1697 motors << rightArmJointv[1]->dofs()[0];
1698 motors << rightArmJointv[2]->dofs()[0];
1699 motors << rightArmJointv[3]->dofs()[0];
1700 motors << rightArmJointv[4]->dofs()[0];
1701 motors << rightArmJointv[5]->dofs()[0];
1702 motors << rightArmJointv[6]->dofs()[0];
1703 motors << rightArmJointv[7]->dofs()[0];
1704 motors << rightArmJointv[23]->dofs()[0];
1705 motors << rightArmJointv[24]->dofs()[0];
1706 motors << rightArmJointv[25]->dofs()[0];
1707 motors << rightArmJointv[11]->dofs()[0];
1708 motors << rightArmJointv[12]->dofs()[0];
1709 motors << rightArmJointv[14]->dofs()[0];
1710 motors << rightArmJointv[15]->dofs()[0];
1711 motors << rightArmJointv[17]->dofs()[0];
1714 for(
unsigned int i=0; i<16; i++ ) {
1717 rightArmCtrl->
setLimitsRaw( i, rightArmMin[i], rightArmMax[i] );
1719 rightArmCtrl->
setLimits( i, rightArmMin[i], rightArmMax[i] );
1722 if ((i + 3) < kinRightArm.getN()) {
1738 rightArmCtrl->
setOwner(
this,
false);
1739 if ( enabledServerControlBoards ) {
1742 counter += motors.size();
1746 motors << headNeckJointv[0]->dofs()[0];
1747 motors << headNeckJointv[1]->dofs()[0];
1748 motors << headNeckJointv[2]->dofs()[0];
1749 motors << headNeckJointv[3]->dofs()[0];
1750 motors << versionDOF;
1751 motors << vergenceDOF;
1752 for(
int i=0; i<6; i++ ) {
1754 motors[i]->enableLimits();
1762 const real minEye =
max(headMin[4] + headMin[5], -179.99999);
1763 const real maxEye =
min(headMax[4] + headMax[5], +179.99999);
1764 headNeckJointv[4]->dofs()[0]->setLimits(
toRad(minEye),
toRad(maxEye) );
1765 headNeckJointv[4]->dofs()[0]->enableLimits();
1766 headNeckJointv[5]->dofs()[0]->setLimits(
toRad(minEye),
toRad(maxEye) );
1767 headNeckJointv[5]->dofs()[0]->enableLimits();
1772 headNeckCtrl->
setOwner(
this,
false);
1773 if ( enabledServerControlBoards ) {
1776 counter += motors.size();
1780 for(
int i=0; i<leftLegJointv.size(); i++ ) {
1781 motors << leftLegJointv[i]->dofs()[0];
1782 motors[i]->setLimits(
toRad(leftLegMin[i]),
toRad(leftLegMax[i]) );
1783 motors[i]->enableLimits();
1789 leftLegCtrl->
setOwner(
this,
false);
1790 if ( enabledServerControlBoards ) {
1793 counter += motors.size();
1797 for(
int i=0; i<rightLegJointv.size(); i++ ) {
1798 motors << rightLegJointv[i]->dofs()[0];
1799 motors[i]->setLimits(
toRad(rightLegMin[i]),
toRad(rightLegMax[i]) );
1800 motors[i]->enableLimits();
1806 rightLegCtrl->
setOwner(
this,
false);
1807 if ( enabledServerControlBoards ) {
1810 counter += motors.size();
1816 WMesh* mesh =
new WMesh( world, name+
":faceCover", matrix );
1825 foreach(
PhyJoint* joint, leftLegJointv ) {
1829 foreach(
PhyJoint* joint, rightLegJointv ) {
1833 foreach(
PhyJoint* joint, torsoJointv ) {
1837 foreach(
PhyJoint* joint, leftArmJointv ) {
1841 foreach(
PhyJoint* joint, rightArmJointv ) {
1845 foreach(
PhyJoint* joint, headNeckJointv ) {
1856 leftLegMasses.resize(0);
1858 mass += obj->
mass();
1859 leftLegMasses << obj->
mass();
1863 rightLegMasses.resize(0);
1865 mass += obj->
mass();
1866 rightLegMasses << obj->
mass();
1870 torsoMasses.resize(0);
1872 mass += obj->
mass();
1873 torsoMasses << obj->
mass();
1877 leftArmMasses.resize(0);
1879 mass += obj->
mass();
1880 leftArmMasses << obj->
mass();
1884 rightArmMasses.resize(0);
1886 mass += obj->
mass();
1887 rightArmMasses << obj->
mass();
1891 headNeckMasses.resize(0);
1893 mass += obj->
mass();
1894 headNeckMasses << obj->
mass();
1898 headNeckv[4]->setTexture(
"blueye" );
1899 headNeckv[5]->setTexture(
"blueye" );
1903 world->pushObject(
this );
1907 if ( cartCtrlLeftArm ) {
1909 delete cartServLeftArm;
1910 delete cartSolvLeftArm;
1912 if ( cartCtrlRightArm ) {
1914 delete cartServRightArm;
1915 delete cartSolvRightArm;
1917 if ( enabledServerControlBoards ) {
1919 QStringList servers;
1920 servers <<
"torso" <<
"left_arm" <<
"right_arm" <<
"head" <<
"left_leg" <<
"right_leg";
1921 foreach( QString srv, servers ) {
1929 delete rightArmCtrl;
1930 delete headNeckCtrl;
1932 delete rightLegCtrl;
1938 for(
int i=0; i<coversv.size(); i++ ) {
1939 delete (coversv[i]);
1941 foreach(
PhyJoint* joint, leftLegJointv ) {
1944 foreach(
PhyJoint* joint, rightLegJointv ) {
1947 foreach(
PhyJoint* joint, torsoJointv ) {
1950 foreach(
PhyJoint* joint, leftArmJointv ) {
1953 foreach(
PhyJoint* joint, rightArmJointv ) {
1956 foreach(
PhyJoint* joint, headNeckJointv ) {
1977 delete leftHandGroup;
1978 delete rightHandGroup;
1985 kinematicSimulation = k;
1986 collidingLeftHand = clh;
1987 collidingRightHand = crh;
1989 if (kinematicSimulation) {
1991 for (
int i = 0; i < leftLegJointv.size(); i++) {
1992 leftLegJointv[i]->enable(
false);
1994 for (
int i = 0; i < rightLegJointv.size(); i++) {
1995 rightLegJointv[i]->enable(
false);
1997 for (
int i = 0; i < torsoJointv.size(); i++) {
1998 torsoJointv[i]->enable(
false);
2000 for (
int i = 0; i < leftArmJointv.size(); i++) {
2001 if (collidingLeftHand && (i >= 6)) {
2002 leftArmJointv[i]->enable(
true);
2004 leftArmJointv[i]->enable(
false);
2007 for (
int i = 0; i < rightArmJointv.size(); i++) {
2008 if (collidingRightHand && (i >= 6)) {
2009 rightArmJointv[i]->enable(
true);
2011 rightArmJointv[i]->enable(
false);
2014 for (
int i = 0; i < headNeckJointv.size(); i++) {
2015 headNeckJointv[i]->enable(
false);
2019 for (
int i = 0; i < leftLegv.size(); i++) {
2020 leftLegv[i]->setKinematic(
true);
2022 for (
int i = 0; i < rightLegv.size(); i++) {
2023 rightLegv[i]->setKinematic(
true);
2025 for (
int i = 0; i < torsov.size(); i++) {
2026 torsov[i]->setKinematic(
true);
2028 for (
int i = 0; i < leftArmv.size(); i++) {
2029 if (collidingLeftHand) {
2031 leftArmv[i]->setKinematic(
true,
false);
2032 }
else if (i == 5) {
2033 leftArmv[i]->setKinematic(
true,
true);
2035 leftArmv[i]->setKinematic(
false);
2038 leftArmv[i]->setKinematic(
true,
false);
2041 for (
int i = 0; i < rightArmv.size(); i++) {
2042 if (collidingRightHand) {
2044 rightArmv[i]->setKinematic(
true,
false);
2045 }
else if (i == 5) {
2046 rightArmv[i]->setKinematic(
true,
true);
2048 rightArmv[i]->setKinematic(
false);
2051 rightArmv[i]->setKinematic(
true,
false);
2054 for (
int i = 0; i < headNeckv.size(); i++) {
2055 headNeckv[i]->setKinematic(
true);
2059 for (
int i = 0; i < leftLegv.size(); i++) {
2060 leftLegv[i]->setKinematic( !enabledLeftLeg );
2062 for (
int i = 0; i < rightLegv.size(); i++) {
2063 rightLegv[i]->setKinematic( !enabledRightLeg );
2065 for (
int i = 0; i < torsov.size(); i++) {
2066 torsov[i]->setKinematic( !enabledTorso );
2068 for (
int i = 0; i < leftArmv.size(); i++) {
2069 leftArmv[i]->setKinematic( !enabledLeftArm );
2071 for (
int i = 0; i < rightArmv.size(); i++) {
2072 rightArmv[i]->setKinematic( !enabledRightArm );
2074 for (
int i = 0; i < headNeckv.size(); i++) {
2075 headNeckv[i]->setKinematic( !enabledHead );
2079 for (
int i = 0; i < leftLegJointv.size(); i++) {
2080 leftLegJointv[i]->enable(enabledLeftLeg);
2081 if (enabledLeftLeg) {
2082 leftLegJointv[i]->updateJointInfo();
2085 for (
int i = 0; i < rightLegJointv.size(); i++) {
2086 rightLegJointv[i]->enable(enabledRightLeg);
2087 if (enabledRightLeg) {
2088 rightLegJointv[i]->updateJointInfo();
2091 for (
int i = 0; i < torsoJointv.size(); i++) {
2092 torsoJointv[i]->enable(enabledTorso);
2094 torsoJointv[i]->updateJointInfo();
2097 for (
int i = 0; i < leftArmJointv.size(); i++) {
2098 leftArmJointv[i]->enable(enabledLeftArm);
2099 if (enabledLeftArm) {
2100 leftArmJointv[i]->updateJointInfo();
2103 for (
int i = 0; i < rightArmJointv.size(); i++) {
2104 rightArmJointv[i]->enable(enabledRightArm);
2105 if (enabledRightArm) {
2106 rightArmJointv[i]->updateJointInfo();
2109 for (
int i = 0; i < headNeckJointv.size(); i++) {
2110 headNeckJointv[i]->enable(enabledHead);
2112 headNeckJointv[i]->updateJointInfo();
2121 #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)
2124 #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?
2131 for (QMap<int, real>::const_iterator it = jointSetup.begin(); it != jointSetup.end(); it++) {
2144 case left_shoulder_pitch:
2147 case left_shoulder_roll:
2150 case left_shoulder_yaw:
2156 case left_wrist_prosup:
2159 case left_wrist_pitch:
2162 case left_wrist_yaw:
2165 case right_shoulder_pitch:
2168 case right_shoulder_roll:
2171 case right_shoulder_yaw:
2177 case right_wrist_prosup:
2180 case right_wrist_pitch:
2183 case right_wrist_yaw:
2198 case eyes_version:
case eyes_vergence:
2203 if (jointSetup. contains(eyes_version)) {
2204 versionAngle =
toRad(jointSetup[eyes_version]);
2206 versionAngle = versionDOF->
position();
2209 if (jointSetup. contains(eyes_vergence)) {
2210 vergenceAngle =
toRad(jointSetup[eyes_vergence]);
2212 vergenceAngle = vergenceDOF->
position();
2224 case left_hip_pitch:
2236 case left_ankle_pitch:
2239 case left_ankle_roll:
2242 case right_hip_pitch:
2245 case right_hip_roll:
2254 case right_ankle_pitch:
2257 case right_ankle_roll:
2278 foreach(
PhyJoint* joint, leftLegJointv ) {
2281 foreach(
PhyJoint* joint, rightLegJointv ) {
2284 foreach(
PhyJoint* joint, torsoJointv ) {
2287 foreach(
PhyJoint* joint, leftArmJointv ) {
2290 foreach(
PhyJoint* joint, rightArmJointv ) {
2293 foreach(
PhyJoint* joint, headNeckJointv ) {
2299 for (QMap<int, real>::const_iterator it = jointSetup.begin(); it != jointSetup.end(); it++) {
2301 case left_hand_finger:
2306 case left_thumb_oppose:
2309 case left_thumb_proximal:
2312 case left_thumb_distal:
2316 case left_index_proximal:
2319 case left_index_distal:
2323 case left_middle_proximal:
2326 case left_middle_distal:
2338 case right_hand_finger:
2343 case right_thumb_oppose:
2346 case right_thumb_proximal:
2349 case right_thumb_distal:
2353 case right_index_proximal:
2356 case right_index_distal:
2360 case right_middle_proximal:
2363 case right_middle_distal:
2382 leftArmCtrl->
stop();
2383 rightArmCtrl->
stop();
2384 headNeckCtrl->
stop();
2385 leftLegCtrl->
stop();
2386 rightLegCtrl->
stop();
2428 if (kinematicSimulation) {
2429 bool torsoUpdated =
false;
2430 int lastLinkRight = -1;
2431 int lastLinkLeft = -1;
2432 if (enabledRightArm || alwaysUpdateKinematicChains) {
2433 if (enabledRightArm && collidingRightHand) {
2437 torsoUpdated =
true;
2439 if (enabledLeftArm || alwaysUpdateKinematicChains) {
2440 if (enabledLeftArm && collidingLeftHand) {
2444 torsoUpdated =
true;
2446 if (enabledRightLeg || alwaysUpdateKinematicChains) {
2449 if (enabledLeftLeg || alwaysUpdateKinematicChains) {
2452 if (enabledHead || alwaysUpdateKinematicChains) {
2455 torsoUpdated =
true;
2459 if (!torsoUpdated && enabledTorso) {
2464 if (!collidingRightHand && (enabledRightArm || alwaysUpdateKinematicChains)) {
2466 if (enabledRightKinematicHand) {
2470 if (!collidingLeftHand && (enabledLeftArm || alwaysUpdateKinematicChains)) {
2472 if (enabledLeftKinematicHand) {
2483 if (alwaysUpdateKinematicChains && !kinematicSimulation) {
2484 int upperBodyUpdateStartingChainLink = 3;
2485 if (!enabledTorso) {
2488 upperBodyUpdateStartingChainLink = 0;
2490 if (!enabledRightArm) {
2493 if (!enabledLeftArm) {
2496 if (!enabledRightLeg) {
2499 if (!enabledLeftLeg) {
2510 if ( enabledLeftLeg == b )
return;
2522 if ( enabledRightLeg == b )
return;
2523 enabledRightLeg = b;
2538 if ( enabledTorso == b )
return;
2541 for (
int i = 0; i < torsov.size(); i++) {
2542 torsov[i]->setStatic(
false);
2544 if (!kinematicSimulation) {
2545 for (
int i = 0; i < torsoJointv.size(); i++) {
2546 torsoJointv[i]->enable(
true);
2547 torsoJointv[i]->updateJointInfo();
2553 if (!kinematicSimulation) {
2554 for (
int i = 0; i < torsoJointv.size(); i++) {
2555 torsoJointv[i]->enable(
false);
2558 for (
int i = 0; i < torsov.size(); i++) {
2559 torsov[i]->setStatic(
true);
2565 if ( enabledHead == b )
return;
2577 if ( enabledCameras == b )
return;
2579 if ( b && !leftcam ) {
2580 leftcam =
new WCamera(
world(),
name()+
"/cam/left", headNeckv[5], 640, 480 );
2581 rightcam =
new WCamera(
world(),
name()+
"/cam/right", headNeckv[4], 640, 480 );
2583 if ( !b && leftcam ) {
2592 if ( enabledLeftArm == b )
return;
2604 if ( enabledRightArm == b )
return;
2605 enabledRightArm = b;
2616 if ( blockedTorso0 == b )
return;
2619 torsov[0]->setMass( 0 );
2621 torsov[0]->setMass( torsoMasses[0] );
2627 enabledLeftKinematicHand = b;
2632 enabledRightKinematicHand = b;
2635 YARP_DECLARE_PLUGINS( icubmod )
2636 void
PhyiCub::enableLeftArmCartesianController() {
2637 YARP_REGISTER_PLUGINS( icubmod );
2640 cartSolvLeftArm =
new iCubArmCartesianSolver(
2641 QString(
"%1/%2/cartesianSolver/left_arm" )
2642 .arg( world()->name() )
2646 Property options( QString(
"\
2650 (dof (1 1 1 1 1 1 1 1 1 1) ) \
2652 .arg( world()->name() )
2654 .toAscii().data() );
2655 cartSolvLeftArm->open( options );
2661 Property optServerLeftArm( QString(
"\
2662 (device cartesiancontrollerserver) \
2663 (GENERAL (ControllerName %1/%2/cartesianController/left_arm) \
2664 (ControllerPeriod 10) \
2665 (SolverNameToConnect %1/%2/cartesianSolver/left_arm) \
2666 (KinematicPart arm) \
2667 (KinematicType left) \
2668 (NumberOfDrivers 2)) \
2669 (DRIVER_0 (Key torso) (JointsOrder reversed)) \
2670 (DRIVER_1 (Key left_arm) (JointsOrder direct))" )
2671 .arg( world()->name() )
2673 .toAscii().data() );
2674 cartServLeftArm =
new PolyDriver();
2675 if ( !cartServLeftArm->open( optServerLeftArm ) ) {
2679 PolyDriverList listL;
2680 listL.push( polydriver(
"torso"),
"torso" );
2681 listL.push( polydriver(
"left_arm"),
"left_arm" );
2682 IMultipleWrapper *wrapperL;
2683 cartServLeftArm->view( wrapperL );
2684 if ( !wrapperL->attachAll(listL) ) {
2686 qDebug() <<
"Errore nell'attaccare i PolyDriver al Server Cartesiano";
2689 cartServLeftArm->view( cartCtrlLeftArm );
2697 YARP_REGISTER_PLUGINS( icubmod );
2700 cartSolvRightArm =
new iCubArmCartesianSolver(
2701 QString(
"%1/%2/cartesianSolver/right_arm" )
2706 Property options( QString(
"\
2713 .toAscii().data() );
2714 cartSolvRightArm->open( options );
2720 Property optServerRightArm( QString(
"\
2721 (device cartesiancontrollerserver) \
2722 (GENERAL (ControllerName %1/%2/cartesianController/right_arm) \
2723 (ControllerPeriod 10) \
2724 (SolverNameToConnect %1/%2/cartesianSolver/right_arm) \
2725 (KinematicPart arm) \
2726 (KinematicType right) \
2727 (NumberOfDrivers 2)) \
2728 (DRIVER_0 (Key torso) (JointsOrder reversed)) \
2729 (DRIVER_1 (Key right_arm) (JointsOrder direct))" )
2732 .toAscii().data() );
2733 cartServRightArm =
new PolyDriver();
2734 if ( !cartServRightArm->open( optServerRightArm ) ) {
2738 PolyDriverList listL;
2740 listL.push(
polydriver(
"right_arm"),
"right_arm" );
2741 IMultipleWrapper *wrapperL;
2742 cartServRightArm->view( wrapperL );
2743 if ( !wrapperL->attachAll(listL) ) {
2745 qDebug() <<
"Errore nell'attaccare i PolyDriver al Server Cartesiano";
2748 cartServRightArm->view( cartCtrlRightArm );
2769 foreach(
PhyJoint* joint, leftLegJointv ) {
2772 foreach(
PhyJoint* joint, rightLegJointv ) {
2775 foreach(
PhyJoint* joint, torsoJointv ) {
2778 foreach(
PhyJoint* joint, leftArmJointv ) {
2781 foreach(
PhyJoint* joint, rightArmJointv ) {
2784 foreach(
PhyJoint* joint, headNeckJointv ) {
2795 convertYarpMatrixToWorldMatrix(kinRightArm.getH0(), torso0Matrix);
2796 torso0Matrix = torso0Matrix *
tm;
2797 const real torso0Height = (
dynamic_cast<PhyBox*
>(torsov[0]))->sideX();
2801 torso0Matrix.w_pos +=
wVector(0.0, 0.0, kinRightLeg.getH0()(2, 3) + torso0Height / 4.0);
2802 torsov[0]->setMatrix(torso0Matrix);
2810 for (
int i = 0; i < objects.size(); i++) {
2811 objects[i]->setKinematic(
false);
2813 if (!kinematicSimulation) {
2814 for (
int i = 0; i < joints.size(); i++) {
2815 joints[i]->enable(
true);
2816 joints[i]->updateJointInfo();
2820 if (!kinematicSimulation) {
2821 for (
int i = 0; i < joints.size(); i++) {
2822 joints[i]->enable(
false);
2825 for (
int i = 0; i < objects.size(); i++) {
2826 objects[i]->setKinematic(
true);
2833 return -version - vergence;
2838 return -version + vergence;
2843 return (-left - right) / 2.0;
2848 return (left - right) / 2.0;
2853 const real lowEyeLimit = versionLow + vergenceLow;
2855 return (lowEyeLimit < -PI_GRECO) ? -(PI_GRECO - 0.000001) : lowEyeLimit;
2860 const real highEyeLimit = versionHigh + vergenceHigh;
2862 return (highEyeLimit > PI_GRECO) ? (PI_GRECO - 0.000001) : highEyeLimit;
2866 #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
2871 if (ignoreEyeSignals) {
2879 ignoreEyeSignals =
true;
2882 ignoreEyeSignals =
false;
2887 if (ignoreEyeSignals) {
2895 ignoreEyeSignals =
true;
2898 ignoreEyeSignals =
false;
2903 if (ignoreEyeSignals) {
2907 const real curVergence = vergenceDOF->
position();
2911 ignoreEyeSignals =
true;
2912 rightEyeDOF->setPosition(rightEyeAngle);
2913 leftEyeDOF->setPosition(leftEyeAngle);
2914 ignoreEyeSignals =
false;
2919 if (ignoreEyeSignals) {
2923 const real curVergenceVelocity = vergenceDOF->
velocity();
2927 ignoreEyeSignals =
true;
2928 rightEyeDOF->setVelocity(rightEyeVelocity);
2929 leftEyeDOF->setVelocity(leftEyeVelocity);
2930 ignoreEyeSignals =
false;
2935 if (ignoreEyeSignals) {
2939 real curVergenceLow, curVergenceHigh;
2940 vergenceDOF->
limits(curVergenceLow, curVergenceHigh);
2944 ignoreEyeSignals =
true;
2945 rightEyeDOF->
setLimits(eyeLow, eyeHigh);
2947 ignoreEyeSignals =
false;
2952 if (ignoreEyeSignals) {
2960 ignoreEyeSignals =
true;
2963 ignoreEyeSignals =
false;
2968 if (ignoreEyeSignals) {
2976 ignoreEyeSignals =
true;
2979 ignoreEyeSignals =
false;
2984 if (ignoreEyeSignals) {
2988 const real curVersion = versionDOF->
position();
2992 ignoreEyeSignals =
true;
2993 rightEyeDOF->setPosition(rightEyeAngle);
2994 leftEyeDOF->setPosition(leftEyeAngle);
2995 ignoreEyeSignals =
false;
3000 if (ignoreEyeSignals) {
3004 const real curVersionVelocity = versionDOF->
velocity();
3008 ignoreEyeSignals =
true;
3009 rightEyeDOF->setVelocity(rightEyeVelocity);
3010 leftEyeDOF->setVelocity(leftEyeVelocity);
3011 ignoreEyeSignals =
false;
3016 if (ignoreEyeSignals) {
3020 real curVersionLow, curVersionHigh;
3021 vergenceDOF->
limits(curVersionLow, curVersionHigh);
3025 ignoreEyeSignals =
true;
3026 rightEyeDOF->
setLimits(eyeLow, eyeHigh);
3028 ignoreEyeSignals =
false;
3033 if (ignoreEyeSignals) {
3037 const real curLeftEyeAngle = leftEyeDOF->
position();
3041 ignoreEyeSignals =
true;
3044 ignoreEyeSignals =
false;
3049 if (ignoreEyeSignals) {
3053 const real curLeftEyeVelocity = leftEyeDOF->
position();
3057 ignoreEyeSignals =
true;
3060 ignoreEyeSignals =
false;
3065 if (ignoreEyeSignals) {
3069 const real curLeftEyeAngle = leftEyeDOF->
position();
3073 ignoreEyeSignals =
true;
3074 versionDOF->setPosition(versionAngle);
3075 vergenceDOF->setPosition(vergenceAngle);
3076 ignoreEyeSignals =
false;
3081 if (ignoreEyeSignals) {
3085 const real curLeftEyeVelocity = leftEyeDOF->
position();
3089 ignoreEyeSignals =
true;
3090 versionDOF->setVelocity(versionVelocity);
3091 vergenceDOF->setVelocity(vergenceVelocity);
3092 ignoreEyeSignals =
false;
3104 if (ignoreEyeSignals) {
3108 const real curRightEyeAngle = rightEyeDOF->
position();
3112 ignoreEyeSignals =
true;
3115 ignoreEyeSignals =
false;
3120 if (ignoreEyeSignals) {
3124 const real curRightEyeVelocity = rightEyeDOF->
position();
3128 ignoreEyeSignals =
true;
3131 ignoreEyeSignals =
false;
3136 if (ignoreEyeSignals) {
3140 const real curRightEyeAngle = rightEyeDOF->
position();
3144 ignoreEyeSignals =
true;
3145 versionDOF->setPosition(versionAngle);
3146 vergenceDOF->setPosition(vergenceAngle);
3147 ignoreEyeSignals =
false;
3152 if (ignoreEyeSignals) {
3156 const real curRightEyeVelocity = rightEyeDOF->
position();
3160 ignoreEyeSignals =
true;
3161 versionDOF->setVelocity(versionVelocity);
3162 vergenceDOF->setVelocity(vergenceVelocity);
3163 ignoreEyeSignals =
false;
3174 #endif // FARSA_USE_YARP_AND_ICUB