Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

CalliopeUInfo.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_CalliopeUInfo_h
00003 #define INCLUDED_CalliopeUInfo_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_CALLIOPEU)
00012 #  define TGT_IS_KOBUKI
00013 #  define TGT_HAS_WHEELS 2
00014 #  define TGT_HAS_BUTTONS 15
00015 #  define TGT_HAS_LEDS 4
00016 #  define TGT_HAS_CAMERA 1
00017 #endif
00018 
00019 //! Contains information about the CalliopeU, such as number of joints, LEDs, etc.
00020 namespace CalliopeUInfo {
00021   
00022   // *******************************
00023   //       ROBOT CONFIGURATION
00024   // *******************************
00025 
00026   extern const char* const TargetName; //!< the name of the model, to be used for logging and remote GUIs
00027 
00028   const unsigned int FrameTime=30;        //!< time between frames in the motion system (milliseconds)
00029   const unsigned int NumFrames=1;        //!< the number of frames per buffer (don't forget also double buffered)
00030   const unsigned int SoundBufferTime=32; //!< the number of milliseconds per sound buffer... I'm not sure if this can be changed
00031   
00032   //!@name Output Types Information
00033   const unsigned NumWheels      =  2;
00034   
00035   const unsigned FingerJointsPerArm = 0;
00036   const unsigned JointsPerArm   =  0;
00037   const unsigned NumArms        =  0;
00038   const unsigned NumArmJoints   =  JointsPerArm*NumArms;
00039   
00040   const unsigned JointsPerLeg   =  0; //!< The number of joints per leg
00041   const unsigned NumLegs        =  0; //!< The number of legs
00042   const unsigned NumLegJoints   =  JointsPerLeg*NumLegs; //!< the TOTAL number of joints on ALL legs
00043   const unsigned NumHeadJoints  =  0; //!< The number of joints in the neck
00044   const unsigned NumTailJoints  =  0; //!< The number of joints assigned to the tail
00045   const unsigned NumMouthJoints =  0; //!< the number of joints that control the mouth
00046   const unsigned NumEarJoints   =  0; //!< The number of joints which control the ears (NOT per ear, is total)
00047   const unsigned NumButtons     =  11; //!< the number of buttons that are available
00048   const unsigned NumSensors     =  42;  //!< the number of sensors available
00049   const unsigned NumLEDs        =  4; //!< The number of LEDs which can be controlled
00050   const unsigned NumFacePanelLEDs = 0; //!< The number of face panel LEDs
00051   
00052   const unsigned NumPIDJoints   = NumWheels; //!< servo pins
00053   const unsigned NumOutputs     = NumPIDJoints + NumLEDs; //!< the total number of outputs
00054   const unsigned NumReferenceFrames = NumOutputs + 1 + NumArms + 1; //!< for the base, gripper (* NumArms), and Camera
00055 
00056   const float wheelBase = 230.0; //!< Kobuki wheel base in mm
00057   const float wheelRadius = 35.0; //!< Kobuki wheel radius in mm
00058   const float tickToRad = 0.002436916871363930187454f;
00059 
00060   using namespace Camera75DOF;
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   = HeadOffset+NumHeadJoints;
00076   
00077   const unsigned ModeOffset = LEDOffset + NumLEDs;
00078 
00079   const unsigned BaseFrameOffset   = NumOutputs; //!< Use with kinematics to refer to base reference frame
00080   const unsigned CameraFrameOffset = BaseFrameOffset + 1; //!< Use with kinematics to refer to camera reference frame
00081   
00082   //! The offsets of appendages with pan (heading), tilt (elevation), note that this should be added to HeadOffset, otherwise use HeadOffset_t (#HeadPanOffset and #HeadTiltOffset)
00083   enum TPROffset_t {
00084     PanOffset = 0,      //!< pan/heading (horizontal)
00085     TiltOffset, //!< tilt/elevation (vertical)
00086     NodOffset = TiltOffset //!< replicated tilt (could be left undefined instead...)
00087   };
00088   
00089   //! These are 'absolute' offsets for the neck joints, don't need to add to HeadOffset like TPROffset_t values do
00090   enum HeadOffset_t {
00091     HeadPanOffset = HeadOffset,      //!< pan/heading (horizontal)
00092     HeadTiltOffset, //!< tilt/elevation (vertical)
00093   };
00094 
00095   enum WheelOffset_t {
00096     SpeedOffset=WheelOffset,
00097     RadiusOffset
00098   };
00099   
00100   //! The offsets of the individual LEDs
00101   /*! @hideinitializer */
00102   enum LEDOffset_t {
00103     RedLED1Offset=LEDOffset, // PowerRed
00104     GreenLED1Offset, // PowerGreen
00105     RedLED2Offset, // Play
00106     GreenLED2Offset // Advance
00107   };
00108 
00109   const LEDOffset_t RedLEDOffset = RedLED1Offset;
00110   const LEDOffset_t YellowLEDOffset = RedLED2Offset;
00111   const LEDOffset_t GreenLEDOffset = GreenLED1Offset;
00112   const LEDOffset_t BlueLEDOffset = GreenLED2Offset; 
00113 
00114   typedef unsigned int LEDBitMask_t; //!< So you can be clear when you're refering to a LED bitmask
00115   
00116   const LEDBitMask_t RedLEDMask = 1<<(RedLED1Offset-LEDOffset); //!< mask corresponding to RedLEDOffset
00117   const LEDBitMask_t YellowLEDMask = 1<<(RedLED2Offset-LEDOffset); //!< mask corresponding to YellowLEDOffset
00118   const LEDBitMask_t GreenLEDMask = 1<<(GreenLED1Offset-LEDOffset); //!< mask corresponding to GreenLEDOffset
00119   const LEDBitMask_t BlueLEDMask = (1<<(GreenLED2Offset-LEDOffset)); //!< mask corresponding to BlueLEDOffset
00120   
00121 
00122 
00123   //! LEDs for the face panel (all FaceLEDPanelMask<<(0:NumFacePanelLEDs-1) entries)
00124   const LEDBitMask_t FaceLEDMask = 0;
00125   //! selects all of the leds
00126   const LEDBitMask_t AllLEDMask  = (LEDBitMask_t)~0;
00127   //@}
00128 
00129   //!Offset needed so that the centroid of the robot is correct related to the bounding box
00130   const fmat::Column<3> AgentBoundingBoxBaseFrameOffset = fmat::pack(0,0,0);
00131 
00132   //! Half of the length, width, and height of the robot without gadgets (E.G arms)
00133   const fmat::Column<3> AgentBoundingBoxHalfDims = fmat::pack(304.8/2, 304.8/2, 0);
00134 
00135   // *******************************
00136   //          INPUT OFFSETS
00137   // *******************************
00138 
00139 
00140   //! The order in which inputs should be stored
00141   //!@name Input Offsets
00142 
00143   //! holds offsets to different buttons in WorldState::buttons[]
00144   /*! Should be a straight mapping to the ButtonSourceIDs
00145    *
00146    *  @see WorldState::buttons
00147    * @hideinitializer */
00148   enum ButtonOffset_t {
00149     B0ButOffset, //!< 1 if play button is down
00150     B1ButOffset, //!< 1 if advance button is down
00151     B2ButOffset, //!< 1 if advance button is down
00152     DropLeftWheelButOffset, //!< 1 if left wheel detects dropoff
00153     DropRightWheelButOffset, //!< 1 if right wheel detects dropoff
00154     BumpLeftButOffset, //!< 1 if left bumper is pressed
00155     BumpRightButOffset, //!< 1 if right bumper is pressed
00156     BumpCenterButOffset, //!< 1 if center bumber is pressed
00157     CliffLeftButOffset,
00158     CliffRightButOffset,
00159     CliffCenterButOffset,
00160     //OvercurrentOffset, //!< 1 if the left wheel is drawing more than 1 amp
00161   };
00162 
00163   const ButtonOffset_t GreenButOffset = B0ButOffset;
00164   const ButtonOffset_t YellowButOffset = B1ButOffset;
00165   const ButtonOffset_t RedButOffset = B2ButOffset;
00166 
00167   //! Provides a string name for each button
00168   const char* const buttonNames[NumButtons+1] = { 
00169     "Button0", 
00170     "Button1",
00171     "Button2",
00172     "LeftWheelDrop", 
00173     "RightWheelDrop",
00174     "BumpLeft", 
00175     "BumpRight", 
00176     "BumpCenter",
00177     "CliffLeft",
00178     "CliffRight",
00179     "CliffCenter",
00180     NULL
00181   };
00182 
00183   //! holds offset to different sensor values in WorldState::sensors[]
00184   /*! @see WorldState::sensors[] */
00185   enum SensorOffset_t {
00186     //! Core Sensors
00187     //TimestampOffset,
00188     //CliffOffset,
00189     LeftEncoderOffset,
00190     RightEncoderOffset,
00191     LeftPwmOffset,
00192     RightPwmOffset,
00193     ChargerOffset,
00194     BatteryOffset,
00195     OverCurrentOffset,
00196 
00197     //! Dock IR
00198     Docking0Offset,
00199     Docking1Offset,
00200     Docking2Offset,
00201 
00202     //! Inertia
00203     AngleOffset,
00204     AngleRateOffset,
00205     Acc0Offset,
00206     Acc1Offset,
00207     Acc2Offset,
00208 
00209     //! Cliff
00210     Bottom0Offset,
00211     Bottom1Offset,
00212     Bottom2Offset,
00213 
00214     //! Current
00215     Current0Offset,
00216     Current1Offset,
00217 
00218     //! Three Axis Gyro
00219     FrameIdOffset,
00220     FollowedDataLenghtOffset,
00221     GyroParam0Offset,
00222     GyroParam1Offset,
00223     GyroParam2Offset,
00224     GyroParam3Offset,
00225     GyroParam4Offset,
00226     GyroParam5Offset,
00227     GyroParam6Offset,
00228     GyroParam7Offset,
00229     GyroParam8Offset,
00230 
00231     //! GpInput
00232     DigitalInputOffset,
00233     AnalogInput0Offset,
00234     AnalogInput1Offset,
00235     AnalogInput2Offset,
00236     AnalogInput3Offset,
00237     AnalogInput4Offset,
00238     AnalogInput5Offset,
00239     AnalogInput6Offset,
00240     //ModeStateOffset, //!< one of #ModeState_t
00241     GPSXOffset, //!< x-coordinate of robot from GPS or Mirage
00242     GPSYOffset, //!< y-coordinate of robot from GPS or Mirage
00243     GPSHeadingOffset, //!< heading of robot from GPS or Mirage
00244   };
00245 
00246   //! Provides a string name for each sensor
00247   const char* const sensorNames[NumSensors+1] = { 
00248     //! Core Sensors
00249     //"Timestamp",
00250     //"CliffOffset",
00251     "LeftEncoder",
00252     "RightEncoder",
00253     "LeftPwm",
00254     "RightPwm",
00255     "Charger",
00256     "Battery",
00257     "OverCurrent",
00258 
00259     //! Dock IR
00260     "Docking0",
00261     "Docking1",
00262     "Docking2",
00263 
00264     //! Inertia
00265     "Angle",
00266     "AngleRate",
00267     "Acc0",
00268     "Acc1",
00269     "Acc2",
00270 
00271     //! Cliff
00272     "CliffBottom0",
00273     "CliffBottom1",
00274     "CliffBottom2",
00275 
00276     //! Current
00277     "Current0",
00278     "Current2",
00279   
00280     //! Three Axis Gyro
00281     "FrameId",
00282     "FollowedDataLenght",
00283     "GyroParam0",
00284     "GyroParam1",
00285     "GyroParam2",
00286     "GyroParam3",
00287     "GyroParam4",
00288     "GyroParam5",
00289     "GyroParam6",
00290     "GyroParam7",
00291     "GyroParam8",
00292 
00293     //! Gp Input
00294     "DigitalInput0",
00295     "AnalogInput0",
00296     "AnalogInput1",
00297     "AnalogInput2",
00298     "AnalogInput3",
00299     "AnalogInput4",
00300     "AnalogInput5",
00301     "AnalogInput6",
00302     "GPSX",
00303     "GPSY",
00304     "GPSHeading",
00305     NULL
00306     
00307   };
00308 
00309   //@}
00310 
00311 
00312   //! Names for each of the outputs
00313   const char* const outputNames[NumReferenceFrames+1] = {
00314     "Speed",
00315     "Radius",
00316     "LED1:Red",
00317     "LED1:Green",
00318     "LED2:Red",
00319     "LED2:Green",
00320     "BaseFrame",
00321     "CameraFrame",
00322     NULL
00323   };
00324   
00325   //! provides polymorphic robot capability detection/mapping
00326   class CalliopeUCapabilities : public Capabilities {
00327   public:
00328     //! constructor
00329     CalliopeUCapabilities()
00330     : Capabilities(TargetName,NumReferenceFrames,outputNames,NumButtons,buttonNames,
00331              NumSensors,sensorNames,PIDJointOffset,NumPIDJoints,LEDOffset,NumLEDs,NumOutputs)
00332     {}
00333   };
00334   //! allocation declared in RobotInfo.cc
00335   extern const CalliopeUCapabilities capabilities;
00336   
00337   //! This table holds the default PID values for each joint.  see PIDMC
00338   const float DefaultPIDs[NumPIDJoints+1][3] = {
00339     {1,0,0},
00340     {1,0,0},
00341   };
00342   
00343   //!These values are our recommended maximum joint velocities, in rad/ms
00344   const float MaxOutputSpeed[NumOutputs] = {
00345     0, 0,  // wheels
00346     0, 0, 0, 0 // LEDs
00347   };
00348 
00349   #ifndef RAD
00350     //!Just a little macro for converting degrees to radians
00351   #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00352     //!a flag so we undef these after we're done - do you have a cleaner solution?
00353   #define __RI_RAD_FLAG
00354   #endif
00355   
00356   //! 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)
00357   const float outputRanges[NumOutputs][2] =
00358     {
00359       { -500 , 500 },
00360       { -500 , 500 },
00361       {  0 , 1 }, // leds
00362       {  0 , 1 },
00363       {  0 , 1 },
00364       {  0 , 1 }
00365     };
00366 
00367   //! 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)
00368   /*! Same as #outputRanges, don't know actual values because they were never specified by Sony */
00369   const float mechanicalLimits[NumOutputs][2] =
00370     {
00371       { -500 , 500 },
00372       { -500 , 500 },
00373       {  0 , 1 },  // leds
00374       {  0 , 1 },
00375       {  0 , 1 },
00376       {  0 , 1 },
00377     };
00378 
00379 #ifdef __RI_RAD_FLAG
00380 #undef RAD
00381 #undef __RI_RAD_FLAG
00382 #endif
00383 }
00384 
00385 /*! @file
00386  * @brief Defines some capabilities of the CalliopeU robot
00387  * @author ejt (Creator)
00388  */
00389 
00390 #endif

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