Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

BioloidInfo.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_BioloidInfo_h
00003 #define INCLUDED_BioloidInfo_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_BIOLOID)
00012 #  define TGT_IS_BIOLOID
00013 #  define TGT_HAS_WEBCAM 1
00014 #  ifdef BIOLOID_BEGINNER_KIT
00015 #    define TGT_HAS_LEDS 4
00016 #  else
00017 #    define TGT_HAS_LEDS 18
00018 #  endif
00019 #endif
00020 
00021 //! Declares configuration of generic bioloid/dynamixel based robots, such as number of joints, LEDs, etc.
00022 namespace BioloidInfo {
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   =  0;
00038   const unsigned NumArms        =  0;
00039   const unsigned NumArmJoints   =  JointsPerArm*NumArms;
00040   
00041   const unsigned JointsPerLeg   =  0; //!< The number of joints per leg
00042   const unsigned NumLegs        =  0; //!< The number of legs
00043   const unsigned NumLegJoints   =  JointsPerLeg*NumLegs; //!< the TOTAL number of joints on ALL legs
00044   const unsigned NumHeadJoints  =  0; //!< The number of joints in the pantilt
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 NumSensors     =  2;  //!< the number of sensors available (voltage and temperature)
00050   const unsigned NumFacePanelLEDs = 0; //!< The number of face panel LEDs
00051 
00052 #ifdef BIOLOID_BEGINNER_KIT
00053   const unsigned NumLEDs        =  4; //!< The number of LEDs which can be controlled (one per dynamixel servo)
00054   const unsigned NumPIDJoints   = 4 + NumWheels + NumArmJoints + NumLegJoints+NumHeadJoints+NumTailJoints+NumMouthJoints;; //!< servo pins
00055 #else
00056   const unsigned NumLEDs        =  18; //!< The number of LEDs which can be controlled (one per dynamixel servo)
00057   const unsigned NumPIDJoints   = 18 + NumWheels + NumArmJoints + NumLegJoints+NumHeadJoints+NumTailJoints+NumMouthJoints;; //!< servo pins
00058 #endif
00059   
00060   const unsigned NumOutputs     = NumWheels + NumPIDJoints + NumLEDs; //!< the total number of outputs
00061   const unsigned NumReferenceFrames = NumOutputs+1; //!< Since we don't know what the user built, we don't actually know any of the kinematics...
00062 
00063   using namespace Camera75DOF;
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   
00075   const unsigned PIDJointOffset = 0; //!< The beginning of the PID Joints
00076   const unsigned WheelOffset = PIDJointOffset;
00077 
00078   const unsigned LEDOffset   = PIDJointOffset + NumPIDJoints; //!< the offset of LEDs in WorldState::outputs and MotionCommand functions, see LedOffset_t for specific offsets
00079 
00080   const unsigned BaseFrameOffset   = NumOutputs; //!< Use with kinematics to refer to base reference frame
00081 
00082   enum WheelOffset_t {
00083     LWheelOffset=WheelOffset,
00084     RWheelOffset
00085   };
00086   
00087   //! The offsets of the individual LEDs -- except we don't have any idea what to 'name' the servos in a reconfigurable kit, so this is empty (just add numeric offsets)
00088   /*! @hideinitializer */
00089   enum LEDOffset_t { };
00090   
00091   typedef unsigned int LEDBitMask_t; //!< So you can be clear when you're refering to a LED bitmask
00092   //! LEDs for the face panel (all FaceLEDPanelMask<<(0:NumFacePanelLEDs-1) entries)
00093   const LEDBitMask_t FaceLEDMask = 0;
00094   //! selects all of the leds
00095   const LEDBitMask_t AllLEDMask  = (LEDBitMask_t)~0;
00096   //@}
00097 
00098 
00099   // *******************************
00100   //          INPUT OFFSETS
00101   // *******************************
00102 
00103 
00104   //! The order in which inputs should be stored
00105   //!@name Input Offsets
00106 
00107   //! holds offsets to different buttons in WorldState::buttons[]
00108   /*! Should be a straight mapping to the ButtonSourceIDs
00109    *
00110    *  Note that the chest (power) button is not a normal button.  It kills
00111    *  power to the motors at a hardware level, and isn't sensed in the
00112    *  normal way.  If you want to know when it is pressed (and you are
00113    *  about to shut down) see PowerSrcID::PauseSID.
00114    *
00115    *  @see WorldState::buttons @see ButtonSourceID_t
00116    * @hideinitializer */
00117   enum ButtonOffset_t { };
00118 
00119   //! Provides a string name for each button
00120   const char* const buttonNames[NumButtons+1] = { NULL }; // non-empty array to avoid gcc 3.4.2 internal error
00121 
00122   //! holds offset to different sensor values in WorldState::sensors[]
00123   /*! @see WorldState::sensors[] */
00124   enum SensorOffset_t {
00125     PowerThermoOffset, //!< degrees Celcius
00126     PowerVoltageOffset, //!< volts
00127   };
00128 
00129   //! Provides a string name for each sensor
00130   const char* const sensorNames[NumSensors+1] = {
00131     "PowerThermo","PowerVoltage", NULL
00132   };
00133 
00134   //@}
00135 
00136 
00137   //! Names for each of the outputs
00138   const char* const outputNames[NumReferenceFrames+1] = {
00139     "SERVO:000",
00140     "SERVO:001",
00141     "SERVO:002",
00142     "SERVO:003",
00143 #ifndef BIOLOID_BEGINNER_KIT
00144     "SERVO:004",
00145     "SERVO:005",
00146     "SERVO:006",
00147     "SERVO:007",
00148     "SERVO:008",
00149     "SERVO:009",
00150     "SERVO:010",
00151     "SERVO:011",
00152     "SERVO:012",
00153     "SERVO:013",
00154     "SERVO:014",
00155     "SERVO:015",
00156     "SERVO:016",
00157     "SERVO:017",
00158 #endif
00159     "LED:00000",
00160     "LED:00001",
00161     "LED:00002",
00162     "LED:00003",
00163 #ifndef BIOLOID_BEGINNER_KIT
00164     "LED:00004",
00165     "LED:00005",
00166     "LED:00006",
00167     "LED:00007",
00168     "LED:00008",
00169     "LED:00009",
00170     "LED:00010",
00171     "LED:00011",
00172     "LED:00012",
00173     "LED:00013",
00174     "LED:00014",
00175     "LED:00015",
00176     "LED:00016",
00177     "LED:00017",
00178 #endif
00179     "BaseFrame",
00180     NULL
00181   };
00182   
00183   //! allocation declared in RobotInfo.cc
00184   extern const Capabilities capabilities;
00185   
00186   //! offsets into DefaultPIDs, since Dynamixel servos don't actually use PID control, but a different set of parameters
00187   enum ServoParam_t {
00188     DYNAMIXEL_SLOPE=0, //!< compliance slope, the proportional control (P in PID)
00189     DYNAMIXEL_PUNCH, //!< punch, a constant added to the slope once error exceeds compliance margin
00190     DYNAMIXEL_MARGIN //!< compliance margin, the amount of error to tolerate before triggering a torque response
00191   };
00192   
00193   //! Dynamixel servos don't use PID control.  Instead, these values indicate compliance slope (P), punch (add to P*error), compliance margin (min error to start applying torque) (see ServoParam_t)
00194   /*! I believe the torque calculation goes something like: torque = (error<compliance) ? 0 : punch + P*error
00195    *  Dynamixel servos allow different values to be supplied for CW vs. CCW motion, but we just use the same value for each */
00196   const float DefaultPIDs[NumPIDJoints][3] = {
00197     {32,32,0}, {32,32,0}, {32,32,0}, {32,32,0}, 
00198 #ifndef BIOLOID_BEGINNER_KIT
00199     {32,32,0}, {32,32,0}, {32,32,0}, {32,32,0}, 
00200     {32,32,0}, {32,32,0}, {32,32,0}, {32,32,0}, 
00201     {32,32,0}, {32,32,0}, {32,32,0}, {32,32,0}, 
00202     {32,32,0}, {32,32,0},
00203 #endif
00204   };
00205   
00206   //!These values are our recommended maximum joint velocities, in rad/ms
00207   /*! a value <= 0 means infinite speed (e.g. LEDs)
00208    *  
00209    *  These limits are <b>not</b> enforced by the framework.  They are simply available for you to use as you see fit.
00210    *  HeadPointerMC and PostureMC are primary examples of included classes which do respect these values (although they can be overridden)
00211    *  
00212    *  These values were obtained from the administrators of the Sony OPEN-R BBS */
00213   const float MaxOutputSpeed[NumOutputs] = {
00214     // servos
00215     0,0,0,0,
00216 #ifndef BIOLOID_BEGINNER_KIT
00217     0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,
00218 #endif
00219     // leds
00220     0,0,0,0,
00221 #ifndef BIOLOID_BEGINNER_KIT
00222     0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,
00223 #endif
00224   };
00225 
00226   #ifndef RAD
00227     //!Just a little macro for converting degrees to radians
00228   #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00229     //!a flag so we undef these after we're done - do you have a cleaner solution?
00230   #define __RI_RAD_FLAG
00231   #endif
00232   
00233   //! 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)
00234   const float outputRanges[NumOutputs][2] = {
00235     // servos
00236     {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, 
00237 #ifndef BIOLOID_BEGINNER_KIT
00238     {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)},
00239     {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)},
00240     {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)},
00241     {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, 
00242 #endif
00243 
00244     // LED
00245     {0,1}, {0,1}, {0,1}, {0,1},
00246 #ifndef BIOLOID_BEGINNER_KIT
00247     {0,1}, {0,1}, {0,1}, {0,1},
00248     {0,1}, {0,1}, {0,1}, {0,1},
00249     {0,1}, {0,1}, {0,1}, {0,1},
00250     {0,1}, {0,1},
00251 #endif
00252   };
00253 
00254   //! This table holds the mechanical limits of each of the outputs, first index is the output offset, second index is MinMaxRange_t (i.e. MinRange or MaxRange)
00255   /*! Same as #outputRanges, don't know actual values because they were never specified by Sony */
00256   const float mechanicalLimits[NumOutputs][2] = {
00257     // servos
00258     {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, 
00259 #ifndef BIOLOID_BEGINNER_KIT
00260     {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)},
00261     {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)},
00262     {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)},
00263     {RAD(-150),RAD(150)}, {RAD(-150),RAD(150)}, 
00264 #endif
00265     
00266     // LED
00267     {0,1}, {0,1}, {0,1}, {0,1},
00268 #ifndef BIOLOID_BEGINNER_KIT
00269     {0,1}, {0,1}, {0,1}, {0,1},
00270     {0,1}, {0,1}, {0,1}, {0,1},
00271     {0,1}, {0,1}, {0,1}, {0,1},
00272     {0,1}, {0,1},
00273 #endif
00274   };
00275 
00276 #ifdef __RI_RAD_FLAG
00277 #undef RAD
00278 #undef __RI_RAD_FLAG
00279 #endif
00280 }
00281 
00282 /*! @file
00283  * @brief Defines some capabilities common to generic bioloid/dynamixel based robots
00284  * @author ejt (Creator)
00285  */
00286 
00287 #endif

Tekkotsu v5.1CVS
Generated Tue Jan 31 04:31:47 2012 by Doxygen 1.6.3