Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

aibojoint.h

Go to the documentation of this file.
00001 // ***************************************************************************
00002 //                           aibojoint.h
00003 //
00004 //    copyright            : (C) 2003 by tbaier
00005 //    email                : tbaier@informatik.uni-hamburg.de
00006 // ***************************************************************************
00007 
00008 #ifndef AIBOJOINT_H
00009 #define AIBOJOINT_H
00010 
00011 
00012 //std includes
00013 #include <math.h>
00014 
00015 //AIBO includes
00016 #include <OPENR/ODataFormats.h>
00017 #include <OPENR/OObject.h>
00018 #include <OPENR/OPENRAPI.h>
00019 #include <OPENR/OSyslog.h>
00020 #include <Types.h>
00021 
00022 #include "aibosensor.h"
00023 #include "defines.h"
00024 
00025 enum JOINT_STATE{
00026   J_UNDEF,
00027   J_START
00028 };
00029 
00031 enum JOINT_UNIT{
00032   ANGLE_DEG, 
00033   ANGLE_RAD  
00034 };
00035 
00037 static const int NUM_JOINTS = 15;
00038 
00039 
00056 class AiboJoint  {
00057 
00058  public: 
00060     AiboJoint();
00061 
00063     virtual ~AiboJoint();
00064 
00068 
00070     virtual void OpenPrimitives() = 0;
00071     
00072     OPrimitiveID GetJointID(int j) const;
00074 
00078 
00083     RCRegion* FindFreeRegion() const;
00084     
00089     int FindFreeRegionIndex() const;
00090 
00092     RCRegion* GetRegion(int index = 0);
00093 
00094     
00096     virtual void NewCommandVectorData() = 0;
00097 
00104     void SetCommandVector(int index, OCommandVectorData *vec);
00105 
00106    
00108 
00112     
00121     void SetJointOPENR(slongword angle, 
00122                        OPrimitiveID joint, int jointIndex, 
00123                        int cmdVecIndex);
00124 
00134     void SetJointOPENR(double angle, 
00135                        OPrimitiveID joint, int jointIndex, 
00136                        int cmdVecIndex);
00137 
00147     void SetJoint(double start, double angle,
00148                   OPrimitiveID joint, int jointIndex, 
00149                   int cmdVecIndex);
00150     
00151     
00163     void SetJoint(double start, double angle,
00164                   OPrimitiveID joint, int jointIndex, 
00165                   int numFrames, int cmdVecIndex);
00166     
00175     void SetJoint(double angle,
00176                   OPrimitiveID joint, int jointIndex, 
00177                   int cmdVecIndex);
00178 
00179 
00190     void SetJoint(double angle,
00191                   OPrimitiveID joint, int jointIndex, 
00192                   int numFrames, int cmdVecIndex);
00193     
00194     
00204     void SetJoint(slongword angle, 
00205                   OPrimitiveID joint, int jointIndex, 
00206                   int cmdVecIndex);
00207 
00208 
00219     void SetJoint(slongword angle,
00220                   OPrimitiveID joint, int jointIndex, 
00221                   int numFrames, int cmdVecIndex);
00222 
00223 
00224     
00225     
00233     void SetJointRelOPENR(slongword angle, 
00234                           OPrimitiveID joint, int jointIndex, 
00235                           int cmdVecIndex);
00236     
00237        
00249     void SetJointRelOPENR(double angle, 
00250                           OPrimitiveID joint, int jointIndex, 
00251                           int cmdVecIndex);
00252    
00263     void SetJointRel(double start, double angle, 
00264                      OPrimitiveID joint, int jointIndex, 
00265                      int cmdVecIndex);
00266 
00267      
00279     void SetJointRel(double start, double angle, 
00280                      OPrimitiveID joint, int jointIndex, 
00281                      int numFrames, int cmdVecIndex);
00282 
00283 
00284 
00294     void SetJointRel(double angle, 
00295                      OPrimitiveID joint, int jointIndex, 
00296                      int cmdVecIndex);
00297     
00309     void SetJointRel(double angle,
00310                      OPrimitiveID joint, int jointIndex, 
00311                      int numFrames, int cmdVecIndex);
00312 
00313 
00314 
00324     void SetJointRel(slongword angle, 
00325                      OPrimitiveID joint, int jointIndex, 
00326                      int cmdVecIndex);
00327     
00340     void SetJointRel(slongword angle,
00341                      OPrimitiveID joint, int jointIndex, 
00342                      int numFrames, int cmdVecIndex);
00343 
00344 
00345 
00346 
00350     void RefreshCommandVector(int cmdVecIndex);
00351     
00354      void RefreshCommandVectors();
00355 
00358      void RefreshJointValue(int index);
00359 
00361      void RefreshJointValues();
00362 
00363 
00365 
00366     
00374     double GetJointValue(int index) const;
00375 
00376     
00381     double GetOPENRJointValue(OPrimitiveID joint) const;
00382 
00383 
00388     double GetOPENRJointValue(int joint) const;
00389     
00390     
00396     virtual double GetMaxJointValue(int index, JOINT_UNIT unit = ANGLE_RAD) const = 0;
00397 
00398 
00404     virtual double GetMinJointValue(int index, JOINT_UNIT unit = ANGLE_RAD ) const = 0;
00405     
00411     virtual double GetMaxJointVelocity(int index, JOINT_UNIT unit = ANGLE_RAD) const = 0 ;
00412     
00414 
00415 
00419     
00421     virtual void SetJointGain()= 0;
00422  
00424     void EnableJointGain();
00425        
00429     void EnableJointGain(OPrimitiveID id);
00430     
00433     void DisableJointGain();
00434 
00438     void DisableJointGain(OPrimitiveID id);
00439       
00440 
00442 
00443 
00447   
00448 
00452     JOINT_STATE GetState() const;
00453 
00457     void SetState(JOINT_STATE st);
00458 
00460 
00464     int GetNumJoints() const;
00465 
00467     static const int    MaxJointRegions = 2;
00468     
00470     RCRegion*           Region[MaxJointRegions];
00471 
00472  protected:
00473     
00474     // VARS---------------------------------------------------------------------
00475 
00477     JOINT_STATE         State;
00478 
00480     int                 NumJoints;
00481 
00483     double              *JointValues; 
00484   
00486     OPrimitiveID        *JointID;
00487     
00490     static const word   PSHIFT   = 0x000e;
00492     static const word   ISHIFT   = 0x0002;
00494     static const word   DSHIFT   = 0x000f;
00495     
00503     double FrameFactor[ocommandMAX_FRAMES];
00504 
00505 };
00506 
00507 
00508 // ******************************************
00509 // **                                      **
00510 // ******************************************
00511 inline OPrimitiveID AiboJoint::GetJointID(int j) const
00512 {
00513   return JointID[j];
00514 };
00515 
00516 
00517 // ******************************************
00518 // **                                      **
00519 // ******************************************
00520 inline int AiboJoint::GetNumJoints() const
00521 {
00522   return NumJoints;
00523 };
00524 
00525 
00526 // ******************************************
00527 // **                                      **
00528 // ******************************************
00529 inline JOINT_STATE AiboJoint::GetState() const
00530 {
00531   return State;
00532 };
00533 
00534 
00535 // ******************************************
00536 // **                                      **
00537 // ******************************************
00538 inline void AiboJoint::SetState(JOINT_STATE st)
00539 {
00540   State = st;
00541 };
00542 
00543 
00544 // ******************************************
00545 // **                                      **
00546 // ******************************************
00547 inline void AiboJoint::EnableJointGain()
00548 {
00549   for(int i = NumJoints-1; i >= 0; i--)
00550     EnableJointGain(JointID[i]);
00551 };
00552 
00553 
00554 // ******************************************
00555 // **                                      **
00556 // ******************************************
00557 inline void AiboJoint::EnableJointGain(OPrimitiveID id)
00558 {
00559   OPENR::EnableJointGain(id);
00560 };
00561 
00562 
00563 // ******************************************
00564 // **                                      **
00565 // ******************************************
00566 inline void AiboJoint::DisableJointGain()
00567 {
00568   for(int i = NumJoints-1; i >= 0; i--)
00569     DisableJointGain(JointID[i]);
00570 };
00571 
00572 
00573 // ******************************************
00574 // **                                      **
00575 // ******************************************
00576 inline void AiboJoint::DisableJointGain(OPrimitiveID id)
00577 {
00578   OPENR::DisableJointGain(id);
00579 };
00580 
00581 
00582 // ******************************************
00583 // **                                      **
00584 // ******************************************
00585 inline RCRegion* AiboJoint::GetRegion(int index)
00586 {
00587   return Region[index];
00588 };
00589  
00590 
00591 // ******************************************
00592 // **                                      **
00593 // ******************************************
00594 inline void AiboJoint::SetJointOPENR(slongword angle, 
00595                                      OPrimitiveID joint, int jointIndex, 
00596                                      int cmdVecIndex)
00597 {
00598   SetJointOPENR(((double) angle)/MICRO,
00599                 joint,jointIndex, 
00600                 cmdVecIndex);
00601 };
00602 
00603 
00604 // ******************************************
00605 // **                                      **
00606 // ******************************************
00607 inline void AiboJoint::SetJoint(slongword angle,
00608                                 OPrimitiveID joint, int jointIndex,
00609                                 int cmdVecIndex)
00610 { 
00611   SetJoint(JointValues[jointIndex], ((double)angle)/MICRO,
00612            joint, jointIndex,
00613            cmdVecIndex);
00614 };
00615 
00616 
00617 // ******************************************
00618 // **                                      **
00619 // ******************************************
00620 inline void AiboJoint::SetJoint(double angle,
00621                                 OPrimitiveID joint, int jointIndex,
00622                                 int cmdVecIndex)
00623 { 
00624   SetJoint(JointValues[jointIndex], angle,
00625            joint, jointIndex,
00626            cmdVecIndex);
00627 };
00628 
00629 
00630 // ******************************************
00631 // **                                      **
00632 // ******************************************
00633 inline void AiboJoint::SetJoint(double angle,
00634                                 OPrimitiveID joint, int jointIndex,
00635                                 int numFrames, int cmdVecIndex)
00636 { 
00637   SetJoint(JointValues[jointIndex], angle,
00638            joint, jointIndex,
00639            numFrames, cmdVecIndex);
00640 };
00641 
00642 
00643 // ******************************************
00644 // **                                      **
00645 // ******************************************
00646 inline void AiboJoint::SetJoint(slongword angle,
00647                                 OPrimitiveID joint, int jointIndex,
00648                                 int numFrames, int cmdVecIndex)
00649 { 
00650   SetJoint(JointValues[jointIndex], (double)angle/MICRO,
00651            joint, jointIndex,
00652            numFrames, cmdVecIndex);
00653 };
00654 
00655 
00656 // ******************************************
00657 // **                                      **
00658 // ******************************************
00659 inline void AiboJoint::SetJointRelOPENR(slongword angle, 
00660                                         OPrimitiveID joint, int jointIndex, 
00661                                         int cmdVecIndex)
00662 {
00663   SetJointRelOPENR(((double) angle)/MICRO,
00664                    joint, jointIndex,
00665                    cmdVecIndex);
00666 };
00667 
00668 
00669 // ******************************************
00670 // **                                      **
00671 // ******************************************
00672 inline void AiboJoint::SetJointRel(double angle, 
00673                                    OPrimitiveID joint, int jointIndex,
00674                                    int cmdVecIndex)
00675 { 
00676   SetJointRel(JointValues[jointIndex], angle, 
00677               joint, jointIndex, 
00678               cmdVecIndex);
00679   
00680 };
00681 
00682 
00683 // ******************************************
00684 // **                                      **
00685 // ******************************************
00686 inline void AiboJoint::SetJointRel(double angle, 
00687                                    OPrimitiveID joint, int jointIndex,
00688                                    int numFrames, int cmdVecIndex)
00689 { 
00690   SetJointRel(JointValues[jointIndex], angle, 
00691               joint, jointIndex, 
00692               numFrames, cmdVecIndex);
00693   
00694 };
00695 
00696 
00697 // ******************************************
00698 // **                                      **
00699 // ******************************************
00700 inline void AiboJoint::SetJointRel(slongword angle, 
00701                                    OPrimitiveID joint, int jointIndex,
00702                                    int cmdVecIndex)
00703 { 
00704   SetJointRel(JointValues[jointIndex], ((double) angle)/MICRO, 
00705               joint, jointIndex, 
00706               cmdVecIndex);
00707   
00708 };
00709 
00710 
00711 // ******************************************
00712 // **                                      **
00713 // ******************************************
00714 inline void AiboJoint::SetJointRel(slongword angle, 
00715                                    OPrimitiveID joint, int jointIndex,
00716                                    int numFrames, int cmdVecIndex)
00717 { 
00718   SetJointRel(JointValues[jointIndex],  ((double) angle)/MICRO, 
00719               joint, jointIndex, 
00720               numFrames, cmdVecIndex);
00721   
00722 };
00723 
00724 
00725 // ******************************************
00726 // **                                      **
00727 // ******************************************
00728 inline double AiboJoint::GetJointValue(int index) const
00729 {
00730   return JointValues[index];
00731 };
00732 
00733 
00734 // ******************************************
00735 // **                                      **
00736 // ******************************************
00737 inline void AiboJoint::RefreshCommandVectors()
00738 {
00739   for(int i = MaxJointRegions-1; i >= 0; i--)
00740     RefreshCommandVector(i);
00741 };
00742 
00743 
00744 // ******************************************
00745 // **                                      **
00746 // ******************************************
00747 inline void AiboJoint::RefreshJointValues()
00748 {
00749   for(int i = NumJoints-1; i >= 0; i--)
00750     RefreshJointValue(i);
00751 };
00752 
00753 
00754 #endif //define AIBOJOINT_H


tams Tim Baier AiboLib v0.2.4
Generated Thu Jan 19 11:54:29 2006 by doxygen 1.4.3