00001
00002 #ifndef INCLUDED_ChiaraInfo_h
00003 #define INCLUDED_ChiaraInfo_h
00004
00005 #include <cmath>
00006 #include <stdlib.h>
00007 #include "CommonInfo.h"
00008 using namespace RobotInfo;
00009
00010
00011 #if defined(TGT_CHIARA)
00012 # define TGT_IS_BIOLOID
00013 # define TGT_IS_CHIARA
00014 # define TGT_HAS_CAMERA 1
00015 # define TGT_HAS_LEDS 11
00016 # define TGT_HAS_BUTTONS 3
00017 # define TGT_HAS_LEGS 6
00018 # define TGT_HAS_SEK_LEGS 6
00019 # define TGT_HAS_ARMS 1
00020 # define TGT_HAS_HEAD 1
00021 # define TGT_HAS_POWER_STATUS
00022 # define TGT_HAS_IR_DISTANCE 3
00023 #endif
00024
00025
00026 namespace ChiaraInfo {
00027
00028
00029
00030
00031
00032 extern const char* const TargetName;
00033
00034 const unsigned int FrameTime=32;
00035 const unsigned int NumFrames=1;
00036 const unsigned int SoundBufferTime=32;
00037
00038
00039 const unsigned NumWheels = 0;
00040
00041 const unsigned JointsPerArm = 6;
00042 const unsigned NumArms = 1;
00043 const unsigned NumArmJoints = JointsPerArm*NumArms;
00044
00045 const unsigned JointsPerLeg = 3;
00046 const unsigned NumLegs = 6;
00047 const unsigned NumLegJoints = JointsPerLeg*NumLegs;
00048 const unsigned NumHeadJoints = 2;
00049 const unsigned NumTailJoints = 0;
00050 const unsigned NumMouthJoints = 0;
00051 const unsigned NumEarJoints = 0;
00052 const unsigned NumButtons = 3;
00053 const unsigned NumSensors = 11;
00054 const unsigned NumFacePanelLEDs = 0;
00055
00056 const unsigned NumLEDs = NumLegs + 1 + 4;
00057 const unsigned NumPIDJoints = NumArmJoints + 1 + NumLegJoints + NumHeadJoints+NumTailJoints+NumMouthJoints;;
00058
00059 const unsigned NumOutputs = NumWheels + NumPIDJoints + NumLEDs;
00060 const unsigned NumReferenceFrames = NumOutputs + 1 + NumLegs + NumArms + 1 + 3;
00061
00062 using namespace Camera75DOF;
00063
00064 const float BallOfFootRadius=0;
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 const unsigned PIDJointOffset = 0;
00077 const unsigned RFrRotatorOffset = PIDJointOffset;
00078 const unsigned LegOffset = RFrRotatorOffset+1;
00079 const unsigned ArmOffset = LegOffset+NumLegJoints;
00080 const unsigned HeadOffset = ArmOffset+NumArmJoints;
00081
00082 const unsigned LEDOffset = PIDJointOffset + NumPIDJoints;
00083
00084 const unsigned BaseFrameOffset = NumOutputs;
00085 const unsigned FootFrameOffset = BaseFrameOffset+1;
00086 const unsigned GripperFrameOffset = FootFrameOffset+NumLegs;
00087 const unsigned CameraFrameOffset = GripperFrameOffset+NumArms;
00088
00089 const unsigned LeftIRFrameOffset = CameraFrameOffset+1;
00090 const unsigned CenterIRFrameOffset = LeftIRFrameOffset+1;
00091 const unsigned IRFrameOffset = CenterIRFrameOffset;
00092 const unsigned RightIRFrameOffset = CenterIRFrameOffset+1;
00093
00094
00095 enum LegOrder_t {
00096 RFrLegOrder = 0,
00097 LFrLegOrder,
00098 RMdLegOrder,
00099 LMdLegOrder,
00100 RBkLegOrder,
00101 LBkLegOrder
00102 };
00103
00104
00105 enum SEKOffset_t {
00106 SweepOffset=0,
00107 ElevatorOffset,
00108 KneeOffset
00109 };
00110
00111
00112 enum TPROffset_t {
00113 PanOffset=0,
00114 TiltOffset,
00115 NodOffset = TiltOffset,
00116 RollOffset
00117 };
00118
00119
00120
00121 enum LegOffset_t {
00122 RFrLegOffset = LegOffset+RFrLegOrder*JointsPerLeg,
00123 LFrLegOffset = LegOffset+LFrLegOrder*JointsPerLeg,
00124 RMdLegOffset = LegOffset+RMdLegOrder*JointsPerLeg,
00125 LMdLegOffset = LegOffset+LMdLegOrder*JointsPerLeg,
00126 RBkLegOffset = LegOffset+RBkLegOrder*JointsPerLeg,
00127 LBkLegOffset = LegOffset+LBkLegOrder*JointsPerLeg,
00128 };
00129
00130
00131 enum ArmOffset_t {
00132 ArmShoulderOffset=ArmOffset,
00133 ArmElbowOffset,
00134 WristOffset,
00135 WristYawOffset = WristOffset,
00136 WristPitchOffset,
00137 WristRollOffset,
00138 GripperOffset
00139 };
00140
00141
00142 enum HeadOffset_t {
00143 HeadPanOffset = HeadOffset,
00144 HeadTiltOffset,
00145 };
00146
00147
00148
00149 enum LEDOffset_t {
00150 BlueLEDOffset = LEDOffset,
00151 GreenLEDOffset,
00152 YellowLEDOffset,
00153 RedLEDOffset,
00154 RFrKneeLEDOffset,
00155 LFrKneeLEDOffset,
00156 RMdKneeLEDOffset,
00157 LMdKneeLEDOffset,
00158 RBkKneeLEDOffset,
00159 LBkKneeLEDOffset,
00160 HeadLEDOffset
00161 };
00162
00163 typedef unsigned int LEDBitMask_t;
00164
00165 const LEDBitMask_t BlueLEDMask = 1<<(BlueLEDOffset-LEDOffset);
00166 const LEDBitMask_t GreenLEDMask = 1<<(GreenLEDOffset-LEDOffset);
00167 const LEDBitMask_t YellowLEDMask = 1<<(YellowLEDOffset-LEDOffset);
00168 const LEDBitMask_t RedLEDMask = 1<<(RedLEDOffset-LEDOffset);
00169 const LEDBitMask_t RFrKneeLEDMask = 1<<(RFrKneeLEDOffset-LEDOffset);
00170 const LEDBitMask_t LFrKneeLEDMask = 1<<(LFrKneeLEDOffset-LEDOffset);
00171 const LEDBitMask_t RMdKneeLEDMask = 1<<(RMdKneeLEDOffset-LEDOffset);
00172 const LEDBitMask_t LMdKneeLEDMask = 1<<(LMdKneeLEDOffset-LEDOffset);
00173 const LEDBitMask_t RBkKneeLEDMask = 1<<(RBkKneeLEDOffset-LEDOffset);
00174 const LEDBitMask_t LBkKneeLEDMask = 1<<(LBkKneeLEDOffset-LEDOffset);
00175 const LEDBitMask_t HeadLEDMask = 1<<(HeadLEDOffset-LEDOffset);
00176
00177
00178 const LEDBitMask_t FaceLEDMask = HeadLEDMask;
00179
00180 const LEDBitMask_t AllLEDMask = (LEDBitMask_t)~0;
00181
00182
00183
00184
00185 const fmat::Column<3> AgentBoundingBoxBaseFrameOffset = fmat::pack(0,0,0);
00186
00187
00188 const fmat::Column<3> AgentBoundingBoxHalfDims = fmat::pack(304.8/2, 304.8/2, 0);
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 enum ButtonOffset_t { GreenButOffset, RedButOffset, YellowButOffset };
00209
00210
00211 const char* const buttonNames[NumButtons+1] = { "GreenBut", "RedBut", "YellowBut", NULL };
00212
00213
00214
00215 enum SensorOffset_t {
00216 LeftIRDistOffset,
00217 CenterIRDistOffset,
00218 IRDistOffset = CenterIRDistOffset,
00219 RightIRDistOffset,
00220 LeftLuminosityOffset,
00221 CenterLuminosityOffset,
00222 RightLuminosityOffset,
00223 MicVolumeOffset,
00224 MicSpikeCountOffset,
00225 PowerRemainOffset,
00226 PowerThermoOffset,
00227 PowerVoltageOffset,
00228 };
00229
00230
00231 const char* const sensorNames[NumSensors+1] = {
00232 "LeftIRDist", "CenterIRDist", "RightIRDist",
00233 "LeftLuminosity", "CenterLuminosity", "RightLuminosity",
00234 "MicVolume", "MicSpikeCount",
00235 "PowerRemain", "PowerThermo", "PowerVoltage", NULL
00236 };
00237
00238
00239
00240
00241
00242 const char* const outputNames[NumReferenceFrames+1] = {
00243
00244 "RFr:rotor",
00245 "RFr:sweep","RFr:elvtr","RFr:knee",
00246 "LFr:sweep","LFr:elvtr","LFr:knee",
00247 "RMd:sweep","RMd:elvtr","RMd:knee",
00248 "LMd:sweep","LMd:elvtr","LMd:knee",
00249 "RBk:sweep","RBk:elvtr","RBk:knee",
00250 "LBk:sweep","LBk:elvtr","LBk:knee",
00251 "ARM:shldr","ARM:elbow","ARM:wristYaw","ARM:wristPitch","ARM:wristRoll","ARM:gripper",
00252 "NECK:pan","NECK:tilt",
00253
00254
00255
00256 "LED:blue", "LED:green", "LED:yellow", "LED:red",
00257 "LED:RFr:knee","LED:LFr:knee",
00258 "LED:RMd:knee","LED:LMd:knee",
00259 "LED:RBk:knee","LED:LBk:knee",
00260 "LED:NECK:pan",
00261
00262
00263 "BaseFrame",
00264 "RFrFootFrame",
00265 "LFrFootFrame",
00266 "RMdFootFrame",
00267 "LMdFootFrame",
00268 "RBkFootFrame",
00269 "LBkFootFrame",
00270 "GripperFrame",
00271 "CameraFrame",
00272 "LeftIRFrame",
00273 "CenterIRFrame",
00274 "RightIRFrame",
00275 NULL
00276 };
00277
00278
00279 class ChiaraCapabilities : public Capabilities {
00280 public:
00281
00282 ChiaraCapabilities()
00283 : Capabilities(TargetName,NumReferenceFrames,outputNames,NumButtons,buttonNames,NumSensors,sensorNames,PIDJointOffset,NumPIDJoints,LEDOffset,NumLEDs,NumOutputs)
00284 {
00285 frameToIndex["ARM:Wrist"] = WristYawOffset;
00286 frameToIndex["NECK:nod"] = HeadTiltOffset;
00287 frameToIndex["IRFrame"] = IRFrameOffset;
00288 sensorToIndex["IRDist"]=IRDistOffset;
00289 }
00290 };
00291
00292 extern const ChiaraCapabilities capabilities;
00293
00294
00295
00296 enum ServoParam_t {
00297 DYNAMIXEL_SLOPE=0,
00298 DYNAMIXEL_PUNCH,
00299 DYNAMIXEL_MARGIN
00300 };
00301
00302
00303
00304
00305 const float DefaultPIDs[NumPIDJoints][3] = {
00306 {32,32,0},
00307 {32,32,0}, {32,32,0}, {32,32,0},
00308 {32,32,0}, {32,32,0}, {32,32,0},
00309 {32,32,0}, {32,32,0}, {32,32,0},
00310 {32,32,0}, {32,32,0}, {32,32,0},
00311 {32,32,0}, {32,32,0}, {32,32,0},
00312 {32,32,0}, {32,32,0}, {32,32,0},
00313 {32,32,0}, {32,32,0}, {32,32,0}, {32,32,0}, {32,32,0}, {32,32,0},
00314 {32,32,0}, {32,32,0},
00315 };
00316
00317
00318
00319
00320
00321
00322
00323
00324 const float MaxOutputSpeed[NumOutputs] = {
00325
00326 0,
00327 0,0,0,
00328 0,0,0,
00329 0,0,0,
00330 0,0,0,
00331 0,0,0,
00332 0,0,0,
00333 0,0,0,0,0,0,
00334 0,0,
00335
00336 0,0,
00337 0,0,
00338 0,0,
00339 0,
00340 0,0,0,0,
00341 };
00342
00343 #ifndef RAD
00344
00345 #define RAD(deg) (((deg) * (float)M_PI ) / 180.0f)
00346
00347 #define __RI_RAD_FLAG
00348 #endif
00349
00350
00351 const float outputRanges[NumOutputs][2] = {
00352
00353 {RAD(-17),RAD(90)},
00354 {RAD(-102),RAD(67)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00355 {RAD(-53),RAD(58)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00356 {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00357 {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00358 {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00359 {RAD(-73),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00360 {RAD(-95),RAD(95)}, {RAD(-95),RAD(95)}, {RAD(-100),RAD(100)}, {RAD(-90),RAD(90)}, {RAD(-90),RAD(90)}, {RAD(-90),RAD(90)},
00361 {RAD(-150),RAD(150)}, {RAD(-92),RAD(75)},
00362
00363
00364 {0,1}, {0,1},
00365 {0,1}, {0,1},
00366 {0,1}, {0,1},
00367 {0,1},
00368 {0,1}, {0,1}, {0,1}, {0,1},
00369 };
00370
00371
00372
00373 const float mechanicalLimits[NumOutputs][2] = {
00374
00375 {RAD(-17),RAD(90)},
00376 {RAD(-102),RAD(67)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00377 {RAD(-53),RAD(58)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00378 {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00379 {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00380 {RAD(-53),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00381 {RAD(-73),RAD(53)}, {RAD(-100),RAD(100)}, {RAD(-55),RAD(160)},
00382 {RAD(-95),RAD(95)}, {RAD(-95),RAD(95)}, {RAD(-100),RAD(100)}, {RAD(-90),RAD(90)}, {RAD(-90),RAD(90)}, {RAD(-90),RAD(90)},
00383 {RAD(-150),RAD(150)}, {RAD(-92),RAD(75)},
00384
00385
00386 {0,1}, {0,1},
00387 {0,1}, {0,1},
00388 {0,1}, {0,1},
00389 {0,1},
00390 {0,1}, {0,1}, {0,1}, {0,1},
00391 };
00392
00393 #ifdef __RI_RAD_FLAG
00394 #undef RAD
00395 #undef __RI_RAD_FLAG
00396 #endif
00397 }
00398
00399
00400
00401
00402
00403
00404 #endif