00001
00002 #ifndef INCLUDED_Calliope3Components_h
00003 #define INCLUDED_Calliope3Components_h
00004
00005
00006
00007
00008
00009 #include <cmath>
00010 #include <stdlib.h>
00011 #include "CommonInfo.h"
00012 using namespace RobotInfo;
00013
00014
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
00038 #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00039
00040 #define __RI_RAD_FLAG
00041 #endif
00042
00043
00044
00045 namespace Calliope3Components {
00046
00047
00048
00049
00050
00051 const unsigned int FrameTime=30;
00052 const unsigned int NumFrames=1;
00053 const unsigned int SoundBufferTime=32;
00054
00055
00056 const unsigned NumWheels = 2;
00057
00058 const unsigned JointsPerLeg = 0;
00059 const unsigned NumLegs = 0;
00060 const unsigned NumLegJoints = JointsPerLeg*NumLegs;
00061 const unsigned NumTailJoints = 0;
00062 const unsigned NumMouthJoints = 0;
00063 const unsigned NumEarJoints = 0;
00064 const unsigned NumButtons = 31;
00065 const unsigned NumLEDs = 6;
00066 const unsigned NumFacePanelLEDs = 0;
00067 const unsigned NumSensors = 36;
00068
00069
00070 const float wheelDiameter = 72.0;
00071 const float wheelBase = 235.0;
00072 const float encoderTicksPerRev = 508.8;
00073
00074
00075
00076
00077
00078
00079
00080
00081 const unsigned PIDJointOffset = 0;
00082 const unsigned WheelOffset = PIDJointOffset;
00083
00084 enum WheelOffset_t {
00085 LWheelOffset=WheelOffset,
00086 RWheelOffset
00087 };
00088
00089
00090 const fmat::Column<3> AgentBoundingBoxBaseFrameOffset = fmat::pack(838.4/2-304.8/2,0,0);
00091
00092
00093 const fmat::Column<3> AgentBoundingBoxHalfDims = fmat::pack(838.4/2, 304.8/2, 0);
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 enum ButtonOffset_t {
00109 WallButOffset,
00110 DropLeftWheelButOffset,
00111 DropRightWheelButOffset,
00112 BumpLeftButOffset,
00113 BumpRightButOffset,
00114 CliffLeftButOffset,
00115 CliffFrontLeftButOffset,
00116 CliffFrontRightButOffset,
00117 CliffRightButOffset,
00118 VirtualWallButOffset,
00119 OvercurrentLeftWheelOffset,
00120 OvercurrentRightWheelOffset,
00121 OvercurrentMainBrushOffset,
00122 OvercurrentSideBrushOffset,
00123 CleanButOffset,
00124 SpotButOffset,
00125 DockButOffset,
00126 MinuteButOffset,
00127 HourButOffset,
00128 DayButOffset,
00129 ScheduleButOffset,
00130 ClockButOffset,
00131 BaseChargerButOffset,
00132 InternalChargerButOffset,
00133 LtBumpRightOffset,
00134 LtBumpFrontRightOffset,
00135 LtBumpCenterRightOffset,
00136 LtBumpCenterLeftOffset,
00137 LtBumpFrontLeftOffset,
00138 LtBumpLeftOffset,
00139 StasisButOffset
00140 };
00141 const ButtonOffset_t GreenButOffset = CleanButOffset;
00142 const ButtonOffset_t YellowButOffset = SpotButOffset;
00143 const ButtonOffset_t RedButOffset = DockButOffset;
00144
00145
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
00163
00164 enum SensorOffset_t {
00165 WallSignalOffset,
00166 DirtDetectOffset,
00167 IRCommOffset,
00168 IRLeftOffset,
00169 IRRightOffset,
00170 CliffLeftSignalOffset,
00171 CliffFrontLeftSignalOffset,
00172 CliffFrontRightSignalOffset,
00173 CliffRightSignalOffset,
00174 EncoderDistanceOffset,
00175 EncoderAngleOffset,
00176 VoltageOffset,
00177 CurrentOffset,
00178 BatteryChargeOffset,
00179 BatteryTempOffset,
00180 ChargingStateOffset,
00181 ModeStateOffset,
00182 ReqVelocityOffset,
00183 ReqRadiusOffset,
00184 ReqLeftVelocityOffset,
00185 ReqRightVelocityOffset,
00186 LeftEncoderOffset,
00187 RightEncoderOffset,
00188 LtBumpRightSignalOffset,
00189 LtBumpFrontRightSignalOffset,
00190 LtBumpCenterRightSignalOffset,
00191 LtBumpCenterLeftSignalOffset,
00192 LtBumpFrontLeftSignalOffset,
00193 LtBumpLeftSignalOffset,
00194 LeftMotorCurrentOffset,
00195 RightMotorCurrentOffset,
00196 SideBrushCurrentOffset,
00197 MainBrushCurrentOffset,
00198 GPSXOffset,
00199 GPSYOffset,
00200 GPSHeadingOffset,
00201 };
00202
00203
00204
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
00278
00279
00280
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;
00303 const unsigned HeadOffset = WheelOffset+NumWheels;
00304
00305
00306 enum TPROffset_t {
00307 PanOffset = 0,
00308 TiltOffset,
00309 NodOffset = TiltOffset
00310 };
00311
00312
00313 enum HeadOffset_t {
00314 HeadPanOffset = HeadOffset,
00315 HeadTiltOffset,
00316 };
00317
00318 const unsigned FingerJointsPerArm = 1;
00319 const unsigned JointsPerArm = 3;
00320 const unsigned NumArms = 1;
00321 const unsigned NumArmJoints = JointsPerArm*NumArms;
00322 const unsigned NumPIDJoints = NumWheels + NumHeadJoints + NumArmJoints;
00323 const unsigned NumOutputs = NumPIDJoints + NumLEDs + 1 ;
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;
00330 const unsigned GripperFrameOffset = BaseFrameOffset + 1;
00331 const unsigned CameraFrameOffset = GripperFrameOffset+NumArms;
00332
00333
00334 enum ArmOffset_t {
00335 ArmBaseOffset=ArmOffset,
00336 ArmShoulderOffset,
00337 GripperOffset
00338 };
00339
00340
00341
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;
00351 const LEDOffset_t GreenLEDOffset = PlayLEDOffset;
00352 const LEDOffset_t YellowLEDOffset = AdvanceLEDOffset;
00353
00354 typedef unsigned int LEDBitMask_t;
00355
00356 const LEDBitMask_t BlueLEDMask = (1<<(AdvanceLEDOffset-LEDOffset)) |
00357 (1<<(PowerRedLEDOffset-LEDOffset));
00358 const LEDBitMask_t GreenLEDMask = 1<<(GreenLEDOffset-LEDOffset);
00359 const LEDBitMask_t YellowLEDMask = 1<<(YellowLEDOffset-LEDOffset);
00360 const LEDBitMask_t RedLEDMask = 1<<(RedLEDOffset-LEDOffset);
00361
00362 const LEDBitMask_t PowerRedLEDMask = 1<<(PowerRedLEDOffset-LEDOffset);
00363 const LEDBitMask_t PowerGreenLEDMask = 1<<(PowerGreenLEDOffset-LEDOffset);
00364 const LEDBitMask_t PlayLEDMask = 1<<(PlayLEDOffset-LEDOffset);
00365 const LEDBitMask_t AdvanceLEDMask = 1<<(AdvanceLEDOffset-LEDOffset);
00366
00367
00368 const LEDBitMask_t FaceLEDMask = 0;
00369
00370 const LEDBitMask_t AllLEDMask = (LEDBitMask_t)~0;
00371
00372
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
00384 const float MaxOutputSpeed[NumOutputs] = {
00385 0, 0,
00386 1.f, 1.f,
00387 1.f, 1.f, 1.f,
00388 0,
00389 0,
00390 0,
00391 0,
00392 0
00393 };
00394
00395
00396 const float outputRanges[NumOutputs][2] =
00397 {
00398 { -500 , 500 },
00399 { -500 , 500 },
00400 {RAD(-150),RAD(150)},
00401 {RAD(-92),RAD(75)},
00402 {RAD(-150),RAD(75)},
00403 {RAD(-60),RAD(49)},
00404 {RAD(0),RAD(130)},
00405 { 0 , 1 },
00406 { 0 , 1 },
00407 { 0 , 1 },
00408 { 0 , 1 },
00409 { MODE_PASSIVE, MODE_SAFE }
00410 };
00411 }
00412 }
00413 #endif