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

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:42 2016 by Doxygen 1.6.3