Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

CreateInfo.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_CreateInfo_h
00003 #define INCLUDED_CreateInfo_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_CREATE)
00012 #  define TGT_IS_CREATE
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 an iRobot Create, such as number of joints, LEDs, etc.
00020 namespace CreateInfo {
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=15;        //!< 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     =  15; //!< the number of buttons that are available
00048   const unsigned NumSensors     =  22;  //!< 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 + 1; //!< the total number of outputs
00054   const unsigned NumReferenceFrames = NumOutputs + 1 + NumArms + 1; //!< for the base, gripper (* NumArms), and Camera
00055 
00056   
00057 
00058   using namespace CameraGeneric60;
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   = HeadOffset+NumHeadJoints;
00074   
00075   const unsigned ModeOffset = LEDOffset + NumLEDs;
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   enum WheelOffset_t {
00094     LWheelOffset=WheelOffset,
00095     RWheelOffset
00096   };
00097   
00098   //! The offsets of the individual LEDs
00099   /*! @hideinitializer */
00100   enum LEDOffset_t {
00101     PowerRedLEDOffset=LEDOffset,
00102     PowerGreenLEDOffset,
00103     PlayLEDOffset,
00104     AdvanceLEDOffset
00105   };
00106 
00107   const LEDOffset_t RedLEDOffset = PowerRedLEDOffset;
00108   const LEDOffset_t BlueLEDOffset = AdvanceLEDOffset; //!< Create has no blue LED: use Advance LED here, and Advance+PowerRED in BlueLEDMask
00109   const LEDOffset_t GreenLEDOffset = PlayLEDOffset;
00110   const LEDOffset_t YellowLEDOffset = AdvanceLEDOffset;
00111 
00112   typedef unsigned int LEDBitMask_t; //!< So you can be clear when you're refering to a LED bitmask
00113 
00114   const LEDBitMask_t BlueLEDMask = (1<<(AdvanceLEDOffset-LEDOffset)) |
00115            (1<<(PowerRedLEDOffset-LEDOffset)); //!< Create has no blue LED, so use Advance (green) + Power (red)
00116   const LEDBitMask_t GreenLEDMask = 1<<(GreenLEDOffset-LEDOffset); //!< mask corresponding to GreenLEDOffset
00117   const LEDBitMask_t YellowLEDMask = 1<<(YellowLEDOffset-LEDOffset); //!< mask corresponding to YellowLEDOffset
00118   const LEDBitMask_t RedLEDMask = 1<<(RedLEDOffset-LEDOffset); //!< mask corresponding to RedLEDOffset
00119 
00120   const LEDBitMask_t PowerRedLEDMask = 1<<(PowerRedLEDOffset-LEDOffset); //!< mask corresponding to BlueLEDOffset
00121   const LEDBitMask_t PowerGreenLEDMask = 1<<(PowerGreenLEDOffset-LEDOffset); //!< mask corresponding to GreenLEDOffset
00122   const LEDBitMask_t PlayLEDMask = 1<<(PlayLEDOffset-LEDOffset); //!< mask corresponding to YellowLEDOffset
00123   const LEDBitMask_t AdvanceLEDMask = 1<<(AdvanceLEDOffset-LEDOffset); //!< mask corresponding to RedLEDOffset
00124 
00125   //! LEDs for the face panel (all FaceLEDPanelMask<<(0:NumFacePanelLEDs-1) entries)
00126   const LEDBitMask_t FaceLEDMask = 0;
00127   //! selects all of the leds
00128   const LEDBitMask_t AllLEDMask  = (LEDBitMask_t)~0;
00129   //@}
00130 
00131   //!Offset needed so that the centroid of the robot is correct related to the bounding box
00132   const fmat::Column<3> AgentBoundingBoxBaseFrameOffset = fmat::pack(0,0,0);
00133 
00134   //! Half of the length, width, and height of the robot without gadgets (E.G arms)
00135   const fmat::Column<3> AgentBoundingBoxHalfDims = fmat::pack(304.8/2, 304.8/2, 0);
00136 
00137   // *******************************
00138   //          INPUT OFFSETS
00139   // *******************************
00140 
00141 
00142   //! The order in which inputs should be stored
00143   //!@name Input Offsets
00144 
00145   //! holds offsets to different buttons in WorldState::buttons[]
00146   /*! Should be a straight mapping to the ButtonSourceIDs
00147    *
00148    *  @see WorldState::buttons
00149    * @hideinitializer */
00150   enum ButtonOffset_t {
00151     PlayButOffset, //!< 1 if play button is down
00152     AdvanceButOffset, //!< 1 if advance button is down
00153     WallButOffset, //!< 1 if wall is detected (note correspondence to WALL_SIGNAL_OFFSET's value, avoiding problems if the two are swapped)
00154     DropCasterButOffset, //!< 1 if caster detects dropoff
00155     DropLeftWheelButOffset, //!< 1 if left wheel detects dropoff
00156     DropRightWheelButOffset, //!< 1 if right wheel detects dropoff
00157     BumpLeftButOffset, //!< 1 if left bumper is pressed
00158     BumpRightButOffset, //!< 1 if right bumper is pressed
00159     OvercurrentLeftWheelOffset, //!< 1 if the left wheel is drawing more than 1 amp
00160     OvercurrentRightWheelOffset, //!< 1 if the right wheel is drawing more than 1 amp
00161     LowSideDriver0ButOffset, //!< 1 if low side driver 0 is pulling more than 0.5 amps
00162     LowSideDriver1ButOffset, //!< 1 if low side driver 1 is pulling more than 0.5 amps
00163     LowSideDriver2ButOffset, //!< 1 if low side driver 2 is pulling more than 1.6 amps
00164     BaseChargerButOffset, //!< 1 if the home base charger is available
00165     InternalChargerButOffset //!< 1 if the internal charger is available
00166   };
00167 
00168   const ButtonOffset_t GreenButOffset = PlayButOffset;
00169   const ButtonOffset_t YellowButOffset = AdvanceButOffset;
00170   const ButtonOffset_t RedButOffset = PlayButOffset;
00171 
00172   //! Provides a string name for each button
00173   const char* const buttonNames[NumButtons+1] = { 
00174     "Play", "Advance",
00175     "Wall",
00176     "CasterDrop", "LWheelDrop", "RWheelDrop",
00177     "LBump", "RBump",
00178     "LOverCurrent", "ROverCurrent",
00179     "DriverLow0", "DriverLow1", "DriverLow2",
00180     "BaseCharger", "InternalCharger",
00181     NULL
00182   };
00183 
00184   //! holds offset to different sensor values in WorldState::sensors[]
00185   /*! @see WorldState::sensors[] */
00186   enum SensorOffset_t {
00187     DigitalInput0Offset, //!< the digital input pins in bits 0 through 4
00188     DigitalInput1Offset, //!< the digital input pins in bits 0 through 4
00189     DigitalInput2Offset, //!< the digital input pins in bits 0 through 4
00190     DigitalInput3Offset, //!< the digital input pins in bits 0 through 4
00191     AnalogSignalOffset, //!< voltage on cargo bay pin 4
00192     WallSignalOffset, //!< strength of the wall sensor's signal (note correspondence to WALL_OFFSET's value, avoid problems if the two are swapped)
00193     IRCommOffset, //!< value received by the infrared communication receiver, see IRComm_t for values sent by standard hardware
00194     CliffLeftSignalOffset, //!< strength of the left cliff sensor
00195     CliffFrontLeftSignalOffset, //!< strength of the front left cliff sensor
00196     CliffFrontRightSignalOffset, //!< strength of the front right cliff sensor
00197     CliffRightSignalOffset, //!< strength of the right cliff sensor
00198     EncoderDistanceOffset, //!< average distance (mm) traveled by the wheels since last update
00199     EncoderAngleOffset, //!< average angle (radians) rotated since the last update
00200     VoltageOffset, //!< mV measured at battery
00201     CurrentOffset, //!< mA flowing into battery (negative when discharging)
00202     BatteryChargeOffset, //!< mAh remaining in battery (may not be accurate with alkaline battery pack)
00203     BatteryTempOffset, //!< degrees celsius
00204     ChargingStateOffset, //!< one of #ChargingState_t
00205     ModeStateOffset, //!< one of #ModeState_t
00206     GPSXOffset, //!< x-coordinate of robot from GPS or Mirage
00207     GPSYOffset, //!< y-coordinate of robot from GPS or Mirage
00208     GPSHeadingOffset, //!< heading of robot from GPS or Mirage
00209   };
00210   
00211   enum IRComm_t {
00212     IR_REMOTE_LEFT=129,
00213     IR_REMOTE_FORWARD,
00214     IR_REMOTE_RIGHT,
00215     IR_REMOTE_SPOT,
00216     IR_REMOTE_MAX,
00217     IR_REMOTE_SMALL,
00218     IR_REMOTE_MEDIUM,
00219     IR_REMOTE_LARGE,
00220     IR_REMOTE_PAUSE,
00221     IR_REMOTE_POWER,
00222     IR_REMOTE_ARC_LEFT, 
00223     IR_REMOTE_ARC_RIGHT,
00224     IR_REMOTE_STOP,
00225     IR_REMOTE_SEND,
00226     IR_REMOTE_DOCK,
00227     IR_BASE_RED=248,
00228     IR_BASE_GREEN=244,
00229     IR_BASE_FORCE=242,
00230     IR_BASE_RED_GREEN=252,
00231     IR_BASE_RED_FORCE=250,
00232     IR_BASE_GREEN_FORCE=246,
00233     IR_BASE_RED_GREEN_FORCE=254
00234   };
00235   /*const unsigned IR_BASE_MASK=240;
00236   const unsigned IR_BASE_RED_MASK=8;
00237   const unsigned IR_BASE_GREEN_MASK=4;
00238   const unsigned IR_BASE_FORCE_MASK=2;*/
00239   
00240   enum ChargingState_t {
00241     CHARGING_OFF,
00242     CHARGING_RECONDITIONING,
00243     CHARGING_FULL,
00244     CHARGING_TRICKLE,
00245     CHARGING_WAITING,
00246     CHARGING_FAULT
00247   };
00248 
00249   enum ModeState_t {
00250     MODE_OFF,
00251     MODE_PASSIVE,
00252     MODE_SAFE,
00253     MODE_FULL
00254   };
00255     
00256   //! Provides a string name for each sensor
00257   const char* const sensorNames[NumSensors+1] = { 
00258     "DigitalIn0",
00259     "DigitalIn1",
00260     "DigitalIn2",
00261     "DigitalIn3",
00262     "AnalogIn",
00263     "WallSignal",
00264     "IR",
00265     "CliffLeftSignal",
00266     "CliffFrontLeftSignal",
00267     "CliffFrontRightSignal",
00268     "CliffRight",
00269     "Distance",
00270     "Angle",
00271     "BatteryVoltage",
00272     "BatteryCurrent",
00273     "BatteryCharge",
00274     "BatteryTemp",
00275     "ChargingState",
00276     "ModeState",
00277     "GPSX",
00278     "GPSY",
00279     "GPSHeading",
00280     NULL
00281   };
00282 
00283   //@}
00284 
00285 
00286   //! Names for each of the outputs
00287   const char* const outputNames[NumReferenceFrames+1] = {
00288     "WHEEL:L",
00289     "WHEEL:R",
00290     "LED:Power(Red)",
00291     "LED:Power(Green)",
00292     "LED:Play",
00293     "LED:Advance",
00294     "DesiredMode",
00295     "BaseFrame",
00296     "CameraFrame",
00297     NULL
00298   };
00299   
00300   //! allocation declared in RobotInfo.cc
00301   extern const Capabilities capabilities;
00302   
00303   //! This table holds the default PID values for each joint.  see PIDMC
00304   const float DefaultPIDs[NumPIDJoints+1][3] = {
00305     {1,0,0},
00306     {1,0,0}
00307   };
00308   
00309   //!These values are our recommended maximum joint velocities, in rad/ms
00310   const float MaxOutputSpeed[NumOutputs] = {
00311     0,
00312     0,
00313     0,
00314     0,
00315     0,
00316     0,
00317     0
00318   };
00319 
00320   #ifndef RAD
00321     //!Just a little macro for converting degrees to radians
00322   #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00323     //!a flag so we undef these after we're done - do you have a cleaner solution?
00324   #define __RI_RAD_FLAG
00325   #endif
00326   
00327   //! 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)
00328   const float outputRanges[NumOutputs][2] =
00329     {
00330       { -500 , 500 },
00331       { -500 , 500 },
00332       {  0 , 1 },
00333       {  0 , 1 },
00334       {  0 , 1 },
00335       {  0 , 1 },
00336       { MODE_PASSIVE, MODE_SAFE }
00337     };
00338 
00339   //! 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)
00340   /*! Same as #outputRanges, don't know actual values because they were never specified by Sony */
00341   const float mechanicalLimits[NumOutputs][2] =
00342     {
00343       { -500 , 500 },
00344       { -500 , 500 },
00345       {  0 , 1 },
00346       {  0 , 1 },
00347       {  0 , 1 },
00348       {  0 , 1 },
00349       { MODE_PASSIVE, MODE_SAFE }
00350     };
00351 
00352 #ifdef __RI_RAD_FLAG
00353 #undef RAD
00354 #undef __RI_RAD_FLAG
00355 #endif
00356 }
00357 
00358 /*! @file
00359  * @brief Defines some capabilities of the iRobot Create robots
00360  * @author ejt (Creator)
00361  */
00362 
00363 #endif

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