Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Calliope3Components.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_Calliope3Components_h
00003 #define INCLUDED_Calliope3Components_h
00004 
00005 //**** This file defines Calliope components (arms, cameras, AX-S1
00006 //**** sensor module) that are used by CalliopeInfo.h to define
00007 //**** specific robot models such as Calliope2SP.
00008 
00009 #include <cmath>
00010 #include <stdlib.h>
00011 #include "CommonInfo.h"
00012 using namespace RobotInfo;
00013 
00014 // see http://tekkotsu.org/porting.html#configuration for more information on TGT_HAS_* flags
00015 
00016 
00017 #if defined(TGT_CALLIOPE3A) || defined(TGT_CALLIOPE3)
00018 #  define TGT_IS_CALLIOPE3
00019 #  define TGT_HAS_HEAD 1
00020 #  define TGT_HAS_CAMERA 1
00021 #  define TGT_HAS_ARMS 1
00022 #  define TGT_HAS_GRIPPER 1
00023 #endif
00024 
00025 
00026 #ifdef TGT_IS_CALLIOPE3
00027 #  define TGT_IS_CREATE2
00028 #endif
00029 
00030 #ifdef TGT_IS_CREATE2
00031 #  define TGT_HAS_WHEELS 2
00032 #  define TGT_HAS_BUTTONS 25
00033 #  define TGT_HAS_LEDS 6 
00034 #endif
00035 
00036 #ifndef RAD
00037 //!Just a little macro for converting degrees to radians
00038 #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00039 //!a flag so we undef these after we're done - do you have a cleaner solution?
00040 #define __RI_RAD_FLAG
00041 #endif
00042 
00043 
00044 //! Contains information about a Calliope robot, such as number of joints, LEDs, etc.
00045 namespace Calliope3Components {
00046   
00047   // *******************************
00048   //       ROBOT CONFIGURATION
00049   // *******************************
00050 
00051   const unsigned int FrameTime=30;        //!< time between frames in the motion system (milliseconds)
00052   const unsigned int NumFrames=1;        //!< the number of frames per buffer (don't forget also double buffered)
00053   const unsigned int SoundBufferTime=32; //!< the number of milliseconds per sound buffer... I'm not sure if this can be changed
00054   
00055   //!@name Output Types Information
00056   const unsigned NumWheels      =  2;
00057   
00058   const unsigned JointsPerLeg   =  0; //!< The number of joints per leg
00059   const unsigned NumLegs        =  0; //!< The number of legs
00060   const unsigned NumLegJoints   =  JointsPerLeg*NumLegs; //!< the TOTAL number of joints on ALL legs
00061   const unsigned NumTailJoints  =  0; //!< The number of joints assigned to the tail
00062   const unsigned NumMouthJoints =  0; //!< the number of joints that control the mouth
00063   const unsigned NumEarJoints   =  0; //!< The number of joints which control the ears (NOT per ear, is total)
00064   const unsigned NumButtons     =  31; //!< the number of buttons that are available
00065   const unsigned NumLEDs        =  6; //!< The number of LEDs which can be controlled
00066   const unsigned NumFacePanelLEDs = 0; //!< The number of face panel LEDs
00067   const unsigned NumSensors     =  36;  //!< the number of sensors available: 33 Create2 + 3 for GPS
00068   //@}
00069 
00070   const float wheelDiameter = 72.0; //!< Create 2 wheel diameter in mm
00071   const float wheelBase = 235.0; //!< Create 2 wheel base in mm
00072   const float encoderTicksPerRev = 508.8; //!< Number of encoder ticks per wheel revolution
00073   // *******************************
00074   //         OUTPUT OFFSETS
00075   // *******************************
00076 
00077   //!Corresponds to entries in outputNames, defined at the end of this file
00078   //!@name Output Offsets
00079 
00080   
00081   const unsigned PIDJointOffset = 0; //!< The beginning of the PID Joints
00082   const unsigned WheelOffset = PIDJointOffset;
00083 
00084   enum WheelOffset_t {
00085     LWheelOffset=WheelOffset,
00086     RWheelOffset
00087   };
00088   
00089   //! Offset needed so that the centroid of the robot is correct related to the bounding box
00090   const fmat::Column<3> AgentBoundingBoxBaseFrameOffset = fmat::pack(838.4/2-304.8/2,0,0);
00091 
00092   //! Half of the length, width, and height of the robot.
00093   const fmat::Column<3> AgentBoundingBoxHalfDims = fmat::pack(838.4/2, 304.8/2, 0);
00094 
00095   // *******************************
00096   //          INPUT OFFSETS
00097   // *******************************
00098 
00099 
00100   //! The order in which inputs should be stored
00101   //!@name Input Offsets
00102 
00103   //! holds offsets to different buttons in WorldState::buttons[]
00104   /*! Should be a straight mapping to the ButtonSourceIDs
00105    *
00106    *  @see WorldState::buttons
00107    * @hideinitializer */
00108   enum ButtonOffset_t {
00109     WallButOffset, //!< 1 if wall is detected (note correspondence to WALL_SIGNAL_OFFSET's value, avoiding problems if the two are swapped)
00110     DropLeftWheelButOffset, //!< 1 if left wheel detects dropoff
00111     DropRightWheelButOffset, //!< 1 if right wheel detects dropoff
00112     BumpLeftButOffset, //!< 1 if left bumper is pressed
00113     BumpRightButOffset, //!< 1 if right bumper is pressed
00114     CliffLeftButOffset, //!< 1 if cliff sensor detects dropoff
00115     CliffFrontLeftButOffset,
00116     CliffFrontRightButOffset,
00117     CliffRightButOffset,
00118     VirtualWallButOffset, //!< 1 if virtual wall is detected
00119     OvercurrentLeftWheelOffset, //!< 1 if the left wheel is drawing more than 1 amp
00120     OvercurrentRightWheelOffset, //!< 1 if the right wheel is drawing more than 1 amp
00121     OvercurrentMainBrushOffset, //!< 1 if the main brush is drawing more than 1 amp
00122     OvercurrentSideBrushOffset, //!< 1 if the side brush is drawing more than 1 amp
00123     CleanButOffset, //!< 1 if clean button is down
00124     SpotButOffset, //!< 1 if spot button is down
00125                 DockButOffset, //!< 1 if dock button is down
00126     MinuteButOffset, //!< 1 if minute button is down
00127     HourButOffset, //!< 1 if hour button is down
00128     DayButOffset, //!< 1 if day button is down
00129     ScheduleButOffset, //!< 1 if schedule button is down
00130     ClockButOffset, //!< 1 if clock button is down
00131     BaseChargerButOffset, //!< 1 if the home base charger is available
00132     InternalChargerButOffset, //!< 1 if the internal charger is available
00133     LtBumpRightOffset, //!< 1 if the right light bumper is pressed
00134     LtBumpFrontRightOffset,
00135     LtBumpCenterRightOffset,
00136     LtBumpCenterLeftOffset,
00137     LtBumpFrontLeftOffset,
00138     LtBumpLeftOffset,
00139     StasisButOffset //!< 1 if the robot is moving forward
00140   };
00141   const ButtonOffset_t GreenButOffset = CleanButOffset;
00142   const ButtonOffset_t YellowButOffset = SpotButOffset;
00143   const ButtonOffset_t RedButOffset = DockButOffset;
00144 
00145   //! Provides a string name for each button
00146         const char* const buttonNames[NumButtons + 1] ={
00147     "Wall",
00148     "LWheelDrop", "RWheelDrop",
00149     "LBump", "RBump",
00150     "LCliff", "LFrontCliff",
00151     "RCliff", "RFrontCliff",
00152     "VirtualWall",
00153     "LOverCurrent", "ROverCurrent", "MBrushOverCurrent", "SBrushOverCurrent",
00154     "Clean", "Spot", "Dock", "Minute", "Hour", "Day", "Schedule",
00155     "Clock",
00156     "BaseCharger", "InternalCharger",
00157     "LtBumperRight", "LtBumperFrontRight","LtBumperCenterRight", "LtBumperCenterLeft", "LtBumperFrontLeft", "LtBumperLeft",
00158     "Stasis",
00159     NULL
00160   };
00161     
00162   //! holds offset to different sensor values in WorldState::sensors[]
00163   /*! @see WorldState::sensors[] */
00164   enum SensorOffset_t {
00165     WallSignalOffset, //!< strength of the wall sensor's signal (note correspondence to WALL_OFFSET's value, avoid problems if the two are swapped)
00166     DirtDetectOffset, //!< Level of dirt detect sensor
00167     IRCommOffset, //!< value received by the infrared communication receiver, see IRComm_t for values sent by standard hardware
00168     IRLeftOffset, //!< value received by the left IR communciation receiver, see IRComm_t for values
00169     IRRightOffset, //!< value received by the right IR communication receiver, see IRComm_t for values
00170     CliffLeftSignalOffset, //!< strength of the left cliff sensor
00171     CliffFrontLeftSignalOffset, //!< strength of the front left cliff sensor
00172     CliffFrontRightSignalOffset, //!< strength of the front right cliff sensor
00173     CliffRightSignalOffset, //!< strength of the right cliff sensor
00174     EncoderDistanceOffset, //!< average distance (mm) traveled by the wheels since last update
00175     EncoderAngleOffset, //!< average angle (radians) rotated since the last update
00176     VoltageOffset, //!< mV measured at battery
00177     CurrentOffset, //!< mA flowing into battery (negative when discharging)
00178     BatteryChargeOffset, //!< mAh remaining in battery (may not be accurate with alkaline battery pack)
00179     BatteryTempOffset, //!< degrees celsius
00180     ChargingStateOffset, //!< one of #ChargingState_t
00181     ModeStateOffset, //!< one of #ModeState_t
00182     ReqVelocityOffset, //!< last requested velocity by a drive command
00183     ReqRadiusOffset, //!< last requested radius by a drive command
00184     ReqLeftVelocityOffset, //!< last requested velocity of left wheel
00185     ReqRightVelocityOffset, //!< last requested velocity of right wheel
00186     LeftEncoderOffset, //!< Count of the encoder of the left wheel
00187     RightEncoderOffset, //!< Count of the encoder of the right wheel
00188     LtBumpRightSignalOffset, //!< Signal strength of right light bumper
00189     LtBumpFrontRightSignalOffset,
00190     LtBumpCenterRightSignalOffset,
00191     LtBumpCenterLeftSignalOffset,
00192     LtBumpFrontLeftSignalOffset,
00193     LtBumpLeftSignalOffset,
00194     LeftMotorCurrentOffset, //!< Current of left motor in mA
00195     RightMotorCurrentOffset, //!< Current of right motor in mA
00196     SideBrushCurrentOffset, //!< Current of motor for side brush in mA
00197     MainBrushCurrentOffset, //!< Current of motor for main brush in mA
00198     GPSXOffset, //!< x-coordinate of robot from GPS or Mirage
00199     GPSYOffset, //!< y-coordinate of robot from GPS or Mirage
00200     GPSHeadingOffset, //!< heading of robot from GPS or Mirage
00201   };
00202   
00203   
00204   //! Provides a string name for each sensor
00205   const char* const sensorNames[NumSensors+1] = { 
00206     "WallSignal",
00207     "Dirt",
00208     "IR",
00209     "IRLeft",
00210     "IRRight",
00211     "CliffLeftSignal",
00212     "CliffFrontLeftSignal",
00213     "CliffFrontRightSignal",
00214     "CliffRight",
00215     "Distance",
00216     "Angle",
00217     "BatteryVoltage",
00218     "BatteryCurrent",
00219     "BatteryCharge",
00220     "BatteryTemp",
00221     "ChargingState",
00222     "ModeState",
00223     "RequestedVelocity",
00224     "RequestedRadius",
00225     "RequestedLeftVelocity",
00226     "RequestedRightVelocity",
00227     "LeftEncoderCount",
00228     "RightEncoderCount",
00229     "LightBumperRightSignal",
00230     "LightBumperFrontRightSignal",
00231     "LightBumperCenterRightSignal",
00232     "LightBumperCenterLeftSignal",
00233     "LightBumperFrontLeftSignal",
00234     "LightBumperLeftSignal",
00235     "LeftMotorCurrent",
00236     "RightMotorCurrent",
00237     "SideBrushCurrent",
00238     "MainBrushCurrent", 
00239     "GPSX",
00240     "GPSY",
00241     "GPSHeading",
00242     NULL
00243   };
00244   
00245   enum IRComm_t {
00246     IR_REMOTE_LEFT=129,
00247     IR_REMOTE_FORWARD,
00248     IR_REMOTE_RIGHT,
00249     IR_REMOTE_SPOT,
00250     IR_REMOTE_MAX,
00251     IR_REMOTE_SMALL,
00252     IR_REMOTE_MEDIUM,
00253     IR_REMOTE_LARGE,
00254     IR_REMOTE_PAUSE,
00255     IR_REMOTE_POWER,
00256     IR_REMOTE_ARC_LEFT, 
00257     IR_REMOTE_ARC_RIGHT,
00258     IR_REMOTE_STOP,
00259     IR_REMOTE_SEND,
00260     IR_REMOTE_DOCK,
00261     IR_BASE_RED=248,
00262     IR_BASE_GREEN=244,
00263     IR_BASE_FORCE=242,
00264     IR_BASE_RED_GREEN=252,
00265     IR_BASE_RED_FORCE=250,
00266     IR_BASE_GREEN_FORCE=246,
00267     IR_BASE_RED_GREEN_FORCE=254,
00268     IR_600_FORCE=161,
00269     IR_600_GREEN=164,
00270     IR_600_GREEN_FORCE,
00271     IR_600_RED = 168,
00272     IR_600_RED_FORCE,
00273     IR_600_RED_GREEN = 172,
00274     IR_600_RED_GREEN_FORCE,
00275     IR_WALL = 162
00276   };
00277   /*const unsigned IR_BASE_MASK=240;
00278   const unsigned IR_BASE_RED_MASK=8;
00279   const unsigned IR_BASE_GREEN_MASK=4;
00280   const unsigned IR_BASE_FORCE_MASK=2;*/
00281   
00282   enum ChargingState_t {
00283     CHARGING_OFF,
00284     CHARGING_RECONDITIONING,
00285     CHARGING_FULL,
00286     CHARGING_TRICKLE,
00287     CHARGING_WAITING,
00288     CHARGING_FAULT
00289   };
00290 
00291   enum ModeState_t {
00292     MODE_OFF,
00293     MODE_PASSIVE,
00294     MODE_SAFE,
00295     MODE_FULL
00296   };
00297     
00298   //@}
00299 
00300 
00301   namespace Calliope3 {
00302     const unsigned NumHeadJoints = 2; //!< The number of joints in the pan/tilt
00303     const unsigned HeadOffset  = WheelOffset+NumWheels;   //!< the offset of the beginning of the head joints, add TPROffset_t to get specific joint
00304     
00305     //! The offsets of appendages with pan (heading), tilt (elevation), note that this should be added to HeadOffset, otherwise use HeadOffset_t (#HeadPanOffset and #HeadTiltOffset)
00306     enum TPROffset_t {
00307       PanOffset = 0,      //!< pan/heading (horizontal)
00308       TiltOffset, //!< tilt/elevation (vertical)
00309       NodOffset = TiltOffset //!< replicated tilt (could be left undefined instead...)
00310     };
00311     
00312     //! These are 'absolute' offsets for the neck joints, don't need to add to HeadOffset like TPROffset_t values do
00313     enum HeadOffset_t {
00314       HeadPanOffset = HeadOffset,      //!< pan/heading (horizontal)
00315       HeadTiltOffset, //!< tilt/elevation (vertical)
00316     };
00317     
00318     const unsigned FingerJointsPerArm = 1;
00319     const unsigned JointsPerArm   =  3; //!< 2 arm joints plus gripper
00320     const unsigned NumArms        =  1;
00321     const unsigned NumArmJoints   =  JointsPerArm*NumArms;
00322     const unsigned NumPIDJoints   = NumWheels + NumHeadJoints + NumArmJoints; //!< number of motors and servos
00323     const unsigned NumOutputs     = NumPIDJoints + NumLEDs + 1 /*Create mode*/; //!< the total number of outputs
00324 
00325     const unsigned ArmOffset = HeadOffset+NumHeadJoints;
00326     const unsigned LEDOffset   = ArmOffset+NumArmJoints;
00327     const unsigned ModeOffset = LEDOffset + NumLEDs;
00328     
00329     const unsigned BaseFrameOffset   = NumOutputs; //!< Use with kinematics to refer to base reference frame
00330     const unsigned GripperFrameOffset = BaseFrameOffset + 1; //!< Use with kinematics to refer to gripper reference frame
00331     const unsigned CameraFrameOffset = GripperFrameOffset+NumArms; //!< Use with kinematics to refer to camera reference frame
00332 
00333     //! These are 'absolute' offsets for the arm joints, don't need to add to ArmOffset like TPROffset_t values do
00334     enum ArmOffset_t {
00335       ArmBaseOffset=ArmOffset,
00336       ArmShoulderOffset,
00337       GripperOffset
00338     };
00339     
00340     //! The offsets of the individual LEDs
00341     /*! @hideinitializer */
00342     enum LEDOffset_t {
00343       PowerRedLEDOffset=LEDOffset,
00344       PowerGreenLEDOffset,
00345       PlayLEDOffset,
00346       AdvanceLEDOffset
00347     };
00348     
00349     const LEDOffset_t RedLEDOffset = PowerRedLEDOffset;
00350     const LEDOffset_t BlueLEDOffset = AdvanceLEDOffset; //!< Create has no blue LED: use Advance LED here, and Advance+PowerRED in BlueLEDMask
00351     const LEDOffset_t GreenLEDOffset = PlayLEDOffset;
00352     const LEDOffset_t YellowLEDOffset = AdvanceLEDOffset;
00353     
00354     typedef unsigned int LEDBitMask_t; //!< So you can be clear when you're refering to a LED bitmask
00355     
00356     const LEDBitMask_t BlueLEDMask = (1<<(AdvanceLEDOffset-LEDOffset)) |
00357     (1<<(PowerRedLEDOffset-LEDOffset)); //!< Create has no blue LED, so use Advance (green) + Power (red)
00358     const LEDBitMask_t GreenLEDMask = 1<<(GreenLEDOffset-LEDOffset); //!< mask corresponding to GreenLEDOffset
00359     const LEDBitMask_t YellowLEDMask = 1<<(YellowLEDOffset-LEDOffset); //!< mask corresponding to YellowLEDOffset
00360     const LEDBitMask_t RedLEDMask = 1<<(RedLEDOffset-LEDOffset); //!< mask corresponding to RedLEDOffset
00361     
00362     const LEDBitMask_t PowerRedLEDMask = 1<<(PowerRedLEDOffset-LEDOffset); //!< mask corresponding to BlueLEDOffset
00363     const LEDBitMask_t PowerGreenLEDMask = 1<<(PowerGreenLEDOffset-LEDOffset); //!< mask corresponding to GreenLEDOffset
00364     const LEDBitMask_t PlayLEDMask = 1<<(PlayLEDOffset-LEDOffset); //!< mask corresponding to YellowLEDOffset
00365     const LEDBitMask_t AdvanceLEDMask = 1<<(AdvanceLEDOffset-LEDOffset); //!< mask corresponding to RedLEDOffset
00366     
00367     //! LEDs for the face panel (all FaceLEDPanelMask<<(0:NumFacePanelLEDs-1) entries)
00368     const LEDBitMask_t FaceLEDMask = 0;
00369     //! selects all of the leds
00370     const LEDBitMask_t AllLEDMask  = (LEDBitMask_t)~0;
00371     //@}
00372     //! This table holds the default PID values for each joint.  see PIDMC
00373     const float DefaultPIDs[NumPIDJoints][3] = {
00374       {1,0,0},
00375       {1,0,0},
00376       {32,32,1},
00377       {32,32,1},
00378       {32,32,1},
00379       {32,32,1},
00380       {32,32,1}
00381     };
00382     
00383     //!These values are our recommended maximum joint velocities, in rad/ms
00384     const float MaxOutputSpeed[NumOutputs] = {
00385       0, 0,   // wheels
00386       1.f, 1.f,   // head
00387       1.f, 1.f, 1.f, // arm
00388       0,
00389       0,
00390       0,
00391       0,
00392       0
00393     };
00394     
00395     //! 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)
00396     const float outputRanges[NumOutputs][2] =
00397     {
00398       { -500 , 500 }, // left wheel
00399       { -500 , 500 }, // right wheel
00400       {RAD(-150),RAD(150)}, // neck pan
00401       {RAD(-92),RAD(75)}, // neck tilt
00402       {RAD(-150),RAD(75)}, // arm base
00403       {RAD(-60),RAD(49)}, // arm shoulder
00404       {RAD(0),RAD(130)}, // gripper
00405       {  0 , 1 },
00406       {  0 , 1 },
00407       {  0 , 1 },
00408       {  0 , 1 },
00409       { MODE_PASSIVE, MODE_SAFE }
00410     };
00411   }
00412 }
00413 #endif

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