Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

KHR2Info.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_KHR2Info_h
00003 #define INCLUDED_KHR2Info_h
00004 
00005 #include <cmath>
00006 #include <stdlib.h>
00007 #include "CommonInfo.h"
00008 using namespace RobotInfo;
00009 
00010 // see http://tekkotsu.org/porting.html#configuration for more information on TGT_HAS_* flags
00011 #if defined(TGT_KHR2)
00012 #  define TGT_IS_BIPED
00013 #  define TGT_IS_HUMANOID
00014 #  define TGT_IS_KHR2
00015 #  define TGT_HAS_CAMERA 1
00016 #  define TGT_HAS_LEGS 2
00017 #  define TGT_HAS_ARMS 2
00018 #  define TGT_HAS_HEAD 1
00019 #endif
00020 
00021 //! Contains information about an KHR2 humanoid robot, such as number of joints, LEDs, etc.
00022 namespace KHR2Info {
00023 
00024   // *******************************
00025   //       ROBOT CONFIGURATION
00026   // *******************************
00027 
00028   extern const char* const TargetName; //!< the name of the model, to be used for logging and remote GUIs
00029 
00030   const unsigned int FrameTime=32;       //!< time between frames in the motion system (milliseconds)
00031   const unsigned int NumFrames=1;        //!< the number of frames per buffer (don't forget also double buffered)
00032   const unsigned int SoundBufferTime=32; //!< the number of milliseconds per sound buffer... I'm not sure if this can be changed
00033   
00034   //!@name Output Types Information
00035   const unsigned NumWheels      =  0;
00036   
00037   const unsigned JointsPerArm   =  3;
00038   const unsigned NumArms        =  2;
00039   const unsigned NumArmJoints   =  JointsPerArm*NumArms;//                                                 6
00040   
00041   const unsigned JointsPerLeg   =  5; //!< The number of joints per leg
00042   const unsigned NumLegs        =  2; //!< The number of legs
00043   const unsigned NumLegJoints   =  JointsPerLeg*NumLegs; //!< the TOTAL number of joints on ALL legs      10
00044   const unsigned NumHeadJoints  =  1; //!< The number of joints in the pantilt                             1
00045   const unsigned NumTailJoints  =  0; //!< The number of joints assigned to the tail
00046   const unsigned NumMouthJoints =  0; //!< the number of joints that control the mouth
00047   const unsigned NumEarJoints   =  0; //!< The number of joints which control the ears (NOT per ear, is total)
00048   const unsigned NumButtons     =  0; //!< the number of buttons that are available
00049   const unsigned SensorsPerFoot = 6;
00050         const unsigned NumIMUAxes     = 3;
00051         const unsigned NumFootSensors = SensorsPerFoot*NumLegs;
00052   const unsigned NumSensors     =  NumArms + NumLegs*6 + 3;  // 2 grippers, 12 foot pressure sensors, 3 axis imu
00053   const unsigned NumFacePanelLEDs = 0; //!< The number of face panel LEDs
00054 
00055   const unsigned NumLEDs        =  0;//NumLegs + 1 + 4; //!< There's an LED on every dynamixel, but can't see most of them, so save some computational resources and only expose the visible ones: knees and pan
00056   const unsigned NumPIDJoints   = NumArmJoints+NumLegJoints+NumHeadJoints; //!< servo pins             15
00057   
00058   const unsigned NumOutputs     = NumWheels + NumPIDJoints + NumLEDs; //!< the total number of outputs    17
00059   const unsigned NumReferenceFrames = NumOutputs + NumLegs + NumArms + 1 + 1; //!< for the feet (NumLegs), arms, base, and camera  23
00060 
00061   using namespace Camera75DOF;
00062   
00063   const float BallOfFootRadius=23.433f / 2; //!< radius of the ball of the foot
00064   //@}
00065 
00066 
00067   // *******************************
00068   //         OUTPUT OFFSETS
00069   // *******************************
00070 
00071   //!Corresponds to entries in ERS7Info::PrimitiveName, defined at the end of this file
00072   //!@name Output Offsets
00073 
00074   const unsigned PIDJointOffset = 0; //!< The beginning of the PID Joints
00075   //const unsigned RFrRotatorOffset = PIDJointOffset;
00076   const unsigned ArmOffset   = PIDJointOffset;          //!< 0 - the offset of the beginning of the arm joints
00077   const unsigned LegOffset   = ArmOffset+NumArmJoints;   //!< 6 - the offset of the beginning of the leg joints
00078   const unsigned HeadOffset  = LegOffset+NumLegJoints;  //!< 16 - the offset of the beginning of the head joint
00079   const unsigned LEDOffset   = PIDJointOffset + NumPIDJoints; //!< 17 - the offset of LEDs
00080   const unsigned BaseFrameOffset    = NumOutputs; //!< 17 - Use with kinematics to refer to base reference frame
00081   const unsigned CameraFrameOffset  = BaseFrameOffset+1; //!< 18  
00082   const unsigned GripperFrameOffset = CameraFrameOffset+1; //!< 19 
00083   const unsigned FootFrameOffset    = GripperFrameOffset+NumLegs; //!< 21 
00084 
00085   //! the ordering of arms
00086   enum ArmOrder_t
00087   {
00088     LeftArmOrder = 0,   //!< left arm
00089     RightArmOrder       //!< right arm
00090   };
00091 
00092   //! the ordering of legs
00093   enum LegOrder_t
00094   {
00095     LeftLegOrder = 0,   //!< left leg
00096     RightLegOrder       //!< right leg
00097   };
00098 
00099   enum RLEOffset_t
00100   {
00101     ArmShoulderRotateOffset = 0,
00102     ArmShoulderOffset,
00103     ArmElbowOffset
00104   };
00105 
00106   //tilt, pan, roll
00107   enum TPROffset_t
00108   {
00109     PanOffset = 0,
00110     TiltOffset = PanOffset
00111   };
00112 
00113   enum AHKALOffset_t
00114   {
00115     LegHipAbduceOffset = 0,
00116     LegHipOffset,
00117     LegKneeOffset,
00118     LegAnkleOffset,
00119     LegAnkleLateralOffset
00120   };
00121 
00122   enum ArmOffset_t
00123   {
00124     LeftArmOffset = ArmOffset+LeftArmOrder*JointsPerArm, // 0+0*3 = 0
00125     RightArmOffset = ArmOffset+RightArmOrder*JointsPerArm// 0+1*3 = 3
00126   };
00127 
00128   enum LegOffset_t
00129   {
00130     LeftLegOffset = LegOffset+LeftLegOrder*JointsPerLeg, //6+0*5 = 6
00131     RightLegOffset = LegOffset+RightLegOrder*JointsPerLeg//6+1*5 = 11
00132   };
00133 
00134   enum HeadOffset_t
00135   {
00136     HeadPanOffset = HeadOffset //16
00137   };
00138 
00139   enum LEDOffset_t {};
00140 
00141   // *******************************
00142   //          INPUT OFFSETS
00143   // *******************************
00144 
00145 
00146   //! The order in which inputs should be stored
00147   //!@name Input Offsets
00148 
00149   //! holds offsets to different buttons in WorldState::buttons[]
00150   /*! Should be a straight mapping to the ButtonSourceIDs
00151    *
00152    *  Note that the chest (power) button is not a normal button.  It kills
00153    *  power to the motors at a hardware level, and isn't sensed in the
00154    *  normal way.  If you want to know when it is pressed (and you are
00155    *  about to shut down) see PowerSrcID::PauseSID.
00156    *
00157    *  @see WorldState::buttons @see ButtonSourceID_t
00158    * @hideinitializer */
00159   enum ButtonOffset_t {};
00160 
00161   //! Provides a string name for each button
00162   const char* const buttonNames[NumButtons+1] = {NULL};
00163 
00164   /*! holds offset to different sensor values in WorldState::sensors[]
00165    *  @see WorldState::sensors[] */
00166   enum SensorOffset_t
00167   {
00168     LStressOffset, RStressOffset,
00169 
00170     LLToeOffset, LRToeOffset, LLSoleOffset, LRSoleOffset, LLBackOffset, LRBackOffset,
00171 
00172                 //! right foot pressure sensors
00173                 RLToeOffset, RRToeOffset, RLSoleOffset, RRSoleOffset, RLBackOffset, RRBackOffset,
00174 
00175     //! ... be careful about the signs on all of these...
00176 
00177     /*! backward acceleration, in @f$m/s^2@f$
00178      *  (negative if laying on back) */
00179     BAccelOffset,
00180 
00181     /*! acceleration to the robot's left, in @f$m/s^2@f$
00182      *  (negative if lying on the robot's right side) */
00183     LAccelOffset,
00184 
00185     /*! download acceleration, in @f$m/s^2@f$
00186      *  (negative if standing up) */
00187     DAccelOffset//,
00188 
00189     //PowerVoltageOffset   //!< power status, in volts
00190   };
00191 
00192   //! provides a string name for each sensor
00193   const char* const sensorNames[NumSensors + 1] = {
00194     "LStress", "RStress",
00195 
00196     //! left foot pressure sensors
00197     "LLToe", "LRToe", "LLSole", "LRSole", "LLBack", "LRBack",
00198 
00199     //! right foot pressure sensors
00200     "RLToe", "RRToe", "RLSole", "RRSole", "RLBack", "RRBack",
00201 
00202     "BAccel", "LAccel", "DAccel"//,
00203 
00204     //"PowerVoltage"
00205   };
00206 
00207   //! names for each of the outputs
00208   const char* const outputNames[NumReferenceFrames + 1] = {
00209 
00210     //! names for the left arm outputs
00211     "LArm:Rotate", "LArm:Elevator", "LArm:Elbow",
00212 
00213     //! names for the right arm outputs
00214     "RArm:Rotate", "RArm:Elevator", "RArm:Elbow",
00215     
00216     //! names for the left leg outputs
00217     "LLeg:Abduce", "LLeg:Flex", "LLeg:Knee",
00218     "LLeg:AnkleFlex",
00219      "LLeg:AnkleLateral",
00220 
00221     //! names for the right left outputs
00222     "RLeg:Abduce", "RLeg:Flex", "RLeg:Knee",
00223     "RLeg:AnkleFlex",
00224      "RLeg:AnkleLateral",
00225 
00226     //! names for each of the neck outputs
00227     "NECK:Pan",
00228     
00229     "BaseFrame",
00230     "CAMERA:Eye",// 18
00231     "LArm:Wrist",// 19
00232     "RArm:Wrist",
00233     "LLeg:Sole",// 21
00234     "RLeg:Sole",
00235     NULL
00236   };
00237   
00238   //! allocation declared in RobotInfo.cc
00239   extern const Capabilities capabilities;
00240   
00241   //! this table holds the default PID values for each joint; see PIDMC
00242   const float DefaultPIDs[NumPIDJoints][3] = {
00243     {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, // PID joints
00244     {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0},
00245     {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0},
00246     {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, 
00247     {1, 0, 0}
00248   };
00249   
00250   //!These values are our recommended maximum joint velocities, in rad/ms
00251   /*! a value <= 0 means infinite speed (e.g. LEDs)
00252    *  
00253    *  These limits are <b>not</b> enforced by the framework.  They are simply available for you to use as you see fit.
00254    *  HeadPointerMC and PostureMC are primary examples of included classes which do respect these values (although they can be overridden)
00255    *  
00256    *  These values were obtained from the administrators of the Sony OPEN-R BBS */
00257   //! haven't determined safe speeds for KHR2 yet
00258   const float MaxOutputSpeed[NumOutputs] = {
00259 
00260     //! PID joints
00261     1e-3f, 1e-3f, 1e-3f, 1e-3f, 1e-3f, 1e-3f, 1e-3f, 1e-3f,
00262     1e-3f, 1e-3f, 1e-3f, 1e-3f, 1e-3f, 1e-3f, 1e-3f, 1e-3f, 
00263     1e-3f
00264   };
00265 
00266   #ifndef RAD
00267     //!Just a little macro for converting degrees to radians
00268   #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00269     //!a flag so we undef these after we're done - do you have a cleaner solution?
00270   #define __RI_RAD_FLAG
00271   #endif
00272   
00273   //! This table holds the software limits of each of the outputs, first index is the output offset, second index is MinMaxRange_t (i.e. MinRange or MaxRange)
00274   const float outputRanges[NumOutputs][2] = {
00275 
00276     //! left arm
00277     {RAD(0), RAD(180)}, {RAD(0), RAD(180)}, {RAD(-90), RAD(90)},
00278 
00279     //! right arm
00280     {RAD(0), RAD(180)}, {RAD(0), RAD(180)}, {RAD(-90), RAD(90)},
00281 
00282     //! left leg
00283     {RAD(-10), RAD(90)}, {RAD(-90), RAD(90)}, {RAD(-90), RAD(20)},
00284     {RAD(-90), RAD(90)},
00285      {RAD(-70), RAD(20)},
00286 
00287     //! right leg
00288     {RAD(-10), RAD(90)}, {RAD(-90), RAD(90)}, {RAD(-90), RAD(20)},
00289     {RAD(-90), RAD(90)},
00290      {RAD(-70), RAD(20)},
00291 
00292     //! head (neck)
00293     {RAD(-90), RAD(90)}
00294   };
00295 
00296   /*! the range that can be reached by external interaction
00297    * (i.e. the domain of the output feedback);
00298    *  this is probably identical to #outputRanges,
00299    *  but may differ if the output have some built-in safety margin... */
00300   const float mechanicalLimits[NumOutputs][2] = {
00301 
00302     //! left arm
00303         {RAD(0), RAD(180)}, {RAD(0), RAD(180)}, {RAD(-90), RAD(90)},
00304 
00305     //! right arm
00306     {RAD(0), RAD(180)}, {RAD(0), RAD(180)}, {RAD(-90), RAD(90)},
00307 
00308     //! left leg
00309     {RAD(-10), RAD(90)}, {RAD(-90), RAD(90)}, {RAD(-90), RAD(20)},
00310     {RAD(-90), RAD(90)},
00311      {RAD(-70), RAD(20)},
00312 
00313     //! right leg
00314     {RAD(-10), RAD(90)}, {RAD(-90), RAD(90)}, {RAD(-90), RAD(20)},
00315     {RAD(-90), RAD(90)},
00316      {RAD(-70), RAD(20)},
00317 
00318     //! head (neck)
00319     {RAD(-90), RAD(90)}
00320   };
00321 
00322 #ifdef __RI_RAD_FLAG
00323 #undef RAD
00324 #undef __RI_RAD_FLAG
00325 #endif
00326 }
00327 
00328 /*! @file
00329  * @brief Defines some capabilities of the KHR2 humanoid robots
00330  * $Author: ejt $
00331  * $Name:  $
00332  * $Revision: 1.3 $
00333  * $State: Exp $
00334  * $Date: 2011-03-10 16:45:43 $
00335  */
00336 
00337 #endif

Tekkotsu v5.1CVS
Generated Fri Mar 16 05:26:42 2012 by Doxygen 1.6.3