20 #ifdef FARSA_USE_YARP_AND_ICUB
25 #include "worldsimconfig.h"
28 #include "wquaternion.h"
30 #include "yarpobject.h"
33 #include "phyicubhelpers.h"
43 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
44 #pragma GCC diagnostic push
45 #pragma GCC diagnostic ignored "-Wunused-parameter"
47 #pragma GCC diagnostic ignored "-Wunused-parameter"
50 #include "yarp/dev/CartesianControl.h"
51 #include "iCub/iKin/iKinHlp.h"
52 #include "iCub/iKin/iKinSlv.h"
54 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
55 #pragma GCC diagnostic pop
57 #pragma GCC diagnostic warning "-Wunused-parameter"
75 class MultiMotorController;
96 torso_yaw=0, torso_roll, torso_pitch,
97 left_shoulder_pitch, left_shoulder_roll, left_shoulder_yaw,
98 left_elbow, left_wrist_prosup, left_wrist_pitch,
99 left_wrist_yaw, left_hand_finger, left_thumb_oppose,
100 left_thumb_proximal, left_thumb_distal, left_index_proximal,
101 left_index_distal, left_middle_proximal, left_middle_distal, left_pinky,
102 right_shoulder_pitch, right_shoulder_roll, right_shoulder_yaw,
103 right_elbow, right_wrist_prosup, right_wrist_pitch,
104 right_wrist_yaw, right_hand_finger, right_thumb_oppose,
105 right_thumb_proximal, right_thumb_distal, right_index_proximal,
106 right_index_distal, right_middle_proximal, right_middle_distal, right_pinky,
107 neck_pitch, neck_roll, neck_yaw,
108 eyes_tilt, eyes_version, eyes_vergence,
109 left_hip_pitch, left_hip_roll, left_hip_yaw,
110 left_knee, left_ankle_pitch, left_ankle_roll,
111 right_hip_pitch, right_hip_roll, right_hip_yaw,
112 right_knee, right_ankle_pitch, right_ankle_roll,
142 void doKinematicSimulation(
bool k,
bool clh =
false,
bool crh =
false);
148 return kinematicSimulation;
160 void configurePosture( QMap<int, real> jointSetup );
173 const QVector<PhyObject*>&
torso() {
199 return leftLegJointv;
204 return rightLegJointv;
225 return leftArmJointv;
241 return rightArmJointv;
246 return headNeckJointv;
274 return cartCtrlLeftArm;
278 return cartCtrlRightArm;
281 yarp::dev::IFrameGrabberImage* leftEyeFrameGrabber();
283 yarp::dev::IFrameGrabberImage* rightEyeFrameGrabber();
290 virtual void preUpdate();
295 virtual void postUpdate();
300 alwaysUpdateKinematicChains = enable;
305 void enableLeftLeg(
bool );
307 void enableRightLeg(
bool );
309 void enableTorso(
bool );
311 void enableHead(
bool );
313 void enableCameras(
bool );
315 void enableLeftArm(
bool );
317 void enableRightArm(
bool );
319 void blockTorso0(
bool );
321 void enableLeftKinematicHand(
bool );
323 void enableRightKinematicHand(
bool );
325 bool isEnabledLeftLeg() {
326 return enabledLeftLeg;
328 bool isEnabledRightLeg() {
329 return enabledRightLeg;
331 bool isEnabledTorso() {
334 bool isEnabledHead() {
337 bool isEnabledCameras() {
338 return enabledCameras;
340 bool isEnabledLeftArm() {
341 return enabledLeftArm;
343 bool isEnabledRightArm() {
344 return enabledRightArm;
346 bool isBlockedTorso0() {
347 return blockedTorso0;
349 bool isEnabledLeftKinematicHand() {
350 return enabledLeftKinematicHand;
352 bool isEnabledRightKinematicHand() {
353 return enabledRightKinematicHand;
357 void enableLeftArmCartesianController();
359 void enableRightArmCartesianController();
363 virtual void changedMatrix();
365 void setTorso0Matrix();
367 void enableObjectsAndLinks(
bool enable, QVector<PhyObject*>& objects, QVector<PhyJoint*>& joints);
369 static real rightEyeFromVersionAndVergence(real version, real vergence);
371 static real leftEyeFromVersionAndVergence(real version, real vergence);
373 static real versionFromRightAndLeftEye(real left, real right);
375 static real vergenceFromRightAndLeftEye(real left, real right);
377 static real lowEyeLimitFromVersionAndVergenceLimits(real versionLow, real vergenceLow);
379 static real highEyeLimitFromVersionAndVergenceLimits(real versionHigh, real vergenceHigh);
383 void versionChangedDesiredPosition( real wishpos );
385 void versionChangedDesiredVelocity( real wishvel );
387 void versionChangedPosition( real newpos );
389 void versionChangedVelocity( real newvel );
391 void versionChangedLimits( real lowlimit, real highlimit );
394 void vergenceChangedDesiredPosition( real wishpos );
396 void vergenceChangedDesiredVelocity( real wishvel );
398 void vergenceChangedPosition( real newpos );
400 void vergenceChangedVelocity( real newvel );
402 void vergenceChangedLimits( real lowlimit, real highlimit );
405 void rightEyeChangedDesiredPosition( real wishpos );
407 void rightEyeChangedDesiredVelocity( real wishvel );
409 void rightEyeChangedPosition( real newpos );
411 void rightEyeChangedVelocity( real newvel );
413 void rightEyeChangedLimits( real lowlimit, real highlimit );
416 void leftEyeChangedDesiredPosition( real wishpos );
418 void leftEyeChangedDesiredVelocity( real wishvel );
420 void leftEyeChangedPosition( real newpos );
422 void leftEyeChangedVelocity( real newvel );
424 void leftEyeChangedLimits( real lowlimit, real highlimit );
429 QVector<PhyObject*> leftLegv;
431 QVector<PhyObject*> rightLegv;
433 QVector<PhyObject*> torsov;
435 QVector<PhyObject*> leftArmv;
437 QVector<PhyObject*> rightArmv;
439 QVector<PhyObject*> headNeckv;
442 QVector<WMesh*> coversv;
445 QVector<PhyJoint*> leftLegJointv;
447 QVector<PhyJoint*> rightLegJointv;
449 QVector<PhyJoint*> torsoJointv;
451 QVector<PhyJoint*> leftArmJointv;
453 QVector<PhyJoint*> rightArmJointv;
455 QVector<PhyJoint*> headNeckJointv;
468 bool ignoreEyeSignals;
471 enum PhyObjectsGroupChains {
472 IndexChain, MiddleChain, RingChain, PinkyChain,
477 PhyObjectsGroup* leftHandGroup;
479 PhyObjectsGroup* rightHandGroup;
482 QVector<real> leftLegMasses;
484 QVector<real> rightLegMasses;
486 QVector<real> torsoMasses;
488 QVector<real> leftArmMasses;
490 QVector<real> rightArmMasses;
492 QVector<real> headNeckMasses;
495 MultiMotorController* torsoCtrl;
497 MultiMotorController* leftArmCtrl;
499 MultiMotorController* rightArmCtrl;
501 MultiMotorController* headNeckCtrl;
503 MultiMotorController* leftLegCtrl;
505 MultiMotorController* rightLegCtrl;
513 yarp::dev::PolyDriver* cartServLeftArm;
514 yarp::dev::ICartesianControl* cartCtrlLeftArm;
515 ::iCub::iKin::iCubArmCartesianSolver* cartSolvLeftArm;
516 yarp::os::RateThread* cartThreadLeftArm;
518 yarp::dev::PolyDriver* cartServRightArm;
519 yarp::dev::ICartesianControl* cartCtrlRightArm;
520 ::iCub::iKin::iCubArmCartesianSolver* cartSolvRightArm;
528 bool enabledRightLeg;
531 bool enabledRightArm;
535 bool enabledRightKinematicHand;
536 bool enabledLeftKinematicHand;
538 const bool enabledServerControlBoards;
540 bool alwaysUpdateKinematicChains;
543 KinematicLimb<iCub::iKin::iCubArm> kinRightArm;
544 KinematicLimb<iCub::iKin::iCubArm> kinLeftArm;
545 KinematicLimb<iCub::iKin::iCubLeg> kinRightLeg;
546 KinematicLimb<iCub::iKin::iCubLeg> kinLeftLeg;
547 KinematicLimb<iCub::iKin::iCubEye> kinRightEye;
548 KinematicLimb<iCub::iKin::iCubEye> kinLeftEye;
553 bool kinematicSimulation;
557 bool collidingLeftHand;
561 bool collidingRightHand;
567 #endif // FARSA_USE_YARP_AND_ICUB