Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Modules/MotionControl/GT2004MotionControl.cpp

Go to the documentation of this file.
00001 /**
00002 * @file GT2004MotionControl.cpp
00003 * 
00004 * Implementation of class GT2004MotionControl.
00005 *
00006 * @author Max Risler
00007 */
00008 
00009 #include "GT2004MotionControl.h"
00010 
00011 #include "Modules/WalkingEngine/WalkingEngineSelector.h"
00012 #include "Modules/WalkingEngine/InvKinWalkingEngine.h"
00013 #include "Modules/WalkingEngine/InvKinWalkingParameterSets.h"
00014 #include "Modules/SpecialActions/GT2003MotionNetSpecialActions/GT2003MotionNetSpecialActions.h"
00015 
00016 #include "Platform/SystemCall.h"
00017 #include "Tools/Actorics/Kinematics.h"
00018 #include "Tools/Debugging/Debugging.h"
00019 #include "Tools/Debugging/GenericDebugData.h"
00020 #include "Tools/RobotConfiguration.h"
00021 
00022 GT2004MotionControl::GT2004MotionControl(ModuleHandler& moduleHandler,
00023                                            const MotionControlInterfaces& interfaces) 
00024                                            :MotionControl(interfaces),
00025                                            moduleHandler(moduleHandler),
00026                                            changeOfMotionControlStatePossible(true),
00027                                            lastMotionType(MotionRequest::playDead),
00028                                            motionControlState(GT2004MotionControl::playDead)
00029 {
00030   // create an uninitialised motion request to set startup motion -- something like getup (see MotionRequest-Constructor)
00031   MotionRequest defaultRequest;
00032   // currentMotionType = lastMotionType = defaultRequest.motionType;
00033   lastHeadTilt = lastHeadPan = lastHeadRoll = 0;
00034 
00035   WalkingEngineInterfaces walkingEngineInterfaces
00036     (sensorDataBuffer, invKinWalkingParameters, gt2004Parameters, walkParameterTimeStamp, receivedNewSensorData, lastMotionType, pidData, odometryData, motionInfo);
00037 
00038   // create the InvKinWalking engine as only one instance is created
00039   // and used by different walk type with different parameter sets
00040   pInvKinWalkingEngine = new InvKinWalkingEngine(walkingEngineInterfaces);
00041   
00042   
00043   pWalkingEngine[WalkRequest::normal] = 
00044     new WalkingEngineSelector(moduleHandler, SolutionRequest::walkingEngineNormal,
00045     walkingEngineInterfaces, pInvKinWalkingEngine);
00046   
00047   pWalkingEngine[WalkRequest::upsideDown] = 
00048     new ParamInvKinWalkingEngine(new UpsideDownWalkingParameters, pInvKinWalkingEngine);
00049   
00050   pWalkingEngine[WalkRequest::turnWithBall] = 
00051     new ParamInvKinWalkingEngine(new TurnWithBallWalkingParameters, pInvKinWalkingEngine);
00052   
00053   pWalkingEngine[WalkRequest::turnKick] = 
00054     new ParamInvKinWalkingEngine(new TurnWithBallWalkingParameters, pInvKinWalkingEngine);
00055   
00056   pWalkingEngine[WalkRequest::dash] =
00057     new BB2004InvKinWalkingEngine(pInvKinWalkingEngine);
00058   
00059   pWalkingEngine[WalkRequest::debug] = 
00060     new ParamInvKinWalkingEngine(new ERS7EvolveWalkingParameters, pInvKinWalkingEngine);
00061   
00062   SpecialActionsInterfaces specialActionsInterfaces(motionRequest,lastMotionType, 
00063     pidData, odometryData, motionInfo);
00064   pSpecialActions = new GT2003MotionNetSpecialActions(specialActionsInterfaces);
00065   
00066   GetupEngineInterfaces getupEngineInterfaces(lastMotionType, sensorDataBuffer, motionRequest, bodyPosture, pidData, odometryData,
00067     motionInfo);
00068   pGetupEngine = new GetupEngineSelector(moduleHandler,getupEngineInterfaces);
00069   
00070   wakingUp = false;
00071   // lastSpecialActionWasPlayDead = false;
00072 }
00073 
00074 GT2004MotionControl::~GT2004MotionControl()
00075 {
00076   delete pWalkingEngine[WalkRequest::normal];
00077   delete pWalkingEngine[WalkRequest::upsideDown];
00078   delete pWalkingEngine[WalkRequest::turnWithBall];
00079   delete pWalkingEngine[WalkRequest::turnKick];
00080   delete pWalkingEngine[WalkRequest::dash];
00081   delete pWalkingEngine[WalkRequest::debug];
00082   delete pSpecialActions;
00083   delete pGetupEngine;
00084   delete pInvKinWalkingEngine;
00085   
00086   moduleHandler.setModuleSelector(SolutionRequest::walkingEngineNormal,0);
00087   moduleHandler.setModuleSelector(SolutionRequest::getupEngine,0);
00088 }
00089 
00090 void GT2004MotionControl::determineMotionControlState()
00091 {
00092   switch(motionControlState)
00093   {
00094   case GT2004MotionControl::playDead:
00095     {
00096       if(motionRequest.motionType != MotionRequest::playDead)
00097       {
00098         motionControlState = GT2004MotionControl::wakeUp;
00099       }
00100       return;
00101     }
00102   case GT2004MotionControl::getup:
00103     if(changeOfMotionControlStatePossible)
00104     {
00105         setMotionControlState();
00106       
00107     }
00108     return;
00109   case GT2004MotionControl::wakeUp:
00110     if(changeOfMotionControlStatePossible)
00111     {
00112       setMotionControlState();
00113       
00114     }
00115     return;
00116   case GT2004MotionControl::stand:
00117     if(changeOfMotionControlStatePossible)
00118     {
00119       setMotionControlState();
00120     }
00121     return;
00122   case GT2004MotionControl::specialAction:
00123     if(changeOfMotionControlStatePossible)
00124     {
00125       setMotionControlState();
00126     }
00127     return;
00128   case GT2004MotionControl::walk:
00129     if(
00130       changeOfMotionControlStatePossible && 
00131       ((motionRequest.motionType != MotionRequest::specialAction || 
00132         pSpecialActions->specialActionIsExecutableInWalkingCycle(motionRequest.specialActionRequest.specialActionType, positionInWalkCycle))
00133       ))
00134     {
00135       setMotionControlState();
00136     }
00137     return;
00138   }
00139 }
00140 
00141 void GT2004MotionControl::setMotionControlState()
00142 {
00143   switch(motionRequest.motionType)
00144   {
00145   case MotionRequest::playDead:
00146     motionControlState = GT2004MotionControl::playDead;
00147     return;
00148   case MotionRequest::getup:
00149     motionControlState = GT2004MotionControl::getup;
00150     return;
00151   case MotionRequest::stand:
00152     motionControlState = GT2004MotionControl::stand;
00153     return;
00154   case MotionRequest::specialAction:
00155     motionControlState = GT2004MotionControl::specialAction;
00156     return;
00157   case MotionRequest::walk:
00158     motionControlState = GT2004MotionControl::walk;
00159     return;
00160   }
00161 }
00162 void GT2004MotionControl::execute()
00163 {
00164   for (int i = 0; i < jointDataBufferNumOfFrames; i++)
00165   {
00166   
00167     JointData &currentFrame = jointDataBuffer.frame[i];
00168 
00169     // remember some variables
00170     if(motionRequest.motionType == MotionRequest::walk)
00171       latestWalkRequest = motionRequest.walkRequest;
00172     else if(motionRequest.motionType == MotionRequest::specialAction)
00173       latestSpecialActionRequest = motionRequest.specialActionRequest;
00174 
00175     
00176     // determine current state for Motion Control
00177     determineMotionControlState();
00178     
00179     /* state machine for current action*/
00180     switch(motionControlState)
00181     {
00182     case GT2004MotionControl::playDead:
00183       {
00184         changeOfMotionControlStatePossible = true;
00185         for(int i = 0; i<JointData::numOfJoint; ++i)
00186         {
00187           pidData.p[i]=0;pidData.i[i]=0;pidData.d[i]=0;
00188         }
00189         motionInfo.executedMotionRequest.motionType = MotionRequest::playDead;
00190         lastMotionType = MotionRequest::playDead;
00191         break;
00192       }
00193     case GT2004MotionControl::wakeUp:
00194       {
00195         changeOfMotionControlStatePossible
00196           = !wakeUpEngine.execute(frameNumber, sensorDataBuffer.frame[0], currentFrame, pidData);
00197         lastMotionType = MotionRequest::playDead;
00198         break;
00199       }
00200       case GT2004MotionControl::getup:
00201         {
00202           changeOfMotionControlStatePossible = !pGetupEngine->executeParameterized(currentFrame);
00203           lastMotionType = MotionRequest::getup;
00204           break;
00205         }
00206     case GT2004MotionControl::stand:
00207       {
00208         WalkRequest standRequest;
00209         standRequest.walkType = WalkRequest::normal;
00210         standRequest.walkParams = Pose2D(0,0,0);
00211         changeOfMotionControlStatePossible 
00212           = !pWalkingEngine[WalkRequest::normal]->executeParameterized(currentFrame,standRequest,0);
00213         motionInfo.executedMotionRequest.motionType = MotionRequest::stand;
00214         positionInWalkCycle = motionInfo.positionInWalkCycle;
00215         lastMotionType = MotionRequest::stand;
00216         break;
00217       }
00218       
00219     case GT2004MotionControl::specialAction:
00220       changeOfMotionControlStatePossible 
00221         = !pSpecialActions->executeParameterized(latestSpecialActionRequest, currentFrame);
00222       lastMotionType = MotionRequest::specialAction;
00223       break;
00224       
00225     case GT2004MotionControl::walk:
00226       {
00227         changeOfMotionControlStatePossible 
00228           = !pWalkingEngine[latestWalkRequest.walkType]->executeParameterized(currentFrame, latestWalkRequest, positionInWalkCycle);
00229         positionInWalkCycle = motionInfo.positionInWalkCycle;
00230         lastMotionType = MotionRequest::walk;
00231         break;
00232       }
00233     }
00234 
00235     if(motionControlState != GT2004MotionControl::walk){
00236       positionInWalkCycle = 0;
00237     }
00238     
00239     /* end of state machine*/
00240     
00241     headIsBlockedBySpecialActionOrWalk = 
00242       (
00243       currentFrame.data[JointData::neckTilt] != jointDataInvalidValue &&
00244       currentFrame.data[JointData::headPan] != jointDataInvalidValue &&
00245       currentFrame.data[JointData::headTilt] != jointDataInvalidValue 
00246       );
00247     
00248     // execute HeadMotionRequest (smoothed)
00249     const long maxdiff=50000; //(~2pi/s)
00250     long diff;
00251     if (currentFrame.data[JointData::neckTilt] == jointDataInvalidValue)
00252     {
00253       diff=headMotionRequest.tilt-lastHeadTilt;
00254       if (diff<-maxdiff)
00255       {
00256         currentFrame.data[JointData::neckTilt] = lastHeadTilt-maxdiff;
00257       }
00258       else if (diff<maxdiff)
00259       {
00260         currentFrame.data[JointData::neckTilt] = headMotionRequest.tilt;
00261       }
00262       else
00263       {
00264         currentFrame.data[JointData::neckTilt] = lastHeadTilt+maxdiff;
00265       }
00266     }
00267     if (currentFrame.data[JointData::headPan] == jointDataInvalidValue)
00268     {
00269       diff=headMotionRequest.pan-lastHeadPan;
00270       if (diff<-maxdiff)
00271       {
00272         currentFrame.data[JointData::headPan] = lastHeadPan-maxdiff;
00273       }
00274       else if (diff<maxdiff)
00275       {
00276         currentFrame.data[JointData::headPan] = headMotionRequest.pan;
00277       }
00278       else
00279       {
00280         currentFrame.data[JointData::headPan] = lastHeadPan+maxdiff;
00281       }
00282     }
00283     if (currentFrame.data[JointData::headTilt] == jointDataInvalidValue)
00284     {
00285       diff=headMotionRequest.roll-lastHeadRoll;
00286       if (diff<-maxdiff)
00287       {
00288         currentFrame.data[JointData::headTilt] = lastHeadRoll-maxdiff;
00289       }
00290       else if (diff<maxdiff)
00291       {
00292         currentFrame.data[JointData::headTilt] = headMotionRequest.roll;
00293       }
00294       else
00295       {
00296         currentFrame.data[JointData::headTilt] = lastHeadRoll+maxdiff;
00297       }
00298     }
00299     if (currentFrame.data[JointData::mouth] == jointDataInvalidValue)
00300     {
00301       currentFrame.data[JointData::mouth] = headMotionRequest.mouth;
00302     }
00303     
00304     lastHeadTilt=currentFrame.data[JointData::neckTilt];
00305     lastHeadPan =currentFrame.data[JointData::headPan];
00306     lastHeadRoll=currentFrame.data[JointData::headTilt];
00307     
00308     // the obgligatory GT tail wag
00309     /** @todo:
00310     wagTail(sensorDataBuffer.lastFrame(), currentFrame);
00311     */
00312     
00313     // whether or not stabilize does something is determined in the method.
00314     // it is called because of averaging that needs to be done continously!!
00315     stabilize(lastMotionType, motionRequest, currentFrame, odometryData, sensorDataBuffer);
00316   }
00317 }
00318 
00319 void GT2004MotionControl::wagTail(
00320                                    const MotionRequest& motionRequest,
00321                                    const SensorData& sensorData,
00322                                    JointData& jointData
00323                                    )
00324 {
00325   if ((jointData.data[JointData::tailPan] != jointDataInvalidValue) ||
00326     (jointData.data[JointData::tailTilt] != jointDataInvalidValue))
00327     return;
00328   
00329   switch (motionRequest.tailRequest.tailRequestID)
00330   {
00331   case TailRequest::wagHorizontal:
00332     {
00333       int framesPerPeriod = 200;
00334       tailCount %= framesPerPeriod;
00335       tailCount++;
00336       jointData.data[JointData::tailPan] = toMicroRad(jointLimitTailPanP * sin(tailCount * 2 * pi / framesPerPeriod));
00337       jointData.data[JointData::tailTilt] = toMicroRad(jointLimitTailTiltN);
00338     }
00339     break;
00340   case TailRequest::wagLeftRightHorizontal:
00341     {
00342       int framesPerPeriod = 125;
00343       tailCount %= framesPerPeriod;
00344       tailCount++;
00345       jointData.data[JointData::tailPan] = toMicroRad(jointLimitTailPanP * sin(tailCount * 2 * pi / framesPerPeriod));
00346       jointData.data[JointData::tailTilt] = toMicroRad(jointLimitTailTiltN);
00347     }
00348     break;
00349   case TailRequest::wagLeftRightVertical:
00350     {
00351       int framesPerPeriod = 125;
00352       tailCount %= framesPerPeriod;
00353       tailCount++;
00354       jointData.data[JointData::tailPan] = toMicroRad(jointLimitTailPanP * sin(tailCount * 2 * pi / framesPerPeriod));
00355       jointData.data[JointData::tailTilt] = toMicroRad(jointLimitTailTiltN);
00356     }
00357     break;
00358   case TailRequest::wagHorizontalFast:
00359     {
00360       int framesPerPeriod = 30;
00361       tailCount %= framesPerPeriod;
00362       tailCount++;
00363       jointData.data[JointData::tailPan] = toMicroRad((jointLimitTailPanP/2) * sgn(sin(tailCount * 2 * pi / framesPerPeriod)));
00364       jointData.data[JointData::tailTilt] = toMicroRad(jointLimitTailTiltN);
00365     }
00366     break;
00367   case TailRequest::wagVertical:
00368     {
00369       int framesPerPeriod = 125;
00370       tailCount %= framesPerPeriod;
00371       tailCount++;
00372       jointData.data[JointData::tailTilt] = 
00373         toMicroRad(
00374         (jointLimitTailTiltP + jointLimitTailTiltN) / 2 +
00375         (jointLimitTailTiltP - jointLimitTailTiltN) / 2 * sin(tailCount * 2 * pi / framesPerPeriod)
00376         );
00377       jointData.data[JointData::tailPan] = 0;
00378     }
00379     break;
00380   case TailRequest::wagUpDownLeft:
00381     {
00382       int framesPerPeriod = 125;
00383       tailCount %= framesPerPeriod;
00384       tailCount++;
00385       jointData.data[JointData::tailTilt] = 
00386         toMicroRad(
00387         (jointLimitTailTiltP + jointLimitTailTiltN) / 2 +
00388         (jointLimitTailTiltP - jointLimitTailTiltN) / 2 * sin(tailCount * 2 * pi / framesPerPeriod)
00389         );
00390       jointData.data[JointData::tailPan] = toMicroRad(jointLimitTailPanN);
00391     }
00392     break;
00393   case TailRequest::wagUpDownRight:
00394     {
00395       int framesPerPeriod = 125;
00396       tailCount %= framesPerPeriod;
00397       tailCount++;
00398       jointData.data[JointData::tailTilt] = 
00399         toMicroRad(
00400         (jointLimitTailTiltP + jointLimitTailTiltN) / 2 +
00401         (jointLimitTailTiltP - jointLimitTailTiltN) / 2 * sin(tailCount * 2 * pi / framesPerPeriod)
00402         );
00403       jointData.data[JointData::tailPan] = toMicroRad(jointLimitTailPanP);
00404     }
00405     break;
00406   case TailRequest::wagVerticalFast:
00407     {
00408       tailCount &= 7;
00409       int j=tailCount++;
00410       if (j>3) j = 8-j;
00411       jointData.data[JointData::tailTilt] = 160000*(j - 2);
00412       jointData.data[JointData::tailPan] = 0;
00413     }
00414     break;
00415   case TailRequest::stayAsForced:
00416     jointData.data[JointData::tailTilt] = sensorData.data[SensorData::tailTilt];
00417     jointData.data[JointData::tailPan] = sensorData.data[SensorData::tailPan];
00418     break;
00419   case TailRequest::stayAsForcedPan:
00420     jointData.data[JointData::tailTilt] = toMicroRad(jointLimitTailTiltP);
00421     jointData.data[JointData::tailPan] = sensorData.data[SensorData::tailPan];
00422     break;
00423   case TailRequest::stayAsForcedTilt:
00424     jointData.data[JointData::tailTilt] = sensorData.data[SensorData::tailTilt];
00425     jointData.data[JointData::tailPan] = 0;
00426     break;
00427   case TailRequest::tailFollowsHead:
00428     jointData.data[JointData::tailTilt] = sensorData.data[SensorData::neckTilt];
00429     jointData.data[JointData::tailPan] = -sensorData.data[SensorData::headPan];
00430     break;
00431   case TailRequest::tailParallelToGround:
00432     jointData.data[JointData::tailTilt] = 0;
00433     jointData.data[JointData::tailPan] = 0;
00434     break;
00435   case TailRequest::noTailWag:
00436     jointData.data[JointData::tailTilt] = 0;
00437     jointData.data[JointData::tailPan] = 0;
00438     break;
00439   case TailRequest::twoPositionSwitchVertical:
00440     jointData.data[JointData::tailPan] = 0;
00441     if (sensorData.data[SensorData::tailTilt] > 0)
00442       jointData.data[JointData::tailTilt] = 380000;
00443     else
00444       jointData.data[JointData::tailTilt] = -380000;
00445     break;
00446   case TailRequest::twoPositionSwitchHorizontal:
00447     jointData.data[JointData::tailTilt] = 0;
00448     if (sensorData.data[SensorData::tailPan] > 0)
00449       jointData.data[JointData::tailPan] = 380000;
00450     else
00451       jointData.data[JointData::tailPan] = -380000;
00452     break;
00453   case TailRequest::threePositionSwitchVertical:
00454     jointData.data[JointData::tailPan] = 0;
00455     if (sensorData.data[SensorData::tailTilt] > 130000)
00456       jointData.data[JointData::tailTilt] = 380000;
00457     else if(sensorData.data[SensorData::tailTilt] > -130000)
00458       jointData.data[JointData::tailTilt] = 0;
00459     else
00460       jointData.data[JointData::tailTilt] = -380000;
00461     break;
00462   case TailRequest::threePositionSwitchHorizontal:
00463     jointData.data[JointData::tailTilt] = 0;
00464     if (sensorData.data[SensorData::tailPan] > 130000)
00465       jointData.data[JointData::tailPan] = 380000;
00466     else if(sensorData.data[SensorData::tailPan] > -130000)
00467       jointData.data[JointData::tailPan] = 0;
00468     else
00469       jointData.data[JointData::tailPan] = -380000;
00470     break;
00471   case TailRequest::fourPositionSwitchUpDownLeftRight:
00472     if(sensorData.data[SensorData::tailPan] > sensorData.data[SensorData::tailTilt])
00473     {
00474       if(sensorData.data[SensorData::tailPan] > -sensorData.data[SensorData::tailTilt])
00475       {
00476         //right
00477         jointData.data[JointData::tailPan] = 380000;
00478         jointData.data[JointData::tailTilt] = 0;
00479       }
00480       else
00481       {
00482         //bottom
00483         jointData.data[JointData::tailPan] = 0;
00484         jointData.data[JointData::tailTilt] = -380000;
00485       }
00486     }
00487     else
00488     {
00489       if(sensorData.data[SensorData::tailPan] > -sensorData.data[SensorData::tailTilt])
00490       {
00491         //top
00492         jointData.data[JointData::tailPan] = 0;
00493         jointData.data[JointData::tailTilt] = 380000;
00494       }
00495       else
00496       {
00497         //left
00498         jointData.data[JointData::tailPan] = -380000;
00499         jointData.data[JointData::tailTilt] = 0;
00500       }
00501     }
00502     break;
00503   case TailRequest::fourPositionSwitchCorners:
00504     if (sensorData.data[SensorData::tailTilt] > 0)
00505       jointData.data[JointData::tailTilt] = 380000;
00506     else
00507       jointData.data[JointData::tailTilt] = -380000;
00508 
00509     if (sensorData.data[SensorData::tailPan] > 0)
00510       jointData.data[JointData::tailPan] = 380000;
00511     else
00512       jointData.data[JointData::tailPan] = -380000;
00513     break;
00514   case TailRequest::fivePositionSwitch:
00515     if(sensorData.data[SensorData::tailTilt] > -130000 &&
00516        sensorData.data[SensorData::tailTilt] < 130000 &&
00517        sensorData.data[SensorData::tailPan] > -130000 &&
00518        sensorData.data[SensorData::tailPan] < 130000)
00519     {
00520       jointData.data[JointData::tailPan] = 0;
00521       jointData.data[JointData::tailTilt] = 0;
00522     }
00523     else
00524     {
00525       if (sensorData.data[SensorData::tailTilt] > 0)
00526         jointData.data[JointData::tailTilt] = 380000;
00527       else
00528         jointData.data[JointData::tailTilt] = -380000;
00529 
00530       if (sensorData.data[SensorData::tailPan] > 0)
00531         jointData.data[JointData::tailPan] = 380000;
00532       else
00533         jointData.data[JointData::tailPan] = -380000;
00534     }
00535     break;
00536   case TailRequest::eightPositionSwitch:
00537     // vertical
00538     jointData.data[JointData::tailPan] = 0;
00539     if (sensorData.data[SensorData::tailTilt] > 130000)
00540     {
00541       jointData.data[JointData::tailTilt] = 380000;
00542       if (sensorData.data[SensorData::tailPan] > 130000)
00543         jointData.data[JointData::tailPan] = 380000;
00544       else if(sensorData.data[SensorData::tailPan] > -130000)
00545         jointData.data[JointData::tailPan] = 0;
00546       else
00547         jointData.data[JointData::tailPan] = -380000;
00548     }
00549     else if(sensorData.data[SensorData::tailTilt] > -130000)
00550     {
00551       jointData.data[JointData::tailTilt] = 0;
00552       if (sensorData.data[SensorData::tailPan] > 130000)
00553         jointData.data[JointData::tailPan] = 380000;
00554       else if(sensorData.data[SensorData::tailPan] > -130000)
00555       {
00556         // if the tail is in the center it is set to the top
00557         jointData.data[JointData::tailPan] = 0;
00558         jointData.data[JointData::tailTilt] = 380000;
00559       }
00560       else
00561         jointData.data[JointData::tailPan] = -380000;
00562     }
00563     else
00564     {
00565       jointData.data[JointData::tailTilt] = -380000;
00566       if (sensorData.data[SensorData::tailPan] > 130000)
00567         jointData.data[JointData::tailPan] = 380000;
00568       else if(sensorData.data[SensorData::tailPan] > -130000)
00569         jointData.data[JointData::tailPan] = 0;
00570       else
00571         jointData.data[JointData::tailPan] = -380000;
00572     }
00573     break;
00574   case TailRequest::tailLeftTop:
00575     jointData.data[JointData::tailPan] = -380000;
00576     jointData.data[JointData::tailTilt] = 380000;
00577     break;
00578   case TailRequest::tailCenterTop:
00579     jointData.data[JointData::tailPan] =       0;
00580     jointData.data[JointData::tailTilt] = 380000;
00581     break;
00582   case TailRequest::tailRightTop:
00583     jointData.data[JointData::tailPan] =  380000;
00584     jointData.data[JointData::tailTilt] = 380000;
00585     break;
00586   case TailRequest::tailLeftCenter:
00587     jointData.data[JointData::tailPan] = -380000;
00588     jointData.data[JointData::tailTilt] =      0;
00589     break;
00590   case TailRequest::tailCenterCenter:
00591     jointData.data[JointData::tailPan] =       0;
00592     jointData.data[JointData::tailTilt] =      0;
00593     break;
00594   case TailRequest::tailRightCenter:
00595     jointData.data[JointData::tailPan] =  380000;
00596     jointData.data[JointData::tailTilt] =      0;
00597     break;
00598   case TailRequest::tailLeftBottom:
00599     jointData.data[JointData::tailPan] = -380000;
00600     jointData.data[JointData::tailTilt] = -380000;
00601     break;
00602   case TailRequest::tailCenterBottom:
00603     jointData.data[JointData::tailPan] =        0;
00604     jointData.data[JointData::tailTilt] = -380000;
00605     break;
00606   case TailRequest::tailRightBottom:
00607     jointData.data[JointData::tailPan] = 380000;
00608     jointData.data[JointData::tailTilt] = -380000;
00609     break;
00610   }
00611 }
00612 
00613 bool GT2004MotionControl::handleMessage(InMessage& message)
00614 { 
00615   switch(message.getMessageID())
00616   {
00617   case idGenericDebugData:
00618     {
00619       GenericDebugData d;
00620       message.bin >> d;
00621       if(d.id == GenericDebugData::motionStabilizer)
00622       {
00623         OUTPUT(idText,text,"generic debug message (motionStabilizer) handled by module motionStabilizer");
00624         
00625         xFore.setWeightP(d.data[0]);
00626         xHind.setWeightP(d.data[0]);
00627         yLeft.setWeightP(d.data[1]);
00628         yRight.setWeightP(d.data[1]);
00629         
00630         stabilizerScale = d.data[2];
00631       }
00632     }
00633     break;
00634   case idMotionNet:
00635     return pSpecialActions->handleMessage(message);
00636   case idOdometryScale:
00637     return pWalkingEngine[WalkRequest::normal]->handleMessage(message);
00638   case idInvKinWalkingParameters:
00639     return pWalkingEngine[WalkRequest::debug]->handleMessage(message);
00640   }
00641   return false;
00642 }
00643 
00644 
00645 /*
00646 * Change log :
00647 * 
00648 * $Log: GT2004MotionControl.cpp,v $
00649 * Revision 1.1  2004/07/10 00:18:29  spranger
00650 * renamed (readded) for coderelease
00651 *
00652 * Revision 1.20  2004/06/16 18:11:30  spranger
00653 * bugfix
00654 *
00655 * Revision 1.19  2004/06/16 16:52:28  risler
00656 * no more change to getup before wakeup is finished
00657 *
00658 * Revision 1.18  2004/06/16 16:15:52  spranger
00659 * debug-stuff added
00660 *
00661 * Revision 1.17  2004/06/14 16:55:10  juengel
00662 * Removed some WalkingEngineParameterSets.
00663 *
00664 * Revision 1.16  2004/06/14 15:28:36  spranger
00665 * removed some more debug-stuff
00666 *
00667 * Revision 1.15  2004/06/14 15:18:47  spranger
00668 * removed some debug-stuff
00669 *
00670 * Revision 1.14  2004/06/14 15:05:52  spranger
00671 * redone statemachine, changed some interfaces
00672 *
00673 * Revision 1.13  2004/06/08 15:29:09  juengel
00674 * Added some OUTPUTs.
00675 *
00676 * Revision 1.12  2004/06/07 18:52:21  spranger
00677 * added positionInWalkCycle, added functionality for preserving positionInwalkCycle and WalkEngine-Control
00678 *
00679 * Revision 1.11  2004/06/05 10:02:31  roefer
00680 * Memory leak closed
00681 *
00682 * Revision 1.10  2004/06/04 16:36:43  juengel
00683 * Added walkType turn-kick
00684 *
00685 * Revision 1.9  2004/06/04 13:46:10  dueffert
00686 * unused turnwithball walk types removed
00687 *
00688 * Revision 1.8  2004/06/02 17:19:31  spranger
00689 * cleanup
00690 *
00691 * Revision 1.7  2004/05/27 18:20:49  spranger
00692 * motionControl cleaned up
00693 *
00694 * Revision 1.6  2004/05/27 17:13:37  jhoffman
00695 * - renaming: tilt1 -> neckTilt,  pan -> headPan,  tilt2 -> headTilt
00696 * - clipping included for setJoints
00697 * - removed some microrad/rad-bugs
00698 * - bodyPosture constructor and "=" operator fixed
00699 *
00700 * Revision 1.5  2004/05/27 09:29:28  loetzsch
00701 * removed executedMotionRequest from Interfaces
00702 *
00703 * Revision 1.4  2004/05/27 09:13:04  loetzsch
00704 * removed executedMotionRequest from Interfaces
00705 *
00706 * Revision 1.3  2004/05/26 20:17:47  juengel
00707 * Removed RobotVerticesBuffer.
00708 * Added "receivedNewSensorData".
00709 *
00710 * Revision 1.2  2004/05/26 16:10:24  dueffert
00711 * better data types used
00712 *
00713 * Revision 1.1.1.1  2004/05/22 17:20:36  cvsadm
00714 * created new repository GT2004_WM
00715 *
00716 * Revision 1.27  2004/05/22 14:28:56  juengel
00717 * Activated WakeUpEngine
00718 *
00719 * Revision 1.26  2004/05/19 15:26:58  juengel
00720 * WakeUpEngine
00721 *
00722 * Revision 1.25  2004/05/19 13:33:21  heinze
00723 * added conditions for WakeUpEngine
00724 *
00725 * Revision 1.24  2004/05/03 09:51:18  heinze
00726 * Prepared WakeUpEngine.
00727 *
00728 * Revision 1.23  2004/04/08 15:33:06  wachter
00729 * GT04 checkin of Microsoft-Hellounds
00730 *
00731 * Revision 1.22  2004/04/07 12:28:59  risler
00732 * ddd checkin after go04 - first part
00733 *
00734 * Revision 1.21  2004/03/29 17:59:29  dueffert
00735 * sorry
00736 *
00737 * Revision 1.20  2004/03/29 15:24:39  dueffert
00738 * new turn parameterset
00739 *
00740 * Revision 1.19  2004/03/26 21:29:44  roefer
00741 * Headstate handling improved
00742 *
00743 * Revision 1.18  2004/03/26 10:01:47  dueffert
00744 * warning removed
00745 *
00746 * Revision 1.17  2004/03/25 09:11:57  jhoffman
00747 * breathing motion added (robot opens/closes mouth)
00748 *
00749 * Revision 1.16  2004/03/22 21:58:11  roefer
00750 * True odometry
00751 *
00752 * Revision 1.15  2004/03/20 09:55:25  roefer
00753 * Preparation for improved odometry
00754 *
00755 * Revision 1.14  2004/03/19 11:25:01  juengel
00756 * Added walkType turnWithBall2.
00757 *
00758 * Revision 1.13  2004/03/17 21:08:39  cesarz
00759 * Added turnWithBall3, which points to MSH2004TurnWithBallWalkingParameters.
00760 *
00761 * Revision 1.12  2004/03/17 15:38:51  thomas
00762 * added walkType debug for debugging WalkingEngineParameterSets
00763 * paramSets-messages send by debug-message are stored in the new debug-walkType only
00764 *
00765 * Revision 1.11  2004/03/17 09:32:11  jhoffman
00766 * tail wag adjusted to work with ERS7
00767 *
00768 * Revision 1.10  2004/03/08 01:39:02  roefer
00769 * Interfaces should be const
00770 *
00771 * Revision 1.9  2004/03/04 18:15:24  juengel
00772 * removed unused comment
00773 *
00774 * Revision 1.8  2004/02/16 18:02:01  dueffert
00775 * packageCognitionMotion extended with invkin parameters
00776 *
00777 * Revision 1.7  2004/01/21 14:31:58  loetzsch
00778 * Module Selectors create only the selected solution.
00779 * When the solution changes, the old solution is erased and the new
00780 * one ist created using createSolution(..)
00781 *
00782 * Revision 1.6  2004/01/05 17:56:27  juengel
00783 * Added HeadControlModes stayAsForcedPan and stayAsForcedTilt.
00784 *
00785 * Revision 1.5  2004/01/05 11:37:08  juengel
00786 * Added new TailModes: wagUpDown* and wagLeftRight*.
00787 *
00788 * Revision 1.4  2003/12/31 23:50:38  roefer
00789 * Removed inclusion of RobotDimensions.h because it is not used
00790 *
00791 * Revision 1.3  2003/12/16 19:02:45  loetzsch
00792 * The motion net file Config/spec_act.dat can be sent through WLAN to a robot.
00793 *
00794 * Revision 1.2  2003/12/10 16:52:52  roefer
00795 * Added sensor data buffer to walking engine
00796 *
00797 * Revision 1.1  2003/10/06 14:10:13  cvsadm
00798 * Created GT2004 (M.J.)
00799 *
00800 * Revision 1.6  2003/09/26 11:38:52  juengel
00801 * - sorted tools
00802 * - clean-up in DataTypes
00803 *
00804 * Revision 1.5  2003/09/25 10:11:57  juengel
00805 * Removed some walk-types
00806 *
00807 * Revision 1.4  2003/08/04 07:54:39  risler
00808 * no message
00809 *
00810 * Revision 1.3  2003/07/24 12:41:26  risler
00811 * ParamInvKinWalkingEngine no longer is template class -> 10min boot bug fixed
00812 *
00813 * Revision 1.2  2003/07/02 15:42:32  loetzsch
00814 * esoteric change (but it works now)
00815 *
00816 * Revision 1.1.1.1  2003/07/02 09:40:24  cvsadm
00817 * created new repository for the competitions in Padova from the 
00818 * tamara CVS (Tuesday 2:00 pm)
00819 *
00820 * removed unused solutions
00821 *
00822 * Revision 1.38  2003/06/13 17:29:25  jhoffman
00823 * added debug message handling
00824 *
00825 * Revision 1.37  2003/05/27 16:17:58  juengel
00826 * Added headIsBlockedBySpecialActionOrWalk.
00827 *
00828 * Revision 1.36  2003/05/26 16:23:37  dueffert
00829 * no message
00830 *
00831 * Revision 1.35  2003/05/23 11:30:12  goehring
00832 * MotionStabilizer signature changed
00833 *
00834 * Revision 1.34  2003/05/23 09:36:51  goehring
00835 * MotionStabilizer gets all 4 Sensor Values
00836 *
00837 * Revision 1.33  2003/05/06 16:52:30  juengel
00838 * Added tail-mode eightPositionSwitch.
00839 *
00840 * Revision 1.32  2003/05/02 18:26:18  risler
00841 * SensorDataBuffer added
00842 * replaced SensorData with SensorDataBuffer
00843 * full SensorData resolution now accessible
00844 *
00845 * Revision 1.31  2003/04/28 07:43:57  roefer
00846 * Error in head motion smoothing fixed
00847 *
00848 * Revision 1.30  2003/04/27 07:49:35  roefer
00849 * static vars -> member vars
00850 *
00851 * Revision 1.29  2003/04/19 04:36:48  pruente
00852 * Commited changes done by Arthur at GO2003:
00853 * - some changes
00854 * - some changes
00855 * - dash chanaged to evo parameters
00856 *
00857 * Revision 1.28  2003/04/16 07:00:16  roefer
00858 * Bremen GO checkin
00859 *
00860 * Revision 1.28  2003/04/08 18:28:28  roefer
00861 * bodyTiltOffset added
00862 *
00863 * Revision 1.27  2003/04/02 14:13:39  dueffert
00864 * walkType turnWithBall added
00865 *
00866 * Revision 1.26  2003/04/01 17:44:21  roefer
00867 * Mouth added to HeadMotionRequest
00868 *
00869 * Revision 1.25  2003/03/24 14:46:21  juengel
00870 * Added several tail modes
00871 *
00872 * Revision 1.24  2003/03/10 14:18:39  dueffert
00873 * optimized MotionNet
00874 *
00875 * Revision 1.23  2003/03/06 12:05:43  dueffert
00876 * execute with parameters renamed to avoid inheritance warnings
00877 *
00878 * Revision 1.22  2003/03/03 17:31:53  risler
00879 * walking engine now writes calculated bodyTilt to headState
00880 *
00881 * Revision 1.21  2003/02/22 00:12:07  roefer
00882 * constant bodyTilt set to 17.5°
00883 *
00884 * Revision 1.20  2003/02/16 08:30:38  roefer
00885 * Constant body tilt changed to 17°
00886 *
00887 * Revision 1.19  2003/02/11 23:12:50  roefer
00888 * useConstantBodyPose debug key added
00889 *
00890 * Revision 1.18  2003/02/06 13:15:14  dueffert
00891 * memory leak fixed
00892 *
00893 * Revision 1.17  2003/02/05 12:23:32  dueffert
00894 * executedMotionRequest is set correctly by SpecialAction and therefore not overwritten by DefaultMotionControl any more
00895 *
00896 * Revision 1.16  2003/01/27 19:27:08  juengel
00897 * added walkType upsideDown
00898 *
00899 * Revision 1.15  2003/01/23 16:44:09  risler
00900 * only one instance of InvKinWalkingEngine
00901 * parameter sets can now be switched while walking
00902 * added UNSWFastTurn, combining two parameter sets
00903 *
00904 * Revision 1.14  2002/12/03 13:07:02  dueffert
00905 * HeadMotionRequests smoothed to avoid destroying heads
00906 *
00907 * Revision 1.13  2002/11/26 17:18:13  risler
00908 * breathing only when standing is executed (not requested)
00909 *
00910 * Revision 1.12  2002/11/26 13:08:05  jhoffman
00911 * no message
00912 *
00913 * Revision 1.11  2002/11/25 14:49:07  jhoffman
00914 * added "breathing" motion
00915 *
00916 * Revision 1.10  2002/11/20 18:02:29  risler
00917 * added PID values to GT2001MotionNetSpecialActions
00918 * added playDead motion
00919 *
00920 * Revision 1.9  2002/11/19 17:12:24  juengel
00921 * "switch" tail modes added
00922 *
00923 * Revision 1.8  2002/10/11 16:59:15  roefer
00924 * Fast tail wags added
00925 *
00926 * Revision 1.7  2002/09/22 18:40:53  risler
00927 * added new math functions, removed GTMath library
00928 *
00929 * Revision 1.6  2002/09/19 12:15:13  loetzsch
00930 * made compilable for the gcc compiler.
00931 *
00932 * Revision 1.5  2002/09/17 23:55:21  loetzsch
00933 * - unraveled several datatypes
00934 * - changed the WATCH macro
00935 * - completed the process restructuring
00936 *
00937 * Revision 1.4  2002/09/16 17:36:04  dueffert
00938 * anonymous contructors return &CLASS with VS, but CLASS with gcc.
00939 *
00940 * Revision 1.3  2002/09/11 13:40:00  loetzsch
00941 * Changed DoxyGen comments
00942 *
00943 * Revision 1.2  2002/09/11 00:06:58  loetzsch
00944 * continued change of module/solution mechanisms
00945 *
00946 * Revision 1.1  2002/09/10 15:36:15  cvsadm
00947 * Created new project GT2003 (M.L.)
00948 * - Cleaned up the /Src/DataTypes directory
00949 * - Removed challenge related source code
00950 * - Removed processing of incoming audio data
00951 * - Renamed AcousticMessage to SoundRequest
00952 *
00953 * Revision 1.19  2002/09/03 16:00:50  juengel
00954 * HeadControlMode follwTail, TailMode stayAsForced.
00955 *
00956 * Revision 1.18  2002/07/23 13:33:41  loetzsch
00957 * new streaming classes
00958 *
00959 * removed many #include statements
00960 *
00961 * Revision 1.17  2002/07/07 09:43:27  roefer
00962 * Memory leak closed
00963 *
00964 * Revision 1.16  2002/06/27 11:18:59  risler
00965 * added additional walk type for bar challenge
00966 *
00967 * Revision 1.15  2002/06/22 04:35:50  dueffert
00968 * 4 bar chall
00969 *
00970 * Revision 1.14  2002/06/21 04:53:38  risler
00971 * added walktype walkWithBar
00972 *
00973 * Revision 1.13  2002/06/12 13:50:26  loetzsch
00974 * changed #ifndef WIN32  to #ifndef _WIN32
00975 *
00976 * Revision 1.12  2002/06/12 11:26:28  dueffert
00977 * if timestamp of last MotionRequest is too old, we will only swing on robot, not in RobotControl
00978 *
00979 * Revision 1.11  2002/06/10 11:05:17  risler
00980 * added timestamp to motion request
00981 * motioncontrol executes swing when no request was received
00982 *
00983 * Revision 1.10  2002/06/06 15:50:44  risler
00984 * inverted tail tilt angle
00985 *
00986 * Revision 1.9  2002/06/06 12:51:44  risler
00987 * removed bug with MotionRequest == operator / executed motion request
00988 *
00989 * Revision 1.8  2002/06/04 16:44:55  risler
00990 * tailRequest added
00991 *
00992 * Revision 1.7  2002/06/01 13:38:35  risler
00993 * reorganized walking engine selection
00994 *
00995 * Revision 1.6  2002/05/31 17:22:43  loetzsch
00996 * added module selector for dribble walk type
00997 *
00998 * Revision 1.5  2002/05/16 22:36:11  roefer
00999 * Team communication and GTMath bugs fixed
01000 *
01001 * Revision 1.4  2002/05/16 15:05:49  risler
01002 * added walk type walkWithBall
01003 *
01004 * Revision 1.3  2002/05/15 08:08:53  risler
01005 * changed default walk, added InvKin:Dortmund to selector
01006 *
01007 * Revision 1.2  2002/05/14 13:50:56  rentmeister
01008 * DortmundWalkingParameters
01009 *
01010 * Revision 1.1.1.1  2002/05/10 12:40:15  cvsadm
01011 * Moved GT2002 Project from ute to tamara.
01012 *
01013 * Revision 1.28  2002/05/06 15:57:43  risler
01014 * corrected bodyRoll angle
01015 *
01016 * Revision 1.27  2002/05/05 15:14:23  risler
01017 * changed stand implementation
01018 *
01019 * Revision 1.26  2002/05/04 18:23:43  risler
01020 * added calculation of executedMotionRequest
01021 *
01022 * Revision 1.25  2002/05/04 12:43:38  loetzsch
01023 * The currently executed MotionRequest is now sent from the MotionControl
01024 * to the BehaviorControl via the OdometryData structure
01025 *
01026 * Revision 1.24  2002/04/29 13:48:24  risler
01027 * added lastWalkType to WalkingEngine execute
01028 *
01029 * Revision 1.23  2002/04/26 13:35:33  risler
01030 * DarmstadtGOWalkingEngine renamed to InvKinWalkingEngine
01031 * added InvKinParameterSets
01032 *
01033 * Revision 1.22  2002/04/23 15:08:44  risler
01034 * changed MotionRequest: walk instead of normalWalk,... and walkType added
01035 *
01036 * Revision 1.21  2002/04/23 10:38:31  risler
01037 * renamed headOdometry to headState
01038 *
01039 * Revision 1.20  2002/04/16 16:59:47  dueffert
01040 * newWalkingParameters added
01041 *
01042 * Revision 1.19  2002/04/15 13:39:24  rentmeister
01043 * DoWalkingEngine (Dortmunder WalkingEngine)
01044 *
01045 * Revision 1.18  2002/04/08 09:48:54  rentmeister
01046 * galopWalk für den Evolver
01047 *
01048 * Revision 1.17  2002/04/05 14:08:43  jhoffman
01049 * stabilizer stuff
01050 *
01051 * Revision 1.16  2002/04/04 15:14:49  jhoffman
01052 * added motion stabilizer
01053 *
01054 * Revision 1.15  2002/04/04 15:07:59  rentmeister
01055 * Walk with Ball hinzugefügt
01056 *
01057 * Revision 1.14  2002/04/03 16:44:31  jhoffman
01058 * added "stabilizeRobot" to motionControl (which is turned off as a default)
01059 *
01060 * Revision 1.13  2002/02/28 16:28:25  risler
01061 * added GT2001WalkingParameters
01062 *
01063 * Revision 1.12  2002/02/23 16:33:07  risler
01064 * finished GetupEngine
01065 *
01066 * Revision 1.11  2002/02/20 16:40:50  risler
01067 * added GetupEngine
01068 *
01069 * Revision 1.10  2002/02/08 20:00:01  risler
01070 * added DebugMotionControl
01071 *
01072 * Revision 1.9  2002/02/08 17:48:57  risler
01073 * SensorData to MotionControl
01074 *
01075 * Revision 1.8  2002/01/19 12:42:32  risler
01076 * fixed bug with solutionHandler
01077 *
01078 * Revision 1.7  2001/12/10 17:47:06  risler
01079 * change log added
01080 *
01081 */

Generated on Thu Sep 23 19:57:31 2004 for GT2004 by doxygen 1.3.6