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_WEBCAM 1
00014 #  define TGT_HAS_CAMERA 1
00015 #  define TGT_HAS_WHEELS 2
00016 #  define TGT_HAS_LEDS 14
00017 #  define TGT_HAS_HEAD 1
00018 #  define TGT_HAS_BUTTONS 4
00019 #endif
00020 
00021 //! Declares configuration of the QwerkBot+, such as number of joints, LEDs, etc.
00022 namespace QBotPlusInfo {
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=25;        //!< 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      =  2;
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  =  2; //!< The number of movable joints in the neck
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     =  8; //!< the number of buttons. 4 analog + 4 digital
00049   const unsigned NumSensors     =  17; //!< the number of sensors available. (8 analog + 8 digital + 1 battery)
00050   const unsigned NumLEDs        =  14; //!< The number of LEDs which can be controlled
00051   const unsigned NumFacePanelLEDs = 0; //!< The number of face panel LEDs
00052 
00053   const unsigned NumPIDJoints   = NumWheels + NumArmJoints + NumLegJoints+NumHeadJoints+NumTailJoints+NumMouthJoints; //!< The number of joints which use PID motion - everything except ears
00054   const unsigned NumOutputs     = NumPIDJoints + NumLEDs; //!< the total number of outputs
00055   const unsigned NumReferenceFrames = NumOutputs + 1 + NumArms + 1; //!< for the base, gripper (* NumArms), and camera reference frames
00056 
00057   using namespace CameraSTX;
00058   //@}
00059 
00060 
00061   // *******************************
00062   //         OUTPUT OFFSETS
00063   // *******************************
00064 
00065   //!Corresponds to entries in ERS7Info::PrimitiveName, defined at the end of this file
00066   //!@name Output Offsets
00067 
00068   
00069   const unsigned PIDJointOffset = 0; //!< The beginning of the PID Joints
00070   const unsigned WheelOffset = PIDJointOffset;
00071   const unsigned HeadOffset  = WheelOffset+NumWheels;   //!< the offset of the beginning of the head joints, add TPROffset_t to get specific joint
00072 
00073   const unsigned LEDOffset   = PIDJointOffset + NumPIDJoints; //!< the offset of LEDs in WorldState::outputs and MotionCommand functions, see LedOffset_t for specific offsets
00074 
00075   const unsigned BaseFrameOffset   = NumOutputs; //!< Use with kinematics to refer to base reference frame
00076   const unsigned CameraFrameOffset = BaseFrameOffset + 1; //!< Use with kinematics to refer to camera reference frame
00077 
00078   //! The offsets of appendages with pan (heading), tilt (elevation), note that this should be added to HeadOffset, otherwise use HeadOffset_t (#HeadPanOffset and #HeadTiltOffset)
00079   enum TPROffset_t {
00080     PanOffset = 0,      //!< pan/heading (horizontal)
00081     TiltOffset, //!< tilt/elevation (vertical)
00082     NodOffset = TiltOffset //!< replicated tilt (could be left undefined instead...)
00083   };
00084   
00085   //! These are 'absolute' offsets for the neck joints, don't need to add to HeadOffset like TPROffset_t values do
00086   enum HeadOffset_t {
00087     HeadPanOffset = HeadOffset,      //!< pan/heading (horizontal)
00088     HeadTiltOffset, //!< tilt/elevation (vertical)
00089   };
00090   
00091   //! 'Absolute' offsets for each of the wheels
00092   enum WheelOffset_t {
00093     LWheelOffset=WheelOffset,
00094     RWheelOffset
00095   };
00096     
00097   //! The offsets of the individual LEDs -- except the qwerk board doesn't have any particularly symbolic LEDs, just use numeric values...
00098   /*! @hideinitializer */
00099   enum LEDOffset_t { };
00100   
00101   typedef unsigned int LEDBitMask_t; //!< So you can be clear when you're refering to a LED bitmask
00102   //! LEDs for the face panel (all FaceLEDPanelMask<<(0:NumFacePanelLEDs-1) entries)
00103   const LEDBitMask_t FaceLEDMask = 0;
00104   //! selects all of the leds
00105   const LEDBitMask_t AllLEDMask  = (LEDBitMask_t)~0;
00106   //@}
00107 
00108 
00109   // *******************************
00110   //          INPUT OFFSETS
00111   // *******************************
00112 
00113 
00114   //! The order in which inputs should be stored
00115   //!@name Input Offsets
00116 
00117   //! holds offsets to different buttons in WorldState::buttons[]
00118   /*! Should be a straight mapping to the ButtonSourceIDs
00119    *
00120    *  Note that the chest (power) button is not a normal button.  It kills
00121    *  power to the motors at a hardware level, and isn't sensed in the
00122    *  normal way.  If you want to know when it is pressed (and you are
00123    *  about to shut down) see PowerSrcID::PauseSID.
00124    *
00125    *  @see WorldState::buttons @see ButtonSourceID_t
00126    * @hideinitializer */
00127   enum ButtonOffset_t { Button0, Button1, Button2, Button3,
00128                         Button4, Button5, Button6, Button7 };
00129 
00130   //! Provides a string name for each button
00131   const char* const buttonNames[NumButtons+1] = 
00132     { "Button0", "Button1", "Button2", "Button3", 
00133       "Button4", "Button5", "Button6", "Button7", 
00134       NULL }; // non-empty array to avoid gcc 3.4.2 internal error
00135 
00136   //! holds offset to different sensor values in WorldState::sensors[]
00137   /*! @see WorldState::sensors[] */
00138   enum SensorOffset_t { AnalogInValues0, AnalogInValues1, 
00139                         AnalogInValues2, AnalogInValues3, 
00140                         AnalogInValues4, AnalogInValues5, 
00141                         AnalogInValues6, AnalogInValues7, 
00142                         DigitalInStates0, DigitalInStates1, 
00143                         DigitalInStates2, DigitalInStates3, 
00144                         DigitalInStates4, DigitalInStates5, 
00145                         DigitalInStates6, DigitalInStates7, 
00146                         BatteryVoltage };
00147 
00148   //! Provides a string name for each sensor
00149   const char* const sensorNames[NumSensors] = { 
00150     "analogInValues0",
00151     "analogInValues1",
00152     "analogInValues2",
00153     "analogInValues3",
00154     "analogInValues4",
00155     "analogInValues5",
00156     "analogInValues6",
00157     "analogInValues7",
00158     "digitalInStates0",
00159     "digitalInStates1",
00160     "digitalInStates2",
00161     "digitalInStates3",
00162     "digitalInStates4",
00163     "digitalInStates5",
00164     "digitalInStates6",
00165     "digitalInStates7",
00166     "BatteryVoltage"
00167   };
00168 
00169   //@}
00170 
00171 
00172   //! Names for each of the outputs
00173   const char* const outputNames[NumReferenceFrames+1] = {
00174     "WHEEL:L",
00175     "WHEEL:R",
00176     "NECK:pan",
00177     "NECK:tilt",
00178     "LED:00000",
00179     "LED:00001",
00180     "LED:00002",
00181     "LED:00003",
00182     "LED:00004",
00183     "LED:00005",
00184     "LED:00006",
00185     "LED:00007",
00186     "LED:00008",
00187     "LED:00009",
00188     "LED:00010", // digital outputs used for extra LEDs...
00189     "LED:00011",
00190     "LED:00012",
00191     "LED:00013",
00192     
00193     "BaseFrame",
00194     "CameraFrame",
00195     NULL
00196   };
00197   
00198   //! provides polymorphic robot capability detection/mapping
00199   class QBotPlusCapabilities : public Capabilities {
00200   public:
00201     //! constructor
00202     QBotPlusCapabilities()
00203     : Capabilities(TargetName,NumReferenceFrames,outputNames,NumButtons,buttonNames,NumSensors,sensorNames,PIDJointOffset,NumPIDJoints,LEDOffset,NumLEDs,NumOutputs)
00204     {
00205       // aliases from generic to semantic values (e.g. to run generic TGT_QWERK code...)
00206       frameToIndex["WHEEL:000"]=LWheelOffset;
00207       frameToIndex["WHEEL:001"]=RWheelOffset;
00208       frameToIndex["SERVO:000"]=HeadPanOffset;
00209       frameToIndex["SERVO:001"]=HeadTiltOffset;
00210       // alias neck nod to "tilt"
00211       frameToIndex["NECK:nod"]=HeadTiltOffset;
00212     }
00213   };
00214   //! allocation declared in RobotInfo.cc
00215   extern const QBotPlusCapabilities capabilities;
00216   
00217   //! This table holds the default PID values for each joint.  see PIDMC
00218   const float DefaultPIDs[NumPIDJoints][3] = {
00219     {1,0,0},
00220     {1,0,0},
00221     {1,0,0},
00222     {1,0,0}
00223   };
00224   
00225   //!These values are our recommended maximum joint velocities, in rad/sec
00226   /*! a value <= 0 means infinite speed (e.g. LEDs)
00227    *  
00228    *  These limits are <b>not</b> enforced by the framework.  They are simply available for you to use as you see fit.
00229    *  HeadPointerMC and PostureMC are primary examples of included classes which do respect these values (although they can be overridden)
00230    *  
00231    *  These values were obtained from the administrators of the Sony OPEN-R BBS */
00232   const float MaxOutputSpeed[NumOutputs] = {
00233     1.f, //Wheels: left, right
00234     1.f,
00235     6.28f, // Neck: pan, tilt
00236     3.14f,
00237 
00238     0,0,0,0,0,0,0,0,0,0 // LED
00239   };
00240 
00241   #ifndef RAD
00242     //!Just a little macro for converting degrees to radians
00243   #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00244     //!a flag so we undef these after we're done - do you have a cleaner solution?
00245   #define __RI_RAD_FLAG
00246   #endif
00247   
00248   //! 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)
00249   const float outputRanges[NumOutputs][2] =
00250     {
00251       { -1 , 1 },
00252       { -1 , 1 },
00253       { RAD(-90) , RAD(90) },
00254       { RAD(-90) , RAD(90) },
00255 
00256       // LED
00257       {0,1}, {0,1}, {0,1}, {0,1}, {0,1},
00258       {0,1}, {0,1}, {0,1}, {0,1}, {0,1},
00259       {0,1}, {0,1}, {0,1}, {0,1}
00260     };
00261 
00262   //! 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)
00263   /*! Same as #outputRanges, don't know actual values because they were never specified by Sony */
00264   const float mechanicalLimits[NumOutputs][2] =
00265     {
00266       { -1 , 1 },
00267       { -1 , 1 },
00268       { RAD(-90) , RAD(90) },
00269       { RAD(-90) , RAD(90) },
00270 
00271       // LED
00272       {0,1}, {0,1}, {0,1}, {0,1}, {0,1},
00273       {0,1}, {0,1}, {0,1}, {0,1}, {0,1},
00274       {0,1}, {0,1}, {0,1}, {0,1}
00275     };
00276 
00277 #ifdef __RI_RAD_FLAG
00278 #undef RAD
00279 #undef __RI_RAD_FLAG
00280 #endif
00281 }
00282 
00283 /*! @file
00284  * @brief Defines some capabilities of the QwerkBot+, a QwerkBot with wheels and a pan/tilt camera
00285  * @author ejt (Creator)
00286  */
00287 
00288 #endif

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