00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __MOTIONREQUEST_H__
00014 #define __MOTIONREQUEST_H__
00015
00016 #include "Tools/Streams/InOut.h"
00017 #include "Tools/Math/Pose2D.h"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 static const double walkMaxForwardSpeed = 450.0;
00030
00031 static const double walkMaxBackwardSpeed = 350.0;
00032
00033 static const double walkMaxLeftRightSpeed = 400.0;
00034
00035 static const double walkMaxRotationSpeed = fromDegrees(250);
00036
00037
00038
00039
00040
00041
00042 class SpecialActionRequest{
00043 public:
00044
00045 enum SpecialActionID {
00046
00047 anyLeft,
00048 armLeft,
00049 armRight,
00050 anyRight,
00051 backKickLeft,
00052 backKickRight,
00053 bash,
00054 bbHeadLeftSoft,
00055 bbHeadLeftStrong,
00056 bbHeadRightSoft,
00057 bbHeadRightStrong,
00058 block,
00059 blockLeft,
00060 blockRight,
00061 cheerAssShake,
00062 cheerHappy1,
00063 cheerHappy2,
00064 cheerHappy3,
00065 cheerHappy4,
00066 cheerHappy5,
00067 cheerHappy6,
00068 cheerHeadStand,
00069 cheerHowl,
00070 cheerLegTrick,
00071 cheerNodHead,
00072 cheerSad1,
00073 cheerSad2,
00074 cheerSad3,
00075 cheerSad5,
00076 cheerSad4,
00077 cheerWaveLeft,
00078 cheerWaveRight,
00079 chestHard,
00080 chestSoft,
00081 dddBlock,
00082 dddBlockLeft,
00083 dddBlockMiddleLeft,
00084 dddBlockMiddleRight,
00085 dddBlockRight,
00086 dddGetUpLeft,
00087 dddGetUpMiddleLeft,
00088 dddGetUpMiddleRight,
00089 dddGetUpMiddle,
00090 dddGetUpRight,
00091 dddDribbleLeft,
00092 dddDribbleRight,
00093 dddPushModerate,
00094 dddTurnLeft,
00095 dddTurnRight,
00096 demoBallOnBack1,
00097 demoBallOnBack2,
00098 demoPackHeadStand,
00099 demoRemoveEars,
00100 demoRollLeft,
00101 demoRollRight,
00102 demoScratchHead,
00103 demoSit,
00104 demoStandUpsideDown,
00105 forwardKickFast,
00106 forwardKickHard,
00107 headLeft,
00108 headLeftSoft,
00109 headRight,
00110 headRightSoft,
00111 hookLeft,
00112 hookRight,
00113 kickAlongArmLeft,
00114 kickAlongArmRight,
00115 kickWithBackLegLeft,
00116 kickWithBackLegRight,
00117 leftPaw,
00118 mshAssBomb,
00119 mshNeckKick,
00120 penaltyBlockLeft,
00121 penaltyBlockRight,
00122 pushSoft,
00123 pushStrong,
00124 putLeft,
00125 putRight,
00126 rightPaw,
00127 slapLeft,
00128 slapRight,
00129 snowPlow,
00130 swing,
00131 tunnelKick,
00132 pushFromGrab,
00133 bashFromGrab,
00134 headKickFromGrab,
00135 numOfSpecialAction
00136 };
00137
00138 SpecialActionRequest():specialActionType(swing){}
00139
00140 SpecialActionID specialActionType;
00141
00142
00143
00144 static const char* getSpecialActionIDName(SpecialActionID id)
00145 {
00146 switch (id)
00147 {
00148 case anyLeft: return "anyLeft";
00149 case armLeft: return "armLeft";
00150 case armRight: return "armRight";
00151 case anyRight: return "anyRight";
00152 case backKickLeft: return "backKickLeft";
00153 case backKickRight: return "backKickRight";
00154 case bash: return "bash";
00155 case bbHeadLeftSoft: return "bbHeadLeftSoft";
00156 case bbHeadLeftStrong: return "bbHeadLeftStrong";
00157 case bbHeadRightSoft: return "bbHeadRightSoft";
00158 case bbHeadRightStrong: return "bbHeadRightStrong";
00159 case block: return "block";
00160 case blockLeft: return "blockLeft";
00161 case blockRight: return "blockRight";
00162 case cheerAssShake: return "cheerAssShake";
00163 case cheerHappy1: return "cheerHappy1";
00164 case cheerHappy2: return "cheerHappy2";
00165 case cheerHappy3: return "cheerHappy3";
00166 case cheerHappy4: return "cheerHappy4";
00167 case cheerHappy5: return "cheerHappy5";
00168 case cheerHappy6: return "cheerHappy6";
00169 case cheerHeadStand: return "cheerHeadStand";
00170 case cheerHowl: return "cheerHowl";
00171 case cheerLegTrick: return "cheerLegTrick";
00172 case cheerNodHead: return "cheerNodHead";
00173 case cheerSad1: return "cheerSad1";
00174 case cheerSad2: return "cheerSad2";
00175 case cheerSad3: return "cheerSad3";
00176 case cheerSad5: return "cheerSad5";
00177 case cheerSad4: return "cheerSad4";
00178 case cheerWaveLeft: return "cheerWaveLeft";
00179 case cheerWaveRight: return "cheerWaveRight";
00180 case chestHard: return "chestHard";
00181 case chestSoft: return "chestSoft";
00182 case dddBlock: return "dddBlock";
00183 case dddBlockLeft: return "dddBlockLeft";
00184 case dddBlockMiddleLeft: return "dddBlockMiddleLeft";
00185 case dddBlockMiddleRight: return "dddBlockMiddleRight";
00186 case dddBlockRight: return "dddBlockRight";
00187 case dddGetUpLeft: return "dddGetUpLeft";
00188 case dddGetUpMiddleLeft: return "dddGetUpMiddleLeft";
00189 case dddGetUpMiddleRight: return "dddGetUpMiddleRight";
00190 case dddGetUpMiddle: return "dddGetUpMiddle";
00191 case dddGetUpRight: return "dddGetUpRight";
00192 case dddDribbleLeft: return "dddDribbleLeft";
00193 case dddDribbleRight: return "dddDribbleRight";
00194 case dddPushModerate: return "dddPushModerate";
00195 case dddTurnLeft: return "dddTurnLeft";
00196 case dddTurnRight: return "dddTurnRight";
00197 case demoBallOnBack1: return "demoBallOnBack1";
00198 case demoBallOnBack2: return "demoBallOnBack2";
00199 case demoPackHeadStand: return "demoPackHeadStand";
00200 case demoRemoveEars: return "demoRemoveEars";
00201 case demoRollLeft: return "demoRollLeft";
00202 case demoRollRight: return "demoRollRight";
00203 case demoScratchHead: return "demoScratchHead";
00204 case demoSit: return "demoSit";
00205 case demoStandUpsideDown: return "demoStandUpsideDown";
00206 case forwardKickFast: return "forwardKickFast";
00207 case forwardKickHard: return "forwardKickHard";
00208 case headLeft: return "headLeft";
00209 case headLeftSoft: return "headLeftSoft";
00210 case headRight: return "headRight";
00211 case headRightSoft: return "headRightSoft";
00212 case hookLeft: return "hookLeft";
00213 case hookRight: return "hookRight";
00214 case kickAlongArmLeft: return "kickAlongArmLeft";
00215 case kickAlongArmRight: return "kickAlongArmRight";
00216 case kickWithBackLegLeft: return "kickWithBackLegLeft";
00217 case kickWithBackLegRight: return "kickWithBackLegRight";
00218 case leftPaw: return "leftPaw";
00219 case mshAssBomb: return "mshAssBomb";
00220 case mshNeckKick: return "mshNeckKick";
00221 case penaltyBlockLeft: return "penaltyBlockLeft";
00222 case penaltyBlockRight: return "penaltyBlockRight";
00223 case pushSoft: return "pushSoft";
00224 case pushStrong: return "pushStrong";
00225 case putLeft: return "putLeft";
00226 case putRight: return "putRight";
00227 case rightPaw: return "rightPaw";
00228 case slapLeft: return "slapLeft";
00229 case slapRight: return "slapRight";
00230 case snowPlow: return "snowPlow";
00231 case swing: return "swing";
00232 case tunnelKick: return "tunnelKick";
00233 case pushFromGrab: return "pushFromGrab";
00234 case bashFromGrab: return "bashFromGrab";
00235 case headKickFromGrab: return "headKickFromGrab";
00236
00237 default: return "please edit MotionRequest::getSpecialActionName";
00238 }
00239 }
00240
00241
00242
00243
00244 static SpecialActionRequest::SpecialActionID getSpecialActionIDFromName(const char* name);
00245 };
00246
00247 class WalkRequest{
00248 public:
00249
00250 enum WalkType {
00251 normal,
00252 upsideDown,
00253 turnWithBall,
00254 turnKick,
00255 dash,
00256 debug,
00257 boost,
00258 walkWithBall,
00259 gt2004mode,
00260 numOfWalkType
00261 };
00262
00263 WalkRequest():walkType(normal) {}
00264
00265
00266 WalkType walkType;
00267
00268
00269 Pose2D walkParams;
00270
00271
00272 static const char* getWalkTypeName(WalkType id)
00273 {
00274 switch (id)
00275 {
00276 case normal: return "normal";
00277 case upsideDown: return "upsideDown";
00278 case turnWithBall: return "turnWithBall";
00279 case turnKick: return "turnKick";
00280 case dash: return "dash";
00281 case debug: return "debug";
00282 case boost: return "boost";
00283 case walkWithBall: return "walkWithBall";
00284 case gt2004mode: return "gt2004mode";
00285 default: return "Unknown motion name, please edit MotionRequest::getWalkTypeName";
00286 }
00287 }
00288 };
00289
00290 class TailRequest{
00291 public:
00292 enum TailRequestID
00293 {
00294 wagHorizontal,
00295 wagVertical,
00296 wagLeftRightHorizontal,
00297 wagLeftRightVertical,
00298 wagUpDownLeft,
00299 wagUpDownRight,
00300 stayAsForced,
00301 stayAsForcedPan,
00302 stayAsForcedTilt,
00303 tailFollowsHead,
00304 tailParallelToGround,
00305 noTailWag,
00306 wagHorizontalFast,
00307 wagVerticalFast,
00308 twoPositionSwitchVertical,
00309 twoPositionSwitchHorizontal,
00310 threePositionSwitchVertical,
00311 threePositionSwitchHorizontal,
00312 fourPositionSwitchUpDownLeftRight,
00313 fourPositionSwitchCorners,
00314 fivePositionSwitch,
00315 eightPositionSwitch,
00316 tailLeftTop, tailCenterTop, tailRightTop,
00317 tailLeftCenter, tailCenterCenter, tailRightCenter,
00318 tailLeftBottom, tailCenterBottom, tailRightBottom,
00319 numOfTailRequests
00320 };
00321
00322 TailRequest():tailRequestID(wagHorizontal){}
00323
00324
00325 TailRequestID tailRequestID;
00326
00327
00328
00329
00330
00331 static const char* getTailRequestIDName(TailRequestID id)
00332 {
00333 switch (id)
00334 {
00335 case wagHorizontal: return "wagHorizontal";
00336 case wagVertical: return "wagVertical";
00337 case wagLeftRightHorizontal: return "wagLeftRightHorizontal";
00338 case wagLeftRightVertical: return "wagLeftRightVertical";
00339 case wagUpDownLeft: return "wagUpDownLeft";
00340 case wagUpDownRight: return "wagUpDownRight";
00341 case stayAsForced: return "stayAsForced";
00342 case stayAsForcedPan: return "stayAsForcedPan";
00343 case stayAsForcedTilt: return "stayAsForcedTilt";
00344 case tailFollowsHead: return "tailFollowsHead";
00345 case tailParallelToGround: return "tailParallelToGround";
00346 case noTailWag: return "noTailWag";
00347 case wagHorizontalFast: return "wagHorizontalFast";
00348 case wagVerticalFast: return "wagVerticalFast";
00349 case twoPositionSwitchVertical: return "twoPositionSwitchVertical";
00350 case twoPositionSwitchHorizontal: return "twoPositionSwitchHorizontal";
00351 case threePositionSwitchVertical: return "threePositionSwitchVertical";
00352 case threePositionSwitchHorizontal: return "threePositionSwitchHorizontal";
00353 case fourPositionSwitchUpDownLeftRight: return "fourPositionSwitchUpDownLeftRight";
00354 case fourPositionSwitchCorners: return "fourPositionSwitchCorners";
00355 case fivePositionSwitch: return "fivePositionSwitch";
00356 case eightPositionSwitch: return "eightPositionSwitch";
00357 case tailLeftTop: return "tailLeftTop";
00358 case tailCenterTop: return "tailCenterTop";
00359 case tailRightTop: return "tailRightTop";
00360 case tailLeftCenter: return "tailLeftCenter";
00361 case tailCenterCenter: return "tailCenterCenter";
00362 case tailRightCenter: return "tailRightCenter";
00363 case tailLeftBottom: return "tailLeftBottom";
00364 case tailCenterBottom: return "tailCenterBottom";
00365 case tailRightBottom: return "tailRightBottom";
00366
00367 default: return "Unknown tail request, please edit MotionRequest::getTailRequestName";
00368 }
00369 }
00370
00371 };
00372
00373
00374
00375 class MotionRequest : public Streamable
00376 {
00377 public:
00378 virtual void serialize( In* in, Out* out)
00379 {
00380 STREAM_REGISTER_BEGIN( );
00381 STREAM( frameNumber);
00382 STREAM_ENUM( motionType, numOfMotion, MotionRequest::getMotionName);
00383 STREAM_ENUM( walkRequest.walkType, walkRequest.numOfWalkType, WalkRequest::getWalkTypeName);
00384 STREAM( walkRequest.walkParams);
00385 STREAM_ENUM( specialActionRequest.specialActionType, specialActionRequest.numOfSpecialAction, SpecialActionRequest::getSpecialActionIDName);
00386 STREAM_ENUM( tailRequest.tailRequestID, tailRequest.numOfTailRequests, TailRequest::getTailRequestIDName);
00387 STREAM( stabilize);
00388 STREAM( padding);
00389 STREAM_REGISTER_FINISH();
00390 }
00391
00392 unsigned long frameNumber;
00393
00394 void setFrameNumber(unsigned long frameNumber) {this->frameNumber = frameNumber;}
00395
00396
00397
00398 enum MotionID {
00399 stand,
00400 walk,
00401 specialAction,
00402 getup,
00403 playDead,
00404 numOfMotion
00405 };
00406
00407
00408 static const char* getMotionName(MotionID id)
00409 {
00410 switch (id)
00411 {
00412 case playDead: return "playDead";
00413 case stand: return "stand";
00414 case walk: return "walk";
00415 case specialAction: return "specialAction";
00416 case getup: return "getup";
00417
00418 default: return "Unknown motion name, please edit MotionRequest::getMotionName";
00419 }
00420 }
00421
00422
00423 MotionID motionType;
00424
00425
00426 SpecialActionRequest specialActionRequest;
00427
00428 TailRequest tailRequest;
00429
00430 WalkRequest walkRequest;
00431
00432
00433
00434
00435
00436
00437 MotionRequest():motionType(playDead),stabilize(false),updateRP(true),frameNumber(0) {}
00438
00439
00440 bool operator==(const MotionRequest& other) const
00441 {
00442 switch (motionType)
00443 {
00444 case stand:
00445 case getup:
00446 default:
00447 return (
00448 motionType == other.motionType &&
00449 stabilize == other.stabilize);
00450 case walk:
00451 return (walkRequest.walkParams == other.walkRequest.walkParams &&
00452 stabilize == other.stabilize &&
00453 motionType == other.motionType &&
00454 walkRequest.walkType == other.walkRequest.walkType);
00455 case specialAction:
00456 return (
00457 stabilize == other.stabilize &&
00458 motionType == other.motionType &&
00459 specialActionRequest.specialActionType == other.specialActionRequest.specialActionType);
00460 }
00461 }
00462
00463
00464 void operator=(const MotionRequest& other);
00465
00466
00467 bool stabilize;
00468
00469
00470
00471 bool updateRP;
00472
00473
00474 const char* getMotionName() const {return getMotionName(motionType);};
00475
00476
00477 const char* getSpecialActionName() const
00478 {
00479 if (motionType == specialAction)
00480 return specialActionRequest.getSpecialActionIDName(specialActionRequest.specialActionType);
00481 else
00482 return "";
00483 };
00484
00485
00486 const char* getWalkTypeName() const
00487 {
00488 if (motionType == walk)
00489 return walkRequest.getWalkTypeName(walkRequest.walkType);
00490 else
00491 return "";
00492 }
00493
00494
00495
00496
00497
00498 void printOut(char* destination) const;
00499
00500 int padding;
00501 };
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519 #endif // __MOTIONREQUEST_H__