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

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