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_HAS_WHEELS 2
00013 #  define TGT_HAS_LEDS 2
00014 #endif
00015 
00016 //! Contains information about an iRobot Create, such as number of joints, timing information, etc.
00017 namespace CreateInfo {
00018   
00019   // *******************************
00020   //       ROBOT CONFIGURATION
00021   // *******************************
00022 
00023   extern const char* const TargetName; //!< the name of the model, to be used for logging and remote GUIs
00024 
00025   const unsigned int FrameTime=15;        //!< time between frames in the motion system (milliseconds)
00026   const unsigned int NumFrames=1;        //!< the number of frames per buffer (don't forget also double buffered)
00027   const unsigned int SoundBufferTime=32; //!< the number of milliseconds per sound buffer... I'm not sure if this can be changed
00028   
00029   //!@name Output Types Information
00030   const unsigned NumWheels      =  2;
00031   
00032   const unsigned JointsPerArm   =  0;
00033   const unsigned NumArms        =  0;
00034   const unsigned NumArmJoints   =  JointsPerArm*NumArms;
00035   
00036   const unsigned JointsPerLeg   =  0; //!< The number of joints per leg
00037   const unsigned NumLegs        =  0; //!< The number of legs
00038   const unsigned NumLegJoints   =  JointsPerLeg*NumLegs; //!< the TOTAL number of joints on ALL legs
00039   const unsigned NumHeadJoints  =  0; //!< The number of joints in the neck
00040   const unsigned NumTailJoints  =  0; //!< The number of joints assigned to the tail
00041   const unsigned NumMouthJoints =  0; //!< the number of joints that control the mouth
00042   const unsigned NumEarJoints   =  0; //!< The number of joints which control the ears (NOT per ear, is total)
00043   const unsigned NumButtons     =  0; //!< the number of buttons that are available, 2 head, 4 paws, 3 back, 1 underbelly see ERS7Info::ButtonOffset_t
00044   const unsigned NumSensors     =  18;  //!< the number of sensors available
00045   const unsigned NumLEDs        =  2; //!< The number of LEDs which can be controlled
00046   const unsigned NumFacePanelLEDs = 0; //!< The number of face panel LEDs
00047   
00048   const unsigned NumPIDJoints   = 0; //!< servo pins
00049   const unsigned NumOutputs     = NumWheels + NumLEDs; //!< the total number of outputs
00050   const unsigned NumReferenceFrames = NumOutputs + 1 + NumArms + 1; //!< for the base, gripper (* NumArms), and camera reference frames
00051 
00052   // webcam ?
00053   const float CameraHorizFOV=56.9/180*M_PI; //!< horizontal field of view (radians)
00054   const float CameraVertFOV=45.2/180*M_PI; //!< vertical field of view (radians)
00055   const float CameraFOV=CameraHorizFOV; //!< should be set to maximum of #CameraHorizFOV or #CameraVertFOV
00056   const unsigned int CameraResolutionX=320; //!< the number of pixels available in the 'full' layer
00057   const unsigned int CameraResolutionY=240; //!< the number of pixels available in the 'full' layer
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 
00072   const unsigned LEDOffset   = PIDJointOffset + NumPIDJoints; //!< the offset of LEDs in WorldState::outputs and MotionCommand functions, see LedOffset_t for specific offsets
00073   
00074   const unsigned MODE_OFFSET = LEDOffset + NumLEDs;
00075   const unsigned DEMO_OFFSET = MODE_OFFSET+1;
00076 
00077   const unsigned BaseFrameOffset   = NumOutputs; //!< Use with kinematics to refer to base reference frame
00078 
00079   enum WheelOffset_t {
00080     LWheelOffset=WheelOffset,
00081     RWheelOffset
00082   };
00083   
00084   //! The offsets of the individual LEDs on the head and tail.  Note that left/right are robot's point of view.  See also LEDBitMask_t
00085   /*! @hideinitializer */
00086   enum LEDOffset_t {
00087   };
00088   
00089   typedef unsigned int LEDBitMask_t; //!< So you can be clear when you're refering to a LED bitmask
00090   //! LEDs for the face panel (all FaceLEDPanelMask<<(0:NumFacePanelLEDs-1) entries)
00091   const LEDBitMask_t FaceLEDMask = 0;
00092   //! selects all of the leds
00093   const LEDBitMask_t AllLEDMask  = (LEDBitMask_t)~0;
00094   //@}
00095 
00096   enum InterfaceMode_t {
00097     MODE_SAFE,
00098     MODE_FULL,
00099     MODE_PASSIVE,
00100     MODE_OFF,
00101   };
00102 
00103   // *******************************
00104   //          INPUT OFFSETS
00105   // *******************************
00106 
00107 
00108   //! The order in which inputs should be stored
00109   //!@name Input Offsets
00110 
00111   //! holds offsets to different buttons in WorldState::buttons[]
00112   /*! Should be a straight mapping to the ButtonSourceIDs
00113    *
00114    *  @see WorldState::buttons
00115    * @hideinitializer */
00116   enum ButtonOffset_t {
00117     PLAY_OFFSET, //!< 1 if play button is down
00118     ADVANCE_OFFSET, //!< 1 if advance button is down
00119     WALL_OFFSET, //!< 1 if wall is detected (note correspondence to WALL_SIGNAL_OFFSET's value, avoiding problems if the two are swapped)
00120     DROP_CASTER_OFFSET, //!< 1 if caster detects dropoff
00121     DROP_LEFT_WHEEL_OFFSET, //!< 1 if left wheel detects dropoff
00122     DROP_RIGHT_WHEEL_OFFSET, //!< 1 if right wheel detects dropoff
00123     BUMP_LEFT_OFFSET, //!< 1 if left bumper is pressed
00124     BUMP_RIGHT_OFFSET, //!< 1 if right bumper is pressed
00125     OVERCURRENT_LEFT_WHEEL_OFFSET, //!< 1 if the left wheel is drawing more than 1 amp
00126     OVERCURRENT_RIGHT_WHEEL_OFFSET, //!< 1 if the right wheel is drawing more than 1 amp
00127     LOW_SIDE_DRIVER_0_OFFSET, //!< 1 if low side driver 0 is pulling more than 0.5 amps
00128     LOW_SIDE_DRIVER_1_OFFSET, //!< 1 if low side driver 1 is pulling more than 0.5 amps
00129     LOW_SIDE_DRIVER_2_OFFSET, //!< 1 if low side driver 2 is pulling more than 1.6 amps
00130     BASE_CHARGER_OFFSET, //!< 1 if the home base charger is available
00131     INTERNAL_CHARGER_OFFSET //!< 1 if the internal charger is available
00132   };
00133 
00134   //! Provides a string name for each button
00135   const char* const buttonNames[NumButtons+1] = { NULL }; // non-empty array to avoid gcc 3.4.2 internal error
00136 
00137   //! holds offset to different sensor values in WorldState::sensors[]
00138   /*! @see WorldState::sensors[] */
00139   enum SensorOffset_t { 
00140     DIGITAL0_INPUTS_OFFSET, //!< the digital input pins in bits 0 through 4
00141     DIGITAL1_INPUTS_OFFSET, //!< the digital input pins in bits 0 through 4
00142     DIGITAL2_INPUTS_OFFSET, //!< the digital input pins in bits 0 through 4
00143     DIGITAL3_INPUTS_OFFSET, //!< the digital input pins in bits 0 through 4
00144     ANALOG_SIGNAL_OFFSET, //!< voltage on cargo bay pin 4
00145     WALL_SIGNAL_OFFSET, //!< strength of the wall sensor's signal (note correspondence to WALL_OFFSET's value, avoid problems if the two are swapped)
00146     IR_COMM_OFFSET, //!< value received by the infrared communication receiver, see IRComm_t for values sent by standard hardware
00147     CLIFF_LEFT_SIGNAL_OFFSET, //!< strength of the left cliff sensor
00148     CLIFF_FRONT_LEFT_SIGNAL_OFFSET, //!< strength of the front left cliff sensor
00149     CLIFF_FRONT_RIGHT_SIGNAL_OFFSET, //!< strength of the front right cliff sensor
00150     CLIFF_RIGHT_SIGNAL_OFFSET, //!< strength of the right cliff sensor
00151     ENCODER_DISTANCE_OFFSET, //!< average distance (mm) traveled by the wheels since last update
00152     ENCODER_ANGLE_OFFSET, //!< average angle (radians) rotated since the last update
00153     VOLTAGE_OFFSET, //!< mV measured at battery
00154     CURRENT_OFFSET, //!< mA flowing into battery (negative when discharging)
00155     BATTERY_CHARGE_OFFSET, //!< mAh remaining in battery (may not be accurate with alkaline battery pack)
00156     BATTERY_TEMP_OFFSET, //!< degrees celsius
00157     CHARGING_STATE_OFFSET //!< one of #ChargingState_t
00158   };
00159   
00160   enum IRComm_t {
00161     IR_REMOTE_LEFT=129,
00162     IR_REMOTE_FORWARD,
00163     IR_REMOTE_RIGHT,
00164     IR_REMOTE_SPOT,
00165     IR_REMOTE_MAX,
00166     IR_REMOTE_SMALL,
00167     IR_REMOTE_MEDIUM,
00168     IR_REMOTE_LARGE,
00169     IR_REMOTE_PAUSE,
00170     IR_REMOTE_POWER,
00171     IR_REMOTE_ARC_LEFT, 
00172     IR_REMOTE_ARC_RIGHT,
00173     IR_REMOTE_STOP,
00174     IR_REMOTE_SEND,
00175     IR_REMOTE_DOCK,
00176     IR_BASE_RED=248,
00177     IR_BASE_GREEN=244,
00178     IR_BASE_FORCE=242,
00179     IR_BASE_RED_GREEN=252,
00180     IR_BASE_RED_FORCE=250,
00181     IR_BASE_GREEN_FORCE=246,
00182     IR_BASE_RED_GREEN_FORCE=254
00183   };
00184   /*const unsigned IR_BASE_MASK=240;
00185   const unsigned IR_BASE_RED_MASK=8;
00186   const unsigned IR_BASE_GREEN_MASK=4;
00187   const unsigned IR_BASE_FORCE_MASK=2;*/
00188   
00189   enum ChargingState_t {
00190     CHARGING_OFF,
00191     CHARGING_RECONDITIONING,
00192     CHARGING_FULL,
00193     CHARGING_TRICKLE,
00194     CHARGING_WAITING,
00195     CHARGING_FAULT
00196   };
00197     
00198   //! Provides a string name for each sensor
00199   const char* const sensorNames[NumSensors] = { 
00200     "DigitalIn0",
00201     "DigitalIn1",
00202     "DigitalIn2",
00203     "DigitalIn3",
00204     "AnalogIn",
00205     "WallSignal",
00206     "IR",
00207     "CliffLeftSignal",
00208     "CliffFrontLeftSignal",
00209     "CliffFrontRightSignal",
00210     "CliffRight",
00211     "Distance",
00212     "Angle",
00213     "BatteryVoltage",
00214     "BatteryCurrent",
00215     "BatteryCharge",
00216     "BatteryTemp",
00217     "ChargingState",
00218   }; // non-empty array to avoid gcc 3.4.2 internal error
00219 
00220   //@}
00221 
00222 
00223   //! Names for each of the outputs
00224   const char* const outputNames[NumOutputs] = {
00225     "WHEEL:L",
00226     "WHEEL:R",
00227     "LED:00000",
00228     "LED:00001",
00229   };
00230   
00231   //! allocation declared in RobotInfo.cc
00232   extern Capabilities capabilities;
00233   
00234   //! This table holds the default PID values for each joint.  see PIDMC
00235   const float DefaultPIDs[NumPIDJoints+1][3] = {
00236     {0,0,0} // extra value to avoid error in older versions of gcc (doesn't like empty array
00237   };
00238   
00239   //!These values are our recommended maximum joint velocities, in rad/ms
00240   /*! a value <= 0 means infinite speed (e.g. LEDs)
00241    *  
00242    *  These limits are <b>not</b> enforced by the framework.  They are simply available for you to use as you see fit.
00243    *  HeadPointerMC and PostureMC are primary examples of included classes which do respect these values (although they can be overridden)
00244    *  
00245    *  These values were obtained from the administrators of the Sony OPEN-R BBS */
00246   const float MaxOutputSpeed[NumOutputs] = {
00247     1<<8,
00248     1<<8,
00249     1<<8,
00250     1<<8,
00251   };
00252 
00253   #ifndef RAD
00254     //!Just a little macro for converting degrees to radians
00255   #define RAD(deg) (((deg) * M_PI ) / 180.0)
00256     //!a flag so we undef these after we're done - do you have a cleaner solution?
00257   #define __RI_RAD_FLAG
00258   #endif
00259   
00260   //! 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)
00261   const double outputRanges[NumOutputs][2] =
00262     {
00263       { -1 , 1 },
00264       { -1 , 1 },
00265       { RAD(-90) , RAD(90) },
00266       { RAD(-90) , RAD(90) },
00267     };
00268 
00269   //! 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)
00270   /*! Same as #outputRanges, don't know actual values because they were never specified by Sony */
00271   const double mechanicalLimits[NumOutputs][2] =
00272     {
00273       { -1 , 1 },
00274       { -1 , 1 },
00275       { RAD(-90) , RAD(90) },
00276       { RAD(-90) , RAD(90) },
00277     };
00278 
00279 #ifdef __RI_RAD_FLAG
00280 #undef RAD
00281 #undef __RI_RAD_FLAG
00282 #endif
00283 }
00284 
00285 #endif

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