Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

QBotPlusInfo.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_QBotPlusInfo_h
00003 #define INCLUDED_QBotPlusInfo_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_QBOTPLUS)
00012 #  define TGT_IS_QWERK
00013 #  define TGT_HAS_WHEELS 2
00014 #  define TGT_HAS_LEDS 10
00015 #  define TGT_HAS_CAMERA 1
00016 #  define TGT_HAS_HEAD 1
00017 #endif
00018 
00019 namespace QBotPlusInfo {
00020 
00021   // *******************************
00022   //       ROBOT CONFIGURATION
00023   // *******************************
00024 
00025   extern const char* const TargetName; //!< the name of the model, to be used for logging and remote GUIs
00026 
00027   const unsigned int FrameTime=15;        //!< time between frames in the motion system (milliseconds)
00028   const unsigned int NumFrames=1;        //!< the number of frames per buffer (don't forget also double buffered)
00029   const unsigned int SoundBufferTime=32; //!< the number of milliseconds per sound buffer... I'm not sure if this can be changed
00030   
00031   //!@name Output Types Information
00032   const unsigned NumWheels      =  2;
00033   
00034   const unsigned JointsPerArm   =  0;
00035   const unsigned NumArms        =  0;
00036   const unsigned NumArmJoints   =  JointsPerArm*NumArms;
00037   
00038   const unsigned JointsPerLeg   =  0; //!< The number of joints per leg
00039   const unsigned NumLegs        =  0; //!< The number of legs
00040   const unsigned NumLegJoints   =  JointsPerLeg*NumLegs; //!< the TOTAL number of joints on ALL legs
00041   const unsigned NumHeadJoints  =  2; //!< The number of joints in the neck
00042   const unsigned NumTailJoints  =  0; //!< The number of joints assigned to the tail
00043   const unsigned NumMouthJoints =  0; //!< the number of joints that control the mouth
00044   const unsigned NumEarJoints   =  0; //!< The number of joints which control the ears (NOT per ear, is total)
00045   const unsigned NumButtons     =  0; //!< the number of buttons that are available, 2 head, 4 paws, 3 back, 1 underbelly see ERS7Info::ButtonOffset_t
00046   const unsigned NumSensors     =  5;  //!< the number of sensors available
00047   const unsigned NumLEDs        =  10; //!< The number of LEDs which can be controlled
00048   const unsigned NumFacePanelLEDs = 0; //!< The number of face panel LEDs
00049   
00050   const unsigned NumPIDJoints   = NumWheels + NumArmJoints + NumLegJoints+NumHeadJoints+NumTailJoints+NumMouthJoints; //!< The number of joints which use PID motion - everything except ears
00051   const unsigned NumOutputs     = NumPIDJoints + NumLEDs; //!< the total number of outputs
00052   const unsigned NumReferenceFrames = NumOutputs + 1 + NumArms + 1; //!< for the base, gripper (* NumArms), and camera reference frames
00053 
00054   // webcam ?
00055   const float CameraHorizFOV=56.9/180*M_PI; //!< horizontal field of view (radians)
00056   const float CameraVertFOV=45.2/180*M_PI; //!< vertical field of view (radians)
00057   const float CameraFOV=CameraHorizFOV; //!< should be set to maximum of #CameraHorizFOV or #CameraVertFOV
00058   const unsigned int CameraResolutionX=320; //!< the number of pixels available in the 'full' layer
00059   const unsigned int CameraResolutionY=240; //!< the number of pixels available in the 'full' layer
00060   //@}
00061 
00062 
00063   // *******************************
00064   //         OUTPUT OFFSETS
00065   // *******************************
00066 
00067   //!Corresponds to entries in ERS7Info::PrimitiveName, defined at the end of this file
00068   //!@name Output Offsets
00069 
00070   
00071   const unsigned PIDJointOffset = 0; //!< The beginning of the PID Joints
00072   const unsigned WheelOffset = PIDJointOffset;
00073   const unsigned HeadOffset  = WheelOffset+NumWheels;   //!< the offset of the beginning of the head joints, add TPROffset_t to get specific joint
00074 
00075   const unsigned LEDOffset   = PIDJointOffset + NumPIDJoints; //!< the offset of LEDs in WorldState::outputs and MotionCommand functions, see LedOffset_t for specific offsets
00076 
00077   const unsigned BaseFrameOffset   = NumOutputs; //!< Use with kinematics to refer to base reference frame
00078   const unsigned CameraFrameOffset = BaseFrameOffset + 1; //!< Use with kinematics to refer to camera reference frame
00079 
00080   //! The offsets of appendages with pan (heading), tilt (elevation), note that this should be added to HeadOffset, otherwise use HeadOffset_t (#HeadPanOffset and #HeadTiltOffset)
00081   enum TPROffset_t {
00082     PanOffset = 0,      //!< pan/heading (horizontal)
00083     TiltOffset, //!< tilt/elevation (vertical)
00084     NodOffset = TiltOffset //!< replicated tilt (could be left undefined instead...)
00085   };
00086   
00087   //! These are 'absolute' offsets for the neck joints, don't need to add to HeadOffset like TPROffset_t values do
00088   enum HeadOffset_t {
00089     HeadPanOffset = HeadOffset,      //!< pan/heading (horizontal)
00090     HeadTiltOffset, //!< tilt/elevation (vertical)
00091   };
00092   
00093   //! 'Absolute' offsets for each of the wheels
00094   enum WheelOffset_t {
00095     LWheelOffset=WheelOffset,
00096     RWheelOffset
00097   };
00098     
00099   //! The offsets of the individual LEDs -- except the qwerk board doesn't have any particularly symbolic LEDs, just use numeric values...
00100   /*! @hideinitializer */
00101   enum LEDOffset_t { };
00102   
00103   typedef unsigned int LEDBitMask_t; //!< So you can be clear when you're refering to a LED bitmask
00104   //! LEDs for the face panel (all FaceLEDPanelMask<<(0:NumFacePanelLEDs-1) entries)
00105   const LEDBitMask_t FaceLEDMask = 0;
00106   //! selects all of the leds
00107   const LEDBitMask_t AllLEDMask  = (LEDBitMask_t)~0;
00108   //@}
00109 
00110 
00111   // *******************************
00112   //          INPUT OFFSETS
00113   // *******************************
00114 
00115 
00116   //! The order in which inputs should be stored
00117   //!@name Input Offsets
00118 
00119   //! holds offsets to different buttons in WorldState::buttons[]
00120   /*! Should be a straight mapping to the ButtonSourceIDs
00121    *
00122    *  Note that the chest (power) button is not a normal button.  It kills
00123    *  power to the motors at a hardware level, and isn't sensed in the
00124    *  normal way.  If you want to know when it is pressed (and you are
00125    *  about to shut down) see PowerSrcID::PauseSID.
00126    *
00127    *  @see WorldState::buttons @see ButtonSourceID_t
00128    * @hideinitializer */
00129   enum ButtonOffset_t { };
00130 
00131   //! Provides a string name for each button
00132   const char* const buttonNames[NumButtons+1] = { NULL }; // non-empty array to avoid gcc 3.4.2 internal error
00133 
00134   //! holds offset to different sensor values in WorldState::sensors[]
00135   /*! @see WorldState::sensors[] */
00136   enum SensorOffset_t { BatteryVoltage };
00137 
00138   //! Provides a string name for each sensor
00139   const char* const sensorNames[NumSensors] = { 
00140     "BatteryVoltage",
00141     "analogInValues0",
00142     "analogInValues1",
00143     "analogInValues2",
00144     "analogInValues3"
00145   };
00146 
00147   //@}
00148 
00149 
00150   //! Names for each of the outputs
00151   const char* const outputNames[NumOutputs] = {
00152     "WHEEL:L",
00153     "WHEEL:R",
00154     "NECK:pan",
00155     "NECK:nod",
00156     "LED:00000",
00157     "LED:00001",
00158     "LED:00002",
00159     "LED:00003",
00160     "LED:00004",
00161     "LED:00005",
00162     "LED:00006",
00163     "LED:00007",
00164     "LED:00008",
00165     "LED:00009"
00166   };
00167   
00168   //! provides polymorphic robot capability detection/mapping
00169   class QBotPlusCapabilities : public Capabilities {
00170   public:
00171     //! constructor
00172     QBotPlusCapabilities()
00173     : Capabilities(TargetName,NumOutputs,outputNames,NumButtons,buttonNames,NumSensors,sensorNames,PIDJointOffset,NumPIDJoints,LEDOffset,NumLEDs)
00174     {
00175       // alias neck tilt to "nod"
00176       outputToIndex["NECK:tilt"]=HeadTiltOffset;
00177     }
00178   };
00179   //! allocation declared in RobotInfo.cc
00180   extern QBotPlusCapabilities capabilities;
00181   
00182   //! This table holds the default PID values for each joint.  see PIDMC
00183   const float DefaultPIDs[NumPIDJoints][3] = {
00184     {1,0,0},
00185     {1,0,0},
00186     {1,0,0},
00187     {1,0,0}
00188   };
00189   
00190   //!These values are our recommended maximum joint velocities, in rad/ms
00191   /*! a value <= 0 means infinite speed (e.g. LEDs)
00192    *  
00193    *  These limits are <b>not</b> enforced by the framework.  They are simply available for you to use as you see fit.
00194    *  HeadPointerMC and PostureMC are primary examples of included classes which do respect these values (although they can be overridden)
00195    *  
00196    *  These values were obtained from the administrators of the Sony OPEN-R BBS */
00197   const float MaxOutputSpeed[NumOutputs] = {
00198     1e-3, //Wheels: left, right
00199     1e-3,
00200     3.14e-3, // Neck: tilt, pan
00201     6.28e-3,
00202 
00203     0,0,0,0,0,0,0,0,0,0 // LED
00204   };
00205 
00206   #ifndef RAD
00207     //!Just a little macro for converting degrees to radians
00208   #define RAD(deg) (((deg) * M_PI ) / 180.0)
00209     //!a flag so we undef these after we're done - do you have a cleaner solution?
00210   #define __RI_RAD_FLAG
00211   #endif
00212   
00213   //! 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)
00214   const double outputRanges[NumOutputs][2] =
00215     {
00216       { -1 , 1 },
00217       { -1 , 1 },
00218       { RAD(-90) , RAD(90) },
00219       { RAD(-90) , RAD(90) },
00220 
00221       // LED
00222       {0,1}, {0,1}, {0,1}, {0,1}, {0,1},
00223       {0,1}, {0,1}, {0,1}, {0,1}, {0,1}
00224     };
00225 
00226   //! 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)
00227   /*! Same as #outputRanges, don't know actual values because they were never specified by Sony */
00228   const double mechanicalLimits[NumOutputs][2] =
00229     {
00230       { -1 , 1 },
00231       { -1 , 1 },
00232       { RAD(-90) , RAD(90) },
00233       { RAD(-90) , RAD(90) },
00234 
00235       // LED
00236       {0,1}, {0,1}, {0,1}, {0,1}, {0,1},
00237       {0,1}, {0,1}, {0,1}, {0,1}, {0,1}
00238     };
00239 
00240 #ifdef __RI_RAD_FLAG
00241 #undef RAD
00242 #undef __RI_RAD_FLAG
00243 #endif
00244 }
00245 
00246 #endif

Tekkotsu v4.0
Generated Thu Nov 22 00:54:55 2007 by Doxygen 1.5.4