00001
00002
00003
00004
00005
00006
00007 #ifndef AIBOLEG_H
00008 #define AIBOLEG_H
00009
00010 #include "aibojoint.h"
00011 #include "aibolegpositions.h"
00012
00014 static const int NUM_LEG_JOINTS = 12;
00015
00017 enum LEG_JOINT{
00018
00019 RF1,
00020 RF2,
00021 RF3,
00023 LF1,
00024 LF2,
00025 LF3,
00027 RR1,
00028 RR2,
00029 RR3,
00031 LR1,
00032 LR2,
00033 LR3
00034 };
00035
00037 static const char* const LEG_JOINT_ARRAY[] = {
00038 "PRM:/r4/c1-Joint2:j1",
00039 "PRM:/r4/c1/c2-Joint2:j2",
00040 "PRM:/r4/c1/c2/c3-Joint2:j3",
00041
00042 "PRM:/r2/c1-Joint2:j1",
00043 "PRM:/r2/c1/c2-Joint2:j2",
00044 "PRM:/r2/c1/c2/c3-Joint2:j3",
00045
00046 "PRM:/r5/c1-Joint2:j1",
00047 "PRM:/r5/c1/c2-Joint2:j2",
00048 "PRM:/r5/c1/c2/c3-Joint2:j3",
00049
00050 "PRM:/r3/c1-Joint2:j1",
00051 "PRM:/r3/c1/c2-Joint2:j2",
00052 "PRM:/r3/c1/c2/c3-Joint2:j3"
00053 };
00054
00055
00075 class AiboLeg : public AiboJoint {
00076
00077
00078 public:
00080 AiboLeg();
00081
00083 virtual ~AiboLeg(){};
00084
00085
00089
00091 void OpenPrimitives();
00096 OPrimitiveID GetJointID(LEG_JOINT j) const;
00098
00099
00103
00106 void NewCommandVectorData();
00108
00112
00113
00114
00120 void SetJoint(slongword angle,
00121 LEG_JOINT joint,
00122 int cmdVecIndex);
00123
00129 void SetJoint(double angle,
00130 LEG_JOINT joint,
00131 int cmdVecIndex);
00132
00139 void SetJoint(double start, double angle,
00140 LEG_JOINT joint,
00141 int cmdVecIndex);
00142
00143
00151 void SetJoint(slongword angle,
00152 LEG_JOINT joint,
00153 int numFrames,
00154 int cmdVecIndex);
00155
00163 void SetJoint(double angle,
00164 LEG_JOINT joint,
00165 int numFrames,
00166 int cmdVecIndex);
00167
00176 void SetJoint(double start, double angle,
00177 LEG_JOINT joint,
00178 int numFrames,
00179 int cmdVecIndex);
00180
00181
00182
00183
00189 void SetJointRel(slongword angle,
00190 LEG_JOINT joint,
00191 int cmdVecIndex);
00192
00198 void SetJointRel(double angle, LEG_JOINT joint,
00199 int cmdVecIndex);
00200
00201
00208 void SetJointRel(double start,double angle,
00209 LEG_JOINT joint,
00210 int cmdVecIndex);
00211
00219 void SetJointRel(slongword angle,
00220 LEG_JOINT joint,
00221 int numFrames,
00222 int cmdVecIndex);
00223
00231 void SetJointRel(double angle,
00232 LEG_JOINT joint,
00233 int numFrames,
00234 int cmdVecIndex);
00235
00236
00245 void SetJointRel(double start,double angle,
00246 LEG_JOINT joint,
00247 int numFrames,
00248 int cmdVecIndex);
00249
00250
00251
00252
00254
00258 double GetJointValue(LEG_JOINT joint) const;
00259
00260 double GetOPENRJointValue(LEG_JOINT joint) const;
00261
00262
00263 double GetMaxJointValue(int index, JOINT_UNIT unit = ANGLE_RAD) const;
00267 double GetMaxJointValue(LEG_JOINT joint, JOINT_UNIT unit = ANGLE_RAD) const;
00268
00269
00270 double GetMinJointValue(int index, JOINT_UNIT unit = ANGLE_RAD) const;
00274 double GetMinJointValue(LEG_JOINT joint, JOINT_UNIT unit = ANGLE_RAD) const;
00275
00276
00277 double GetMaxJointVelocity(int index, JOINT_UNIT unit = ANGLE_RAD) const;
00281 double GetMaxJointVelocity(LEG_JOINT joint, JOINT_UNIT unit = ANGLE_RAD) const;
00282
00284
00288 void SetJointGain();
00289
00293 void EnableJointGain(LEG_JOINT joint);
00294
00298 void DisableJointGain(LEG_JOINT joint);
00299
00301
00302
00303
00304 protected:
00305
00308 static const word J1_PGAIN = 0x0016;
00310 static const word J1_IGAIN = 0x0004;
00312 static const word J1_DGAIN = 0x0008;
00313
00315 static const word J2_PGAIN = 0x0014;
00317 static const word J2_IGAIN = 0x0004;
00319 static const word J2_DGAIN = 0x0006;
00320
00322 static const word J3_PGAIN = 0x0023;
00324 static const word J3_IGAIN = 0x0004;
00326 static const word J3_DGAIN = 0x0005;
00327
00331 static const double MAX_J1_DEG = 117.0;
00335 static const double MAX_J2_DEG = 89.0;
00339 static const double MAX_J3_DEG = 147.0;
00340
00344 static const double MIN_J1_DEG = -117.0;
00348 static const double MIN_J2_DEG = -11.0;
00352 static const double MIN_J3_DEG = -27.0;
00353
00357 static const double MAX_J1 = MAX_J1_DEG * DEGTORAD;
00361 static const double MAX_J2 = MAX_J2_DEG * DEGTORAD;
00365 static const double MAX_J3 = MAX_J3_DEG * DEGTORAD;
00366
00367
00371 static const double MIN_J1 = MIN_J1_DEG * DEGTORAD;
00375 static const double MIN_J2 = MIN_J2_DEG * DEGTORAD;
00379 static const double MIN_J3 = MIN_J3_DEG * DEGTORAD;
00380
00381
00382
00383
00384
00388 static const double MAX_J1_VELO_DEG = 2.58/2.0;
00392 static const double MAX_J2_VELO_DEG = 2.29/2.0;
00396 static const double MAX_J3_VELO_DEG = 2.60/2.0;
00397
00398
00402 static const double MAX_J1_VELO = MAX_J1_VELO_DEG * DEGTORAD;
00406 static const double MAX_J2_VELO = MAX_J2_VELO_DEG * DEGTORAD;
00410 static const double MAX_J3_VELO = MAX_J3_VELO_DEG * DEGTORAD;
00411
00412 };
00413
00414
00415
00416
00417
00418 inline OPrimitiveID AiboLeg::GetJointID(LEG_JOINT j) const
00419 {
00420 return JointID[j];
00421 };
00422
00423
00424
00425
00426
00427 inline void AiboLeg::EnableJointGain(LEG_JOINT joint)
00428 {
00429 AiboJoint::EnableJointGain(JointID[joint]);
00430 };
00431
00432
00433
00434
00435
00436
00437 inline void AiboLeg::DisableJointGain(LEG_JOINT joint)
00438 {
00439 AiboJoint::DisableJointGain(JointID[joint]);
00440 };
00441
00442
00443
00444
00445
00446 inline void AiboLeg::SetJoint(slongword angle,
00447 LEG_JOINT joint,
00448 int cmdVecIndex)
00449 {
00450 AiboJoint::SetJoint(JointValues[joint], ((double)angle)/MICRO,
00451 JointID[joint], joint,
00452 cmdVecIndex);
00453 };
00454
00455
00456
00457
00458
00459 inline void AiboLeg::SetJoint(double angle,
00460 LEG_JOINT joint,
00461 int cmdVecIndex)
00462 {
00463 AiboJoint::SetJoint(JointValues[joint], angle,
00464 JointID[joint], joint,
00465 cmdVecIndex);
00466 };
00467
00468
00469
00470
00471
00472 inline void AiboLeg::SetJoint(double start,double angle,
00473 LEG_JOINT joint,
00474 int cmdVecIndex)
00475 {
00476 AiboJoint::SetJoint(start, angle,
00477 JointID[joint], joint,
00478 cmdVecIndex);
00479 };
00480
00481
00482
00483
00484
00485 inline void AiboLeg::SetJoint(slongword angle,
00486 LEG_JOINT joint,
00487 int numFrames,
00488 int cmdVecIndex)
00489 {
00490 AiboJoint::SetJoint(JointValues[joint], ((double)angle)/MICRO,
00491 JointID[joint], joint,
00492 numFrames,
00493 cmdVecIndex);
00494 };
00495
00496
00497
00498
00499
00500 inline void AiboLeg::SetJoint(double angle,
00501 LEG_JOINT joint,
00502 int numFrames,
00503 int cmdVecIndex)
00504 {
00505 AiboJoint::SetJoint(JointValues[joint], angle,
00506 JointID[joint], joint,
00507 numFrames,
00508 cmdVecIndex);
00509 };
00510
00511
00512
00513
00514
00515 inline void AiboLeg::SetJoint(double start,double angle,
00516 LEG_JOINT joint,
00517 int numFrames,
00518 int cmdVecIndex)
00519 {
00520 AiboJoint::SetJoint(start, angle,
00521 JointID[joint], joint,
00522 numFrames,
00523 cmdVecIndex);
00524 };
00525
00526
00527
00528
00529
00530 inline void AiboLeg::SetJointRel(slongword angle,
00531 LEG_JOINT joint,
00532 int cmdVecIndex)
00533 {
00534 AiboJoint::SetJointRel(JointValues[joint], ((double)angle)/MICRO,
00535 JointID[joint], joint,
00536 cmdVecIndex);
00537 };
00538
00539
00540
00541
00542 inline void AiboLeg::SetJointRel(double angle,
00543 LEG_JOINT joint,
00544 int cmdVecIndex)
00545 {
00546 AiboJoint::SetJointRel(JointValues[joint], angle,
00547 JointID[joint], joint,
00548 cmdVecIndex);
00549 };
00550
00551
00552
00553
00554
00555 inline void AiboLeg::SetJointRel(double start, double angle,
00556 LEG_JOINT joint,
00557 int cmdVecIndex)
00558 {
00559 AiboJoint::SetJointRel(start, angle,
00560 JointID[joint], joint,
00561 cmdVecIndex);
00562 };
00563
00564
00565
00566
00567
00568 inline void AiboLeg::SetJointRel(slongword angle,
00569 LEG_JOINT joint,
00570 int numFrames,
00571 int cmdVecIndex)
00572 {
00573 AiboJoint::SetJointRel(JointValues[joint], ((double)angle)/MICRO,
00574 JointID[joint], joint,
00575 numFrames,
00576 cmdVecIndex);
00577 };
00578
00579
00580
00581
00582
00583 inline void AiboLeg::SetJointRel(double angle,
00584 LEG_JOINT joint,
00585 int numFrames,
00586 int cmdVecIndex)
00587 {
00588 AiboJoint::SetJointRel(JointValues[joint], angle,
00589 JointID[joint], joint,
00590 numFrames,
00591 cmdVecIndex);
00592 };
00593
00594
00595
00596
00597
00598 inline void AiboLeg::SetJointRel(double start, double angle,
00599 LEG_JOINT joint,
00600 int numFrames,
00601 int cmdVecIndex)
00602 {
00603 AiboJoint::SetJointRel(start, angle,
00604 JointID[joint], joint,
00605 numFrames,
00606 cmdVecIndex);
00607 };
00608
00609
00610
00611
00612
00613 inline double AiboLeg::GetJointValue(LEG_JOINT joint) const
00614 {
00615 return JointValues[joint];
00616 };
00617
00618
00619
00620
00621
00622 inline double AiboLeg::GetOPENRJointValue(LEG_JOINT joint) const
00623 {
00624 return AiboJoint::GetOPENRJointValue(JointID[joint]);
00625 };
00626
00627
00628
00629
00630
00631 inline double AiboLeg::GetMaxJointValue(int index, JOINT_UNIT unit) const
00632 {
00633 return GetMaxJointValue(LEG_JOINT(index), unit);
00634 };
00635
00636
00637
00638
00639 inline double AiboLeg::GetMinJointValue(int index, JOINT_UNIT unit) const
00640 {
00641 return GetMinJointValue(LEG_JOINT(index), unit);
00642 };
00643
00644
00645
00646
00647
00648 inline double AiboLeg::GetMaxJointVelocity(int index, JOINT_UNIT unit) const
00649 {
00650 return GetMaxJointVelocity(LEG_JOINT(index), unit);
00651 };
00652
00653
00654 #endif // define AIBOLEG_H