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

# Modules/BehaviorControl/GT2005BehaviorControl/GT2005Symbols/GT2005StrategySymbols.cpp

Go to the documentation of this file.

    00001 /**
    00002 * @file GT2005StrategySymbols.cpp
    00003 *
    00004 * Implementation of class GT2005StrategySymbols.
    00005 *
    00006 * @author Martin Lötzsch
    00007 */
    00008
    00009 #include "GT2005StrategySymbols.h"
    00010 #include "Tools/FieldDimensions.h"
    00011
    00012
    00013 GT2005StrategySymbols::GT2005StrategySymbols(BehaviorControlInterfaces& interfaces)
    00014 : BehaviorControlInterfaces(interfaces),
    00015   ballIsHandledAtTheMoment(false),
    00016   goingToInterceptionPoint(false),
    00017   doProfile(GT2005StrategySymbols::dontDoProfiling),
    00018   writeProfile(GT2005StrategySymbols::dontWriteProfiles)
    00019 {
    00020   role = BehaviorTeamMessage::goalie;
    00021   estimatedTimeToReachBall = 0.0;
    00022   timeSinceLastCarryBall = 0;
    00023   behaviorTimeCarryBallState = dontSave;
    00024   timeSinceLastCarryBallSaved = false;
    00025   timeSinceLastKick = 0;
    00026   behaviorTimeKickState = dontSave;
    00027   timeSinceLastKickSaved = false;
    00028 }
    00029
    00030 void GT2005StrategySymbols::registerSymbols(Xabsl2Engine& engine)
    00031 {
    00032   // "robot-number"
    00033   engine.registerDecimalInputSymbol("robot-number", this,
    00034     (double(Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getRobotNumber);
    00035
    00036   // "role"
    00037   engine.registerEnumeratedInputSymbol("role", (int *)&role);
    00038   engine.registerEnumeratedInputSymbolEnumElement("role", "goalie", BehaviorTeamMessage::goalie);
    00039   engine.registerEnumeratedInputSymbolEnumElement("role", "striker", BehaviorTeamMessage::striker);
    00040   engine.registerEnumeratedInputSymbolEnumElement("role", "defensive-supporter", BehaviorTeamMessage::defensiveSupporter);
    00041   engine.registerEnumeratedInputSymbolEnumElement("role", "offensive-supporter", BehaviorTeamMessage::offensiveSupporter);
    00042
    00043   // "estimated-time-to-reach-ball"
    00044   engine.registerDecimalInputSymbol("estimated-time-to-reach-ball", (double *)&estimatedTimeToReachBall);
    00045
    00046   // "sent-game-state"
    00047   engine.registerEnumeratedOutputSymbol("sent-game-state",(int*)&outgoingBehaviorTeamMessage.gameState);
    00048   engine.registerEnumeratedOutputSymbolEnumElement("sent-game-state","sent-game-state.sleep",BehaviorTeamMessage::sleep);
    00049   engine.registerEnumeratedOutputSymbolEnumElement("sent-game-state","sent-game-state.initial",BehaviorTeamMessage::initial);
    00050   engine.registerEnumeratedOutputSymbolEnumElement("sent-game-state","sent-game-state.ready",BehaviorTeamMessage::ready);
    00051   engine.registerEnumeratedOutputSymbolEnumElement("sent-game-state","sent-game-state.playing",BehaviorTeamMessage::playing);
    00052   engine.registerEnumeratedOutputSymbolEnumElement("sent-game-state","sent-game-state.penalized",BehaviorTeamMessage::penalized);
    00053   engine.registerEnumeratedOutputSymbolEnumElement("sent-game-state","sent-game-state.finished",BehaviorTeamMessage::finished);
    00054   engine.registerEnumeratedOutputSymbolEnumElement("sent-game-state","sent-game-state.set",BehaviorTeamMessage::set);
    00055
    00056
    00057   // "another-player-is-in-ready-state"
    00058   engine.registerBooleanInputSymbol("another-player-is-in-ready-state",
    00059     this,(bool(Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getAnotherPlayerIsInReadyState);
    00060
    00061   // "another-player-is-in-initial-state"
    00062   engine.registerBooleanInputSymbol("another-player-is-in-initial-state",
    00063     this,(bool(Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getAnotherPlayerIsInInitialState);
    00064
    00065   // "team-message"
    00066   engine.registerEnumeratedOutputSymbol("team-message",(int*)&outgoingBehaviorTeamMessage.message);
    00067   engine.registerEnumeratedOutputSymbolEnumElement("team-message","team-message.none", BehaviorTeamMessage::none);
    00068   engine.registerEnumeratedOutputSymbolEnumElement("team-message","team-message.performing-a-kick",BehaviorTeamMessage::performingAKick);
    00069   engine.registerEnumeratedOutputSymbolEnumElement("team-message","team-message.performing-a-pass",BehaviorTeamMessage::passing);
    00070
    00071   // "another-teammate-is-performing-a-kick"
    00072   engine.registerBooleanInputSymbol("another-teammate-is-performing-a-kick",
    00073     this,(bool(Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getAnotherTeammateIsPerformingAKick);
    00074
    00075   // "another-teammate-is-performing-a-pass"
    00076   engine.registerBooleanInputSymbol("another-teammate-is-performing-a-pass",
    00077     this,(bool(Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getAnotherTeammateIsPerformingAPass);
    00078
    00079   // "the-striker-is-playing-near-the-opponent-goal"
    00080   engine.registerBooleanInputSymbol("the-striker-is-playing-near-the-opponent-goal",
    00081     this,(bool(Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getTheStrikerIsPlayingNearTheOpponentGoal);
    00082
    00083   // "the-striker-is-not-playing-near-the-opponent-goal"
    00084   engine.registerBooleanInputSymbol("the-striker-is-not-playing-near-the-opponent-goal",
    00085     this,(bool(Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getTheStrikerIsNotPlayingNearTheOpponentGoal);
    00086
    00087   // "the-striker-is-playing-near-the-own-goal"
    00088   engine.registerBooleanInputSymbol("the-striker-is-playing-near-the-own-goal",
    00089     this,(bool(Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getTheStrikerIsPlayingNearTheOwnGoal);
    00090
    00091   // "the-striker-is-not-playing-near-the-own-goal"
    00092   engine.registerBooleanInputSymbol("the-striker-is-not-playing-near-the-own-goal",
    00093     this,(bool(Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getTheStrikerIsNotPlayingNearTheOwnGoal);
    00094
    00095   // "goalie-max-position-speed"
    00096   engine.registerDecimalInputSymbol("goalie-max-position-speed", this,
    00097     (double (Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getGoalieMaxPositionSpeed);
    00098
    00099   engine.registerDecimalInputSymbol("search-ball.x", this,
    00100     (double (Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getSearchBallX);
    00101
    00102   // "get-angle-to-teammate
    00103   engine.registerDecimalInputFunction("get-angle-to-teammate",this,
    00104     (double (Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getAngleToTeammate);
    00105   engine.registerDecimalInputFunctionParameter("get-angle-to-teammate","get-angle-to-teammate.index",GT2005StrategySymbols::angleToTeammateIndex);
    00106
    00107   // strategy.ball-is-handled-at-the-moment
    00108   engine.registerBooleanInputSymbol("strategy.ball-is-handled-at-the-moment", &ballIsHandledAtTheMoment);
    00109
    00110   // strategy.going-to-interception-point
    00111   engine.registerBooleanInputSymbol("strategy.going-to-interception-point", &goingToInterceptionPoint);
    00112
    00113   // strategy.time-since-last-carry-ball
    00114   engine.registerDecimalInputSymbol("strategy.time-since-last-carry-ball", this,
    00115     (double (Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getTimeSinceLastCarryBall);
    00116   // strategy.set-time-carry-ball
    00117   engine.registerEnumeratedOutputSymbol("strategy.set-time-carry-ball", (int*)&behaviorTimeCarryBallState);
    00118   engine.registerEnumeratedOutputSymbolEnumElement("strategy.set-time-carry-ball","strategy.set-time-carry-ball.dont-save",dontSave);
    00119   engine.registerEnumeratedOutputSymbolEnumElement("strategy.set-time-carry-ball","strategy.set-time-carry-ball.save-time",saveTime);
    00120   engine.registerEnumeratedOutputSymbolEnumElement("strategy.set-time-carry-ball","strategy.set-time-carry-ball.reset-time",resetTime);
    00121
    00122
    00123   // strategy.time-since-last-kick
    00124   engine.registerDecimalInputSymbol("strategy.time-since-last-kick", this,
    00125     (double (Xabsl2FunctionProvider::*)())&GT2005StrategySymbols::getTimeSinceLastKick);
    00126
    00127   // strategy.set-time-kick
    00128   engine.registerEnumeratedOutputSymbol("strategy.set-time-kick", (int*)&behaviorTimeKickState);
    00129   engine.registerEnumeratedOutputSymbolEnumElement("strategy.set-time-kick","strategy.set-time-kick.dont-save",dontSave);
    00130   engine.registerEnumeratedOutputSymbolEnumElement("strategy.set-time-kick","strategy.set-time-kick.save-time",saveTime);
    00131   engine.registerEnumeratedOutputSymbolEnumElement("strategy.set-time-kick","strategy.set-time-kick.reset-time",resetTime);
    00132
    00133
    00134
    00135   // strategy.ball-handling
    00136   engine.registerEnumeratedOutputSymbol("strategy.ball-handling", (int*)&ballHandling.behaviorBallState);
    00137   engine.registerEnumeratedOutputSymbolEnumElement("strategy.ball-handling","going-to-interception-point",BallHandling::goToInterceptionPoint);
    00138   engine.registerEnumeratedOutputSymbolEnumElement("strategy.ball-handling","dribble-the-ball",BallHandling::dribbleTheBall);
    00139   engine.registerEnumeratedOutputSymbolEnumElement("strategy.ball-handling","performing-a-kick",BallHandling::performingAKick);
    00140   engine.registerEnumeratedOutputSymbolEnumElement("strategy.ball-handling","handling-the-ball",BallHandling::handlingTheBall);
    00141   engine.registerEnumeratedOutputSymbolEnumElement("strategy.ball-handling","not-handling-the-ball",BallHandling::notHandlingTheBall);
    00142 }
    00143
    00144 void GT2005StrategySymbols::update()
    00145 {
    00146   estimateTimeToReachBall();
    00147   MODIFY("Symbols:GT2005Strategy:estimatedTimeToReachBall", estimatedTimeToReachBall);
    00148   computeRole();
    00149   if ( role != roleLastFrame )
    00150   {
    00151     timeStampSinceRoleChange = SystemCall::getCurrentSystemTime();
    00152   }
    00153
    00154   roleLastFrame = role;
    00155   outgoingBehaviorTeamMessage.timeSinceRoleChange = SystemCall::getTimeSince(timeStampSinceRoleChange);
    00156
    00157   outgoingBehaviorTeamMessage.estimatedTimeToReachBall = estimatedTimeToReachBall;
    00158   outgoingBehaviorTeamMessage.dynamicRole = role;
    00159
    00160   // use the information that was set by the options in the last frame
    00161   ballIsHandledAtTheMoment = (ballHandling.behaviorBallState == BallHandling::notHandlingTheBall ||
    00162                               ballHandling.behaviorBallState == BallHandling::goToInterceptionPoint) ? false : true;
    00163   goingToInterceptionPoint = ballHandling.behaviorBallState == BallHandling::goToInterceptionPoint;
    00164
    00165   switch(behaviorTimeCarryBallState)
    00166   {
    00167   case dontSave  : timeSinceLastCarryBallSaved = false; break;
    00168   case saveTime  : if (!timeSinceLastCarryBallSaved) {
    00169           timeSinceLastCarryBall = SystemCall::getCurrentSystemTime();
    00170           timeSinceLastCarryBallSaved = true;
    00171            }
    00172            break;
    00173   case resetTime : timeSinceLastCarryBall = 0; timeSinceLastCarryBallSaved = false; break;
    00174   }
    00175   behaviorTimeCarryBallState = dontSave;
    00176
    00177   switch(behaviorTimeKickState)
    00178   {
    00179   case dontSave :
    00180     timeSinceLastKickSaved = false;
    00181     break;
    00182   case saveTime  :
    00183     if (!timeSinceLastCarryBallSaved)
    00184     {
    00185       timeSinceLastKick = SystemCall::getCurrentSystemTime();
    00186       timeSinceLastKickSaved = true;
    00187     }
    00188     break;
    00189   case resetTime :
    00190     timeSinceLastKick = 0;
    00191     timeSinceLastKickSaved = false;
    00192     break;
    00193   }
    00194   behaviorTimeKickState = dontSave;
    00195
    00196   DEBUG_RESPONSE("Behavior:ballHandling",
    00197     switch (ballHandling.behaviorBallState)
    00198     {
    00199     case BallHandling::notHandlingTheBall: OUTPUT(idText, text, "notHandlingTheBall"); break;
    00200     case BallHandling::dribbleTheBall: OUTPUT(idText, text, "dribbleTheBall"); break;
    00201     case BallHandling::goToInterceptionPoint: OUTPUT(idText, text, "goToInterceptionPoint"); break;
    00202     case BallHandling::handlingTheBall: OUTPUT(idText, text, "handlingTheBall"); break;
    00203     case BallHandling::performingAKick: OUTPUT(idText, text, "performingAKick"); break;
    00204     }
    00205   );
    00206
    00207   // set "ballWasHandledInLastFrame" to false. It will only become true when
    00208   // an option sets it to true again
    00209   ballHandling.behaviorBallState = BallHandling::notHandlingTheBall;
    00210
    00211   NDECLARE_DEBUGDRAWING("behavior:symbols:ball is handled at the moment", "drawingOnField", "shows an orange circle around the robot when true");
    00212   if(ballIsHandledAtTheMoment)
    00213   {
    00214     NCIRCLE("behavior:symbols:ball is handled at the moment", robotPose.translation.x, robotPose.translation.y, 150, 25, Drawings::ps_solid, Drawings::orange);
    00215   }
    00216
    00217 }
    00218
    00219 void GT2005StrategySymbols::computeRole()
    00220 {
    00221   int i;
    00222
    00223   if (getPlayer().getPlayerNumber() == Player::one)
    00224   {
    00225     // no role changes for the goalie
    00226     role = BehaviorTeamMessage::goalie;
    00227     return;
    00228   }
    00229
    00230
    00231   // if in the goalzone and ball lies within angle infront, role = striker
    00232   if(FieldDimensions::distanceToOpponentPenaltyArea(robotPose.translation) < 400
    00233     && SystemCall::getTimeSince(ballModel.seen.timeWhenLastSeen) < 1000)
    00234   {
    00235     if(ballModel.seen.ballInFrontOfOpponentGoal)
    00236     {
    00237         role = BehaviorTeamMessage::striker;
    00238         return;
    00239     }
    00240   }
    00241   DEBUG_RESPONSE_NOT("ROLE:disableWLANCheck",
    00242   // fall-back if no wlan
    00243   if (!teamMessageCollection[0].isActual(5000)
    00244     && !teamMessageCollection[1].isActual(5000)
    00245     && !teamMessageCollection[2].isActual(5000))
    00246   {
    00247     switch(getPlayer().getPlayerNumber())
    00248     {
    00249     case Player::two:
    00250       if (SystemCall::getTimeSince (ballModel.seen.timeWhenLastSeen) > 5000)
    00251         role = BehaviorTeamMessage::defensiveSupporter;
    00252       else if(role == BehaviorTeamMessage::defensiveSupporter)
    00253       {
    00254         if (ballModel.getKnownBallState().positionField.x < 400)
    00255           role = BehaviorTeamMessage::striker;
    00256         else
    00257           role = BehaviorTeamMessage::defensiveSupporter;
    00258       } else {
    00259         if (ballModel.getKnownBallState().positionField.x < 600)
    00260           role = BehaviorTeamMessage::striker;
    00261         else
    00262           role = BehaviorTeamMessage::defensiveSupporter;
    00263       }
    00264       break;
    00265     case Player::three:
    00266     case Player::four:
    00267       if (SystemCall::getTimeSince (ballModel.seen.timeWhenLastSeen) > 5000)
    00268         role = BehaviorTeamMessage::offensiveSupporter;
    00269       else if (role == BehaviorTeamMessage::offensiveSupporter)
    00270       {
    00271         if (ballModel.getKnownBallState().positionField.x > -400)
    00272           role = BehaviorTeamMessage::striker;
    00273         else
    00274           role = BehaviorTeamMessage::offensiveSupporter;
    00275       }
    00276       else
    00277       {
    00278         if (ballModel.getKnownBallState().positionField.x > -600)
    00279           role = BehaviorTeamMessage::striker;
    00280         else
    00281           role = BehaviorTeamMessage::offensiveSupporter;
    00282       }
    00283       break;
    00284     }
    00285     return;
    00286   }
    00287   );
    00288
    00289   // with wlan
    00290
    00291   // estimate the closest other teammate to the ball
    00292   double minTeammateTime = 100000.0;
    00293
    00294   unsigned long timeSinceRoleChange = 1000;
    00295   // compute striker bonus
    00296   for (i = 0; i < teamMessageCollection.numberOfTeamMessages; i++ )
    00297   {
    00298     if ( teamMessageCollection[i].isActual() ) // only new messages
    00299     {
    00300       if ( teamMessageCollection[i].behaviorTeamMessage.dynamicRole != BehaviorTeamMessage::goalie
    00301         && teamMessageCollection[i].behaviorTeamMessage.gameState == BehaviorTeamMessage::playing)
    00302         // the robot is not interested in
    00303         // (1) how fast the goalie can approach the ball
    00304         // (2) how fast a penalized field player can approach the ball
    00305       {
    00306         if ( teamMessageCollection[i].behaviorTeamMessage.dynamicRole == BehaviorTeamMessage::striker )
    00307         {
    00308           timeSinceRoleChange = teamMessageCollection[i].behaviorTeamMessage.timeSinceRoleChange;
    00309         }
    00310       }
    00311     }
    00312   }
    00313   if (role == BehaviorTeamMessage::striker )
    00314   {
    00315     timeSinceRoleChange = outgoingBehaviorTeamMessage.timeSinceRoleChange;
    00316   }
    00317
    00318   double strikerbonus = 500.0;
    00319
    00320   DEBUG_RESPONSE("behavior:strategy-symbols:timeSinceRoleChange",OUTPUT(idText,text,"ROLE.timeSinceRoleChange = " <<timeSinceRoleChange););
    00321   DEBUG_RESPONSE("behavior:strategy-symbols:dynamic strikerbonus",
    00322   {
    00323
    00324     double upperBound = 1500;
    00325     double lowerBound = 100;
    00326     double timeBound = 3000;
    00327     MODIFY("behavior:strategy-symbols:upperBound",upperBound);
    00328     MODIFY("behavior:strategy-symbols:lowerBound",lowerBound);
    00329     MODIFY("behavior:strategy-symbols:timeBound",timeBound);
    00330     strikerbonus= -(upperBound-lowerBound)/timeBound
    00331                 * timeSinceRoleChange
    00332                 + upperBound;
    00333     if (strikerbonus <lowerBound)
    00334     {
    00335       strikerbonus = lowerBound;
    00336     }
    00337   }
    00338   );
    00339   DEBUG_RESPONSE("behavior:strategy-symbols:strikerbonus",OUTPUT(idText,text,"ROLE.strikerbonus = " <<strikerbonus););
    00340
    00341
    00342   for (i = 0; i < teamMessageCollection.numberOfTeamMessages; i++ )
    00343   {
    00344     if ( teamMessageCollection[i].isActual() ) // only new messages
    00345     {
    00346       if ( teamMessageCollection[i].behaviorTeamMessage.dynamicRole != BehaviorTeamMessage::goalie
    00347         && teamMessageCollection[i].behaviorTeamMessage.gameState == BehaviorTeamMessage::playing)
    00348         // the robot is not interested in
    00349         // (1) how fast the goalie can approach the ball
    00350         // (2) how fast a penalized field player can approach the ball
    00351       {
    00352         double time =
    00353           teamMessageCollection[i].behaviorTeamMessage.estimatedTimeToReachBall;
    00354
    00355         // bonus for current striker
    00356         if ( teamMessageCollection[i].behaviorTeamMessage.dynamicRole == BehaviorTeamMessage::striker )
    00357           time -= strikerbonus;
    00358
    00359         if (time < minTeammateTime )
    00360         {
    00361           minTeammateTime = time;
    00362         }
    00363       }
    00364     }
    00365   }
    00366
    00367   // bonus for current striker
    00368   if (role == BehaviorTeamMessage::striker)
    00369     minTeammateTime += strikerbonus*2;
    00370
    00371   // assign striker-role if nearest to the ball
    00372   if ( estimatedTimeToReachBall < minTeammateTime )
    00373   {
    00374     role = BehaviorTeamMessage::striker;
    00375     return;
    00376   }
    00377
    00378   // assign supporting roles
    00379   double minTeammateX = (double)xPosOpponentGroundline;
    00380   for (i = 0; i < teamMessageCollection.numberOfTeamMessages; i++ )
    00381   {
    00382     if ( teamMessageCollection[i].isActual() )
    00383     {
    00384       if ( teamMessageCollection[i].behaviorTeamMessage.dynamicRole != BehaviorTeamMessage::striker
    00385         && teamMessageCollection[i].behaviorTeamMessage.dynamicRole != BehaviorTeamMessage::goalie
    00386         && teamMessageCollection[i].behaviorTeamMessage.gameState == BehaviorTeamMessage::playing)
    00387       {
    00388         double teammateX =
    00389           teamMessageCollection[i].robotPose.translation.x;
    00390
    00391         // bonus for current offensive supporter
    00392         if ( teamMessageCollection[i].behaviorTeamMessage.dynamicRole == BehaviorTeamMessage::defensiveSupporter )
    00393           teammateX -= 300.0;
    00394
    00395         if (teammateX < minTeammateX )
    00396         {
    00397           minTeammateX = teammateX;
    00398         }
    00399       }
    00400     }
    00401   }
    00402
    00403   // bonus for current offensive supporter
    00404   if ( role == BehaviorTeamMessage::defensiveSupporter )
    00405     minTeammateX += 300.0;
    00406
    00407   if ( robotPose.translation.x <= minTeammateX )
    00408     role = BehaviorTeamMessage::defensiveSupporter;
    00409   else
    00410     role = BehaviorTeamMessage::offensiveSupporter;
    00411 }
    00412
    00413 double GT2005StrategySymbols::getGoalieMaxPositionSpeed()
    00414 {
    00415   double maxSpeed = 150;
    00416   double minDistance = 300;
    00417
    00418   double minSpeed = 60;
    00419   double maxDistance = 1500;
    00420
    00421   double ballDistance = Geometry::distanceTo(robotPose.getPose(),ballModel.seen.positionField);
    00422
    00423   double speed = maxSpeed - ((ballDistance - minDistance) * maxSpeed) / (maxDistance ) ;
    00424
    00425   speed = max(minSpeed, speed);
    00426   speed = min(maxSpeed, speed);
    00427
    00428   return speed;
    00429 }
    00430
    00431 void GT2005StrategySymbols::estimateTimeToReachBall()
    00432 {
    00433   //if (ballWasHandledInLastFrame)
    00434   if (ballHandling.behaviorBallState != BallHandling::notHandlingTheBall &&
    00435       ballHandling.behaviorBallState != BallHandling::goToInterceptionPoint)
    00436   {
    00437     // currently at the ball
    00438     estimatedTimeToReachBall = 0;
    00439     return;
    00440   }
    00441
    00442   // no ball known
    00443   if ( ballModel.getTimeSinceLastKnown(BallModel::behaviorControlTimeAfterWhichCommunicatedBallsAreAccepted)
    00444        > 1500 )
    00445   {
    00446     estimatedTimeToReachBall = 10000 + getPlayer().getPlayerNumber();
    00447     return;
    00448   }
    00449
    00450   Vector2<double> ballPositionToUse = ballModel.seen.positionField;
    00451
    00452   DEBUG_RESPONSE("behavior:strategy-symbols:estimate time with known ball",
    00453   {
    00454     ballPositionToUse = ballModel.getKnownPosition(
    00455       BallModel::behaviorControlTimeAfterWhichCommunicatedBallsAreAccepted,
    00456       BallModel::timeAfterWhichPropagatedAreUsed,
    00457       BallModel::maxDistanceToUseSeen,
    00458       BallModel::minDistanceToUseSeen);
    00459   });
    00460
    00461   // account for distance to ball
    00462   estimatedTimeToReachBall = Geometry::distanceTo(robotPose.translation, ballPositionToUse) / 0.2;
    00463
    00464   // account if the robot is between the ball and the opponent goal
    00465
    00466   // the position of the robot
    00467   Vector2<double> robotPosition = robotPose.translation;
    00468   double angleToLeftOpponentGoalPost = Geometry::angleTo(robotPosition, Vector2<double>(xPosOpponentGroundline,yPosLeftGoal));
    00469   double angleToRightOpponentGoalPost = Geometry::angleTo(robotPosition, Vector2<double>(xPosOpponentGroundline,yPosRightGoal));
    00470   if(angleToLeftOpponentGoalPost < angleToRightOpponentGoalPost)
    00471   {
    00472     angleToLeftOpponentGoalPost += pi2;
    00473   }
    00474   double angleToOpponentGoal= (angleToLeftOpponentGoalPost + angleToRightOpponentGoalPost) / 2.0;
    00475   double absoluteAngleToBall = Geometry::angleTo(robotPosition,ballPositionToUse);
    00476   double angleBetweenBallAndOpponentGoal = normalize(angleToOpponentGoal - absoluteAngleToBall);
    00477
    00478   estimatedTimeToReachBall += 400.0 * fabs(angleBetweenBallAndOpponentGoal);
    00479
    00480   // longer if ball not seen
    00481   estimatedTimeToReachBall += 2.0 * SystemCall::getTimeSince(ballModel.seen.timeWhenLastSeen);
    00482
    00483   // test for obstacles
    00484   /*
    00485   if ( isOpponentBetweenRobotAndBall(robotPose) ||
    00486   isOwnBetweenRobotAndBall (robotPose) )
    00487   time += 5000.0;
    00488   */
    00489
    00490 }
    00491
    00492 double GT2005StrategySymbols::getAngleToTeammate()
    00493 {
    00494
    00495   //OUTPUT(idText, text,"::nrofownplayer:"<<playerPoseCollection.numberOfOwnPlayers);
    00496
    00497
    00498   if(1 <= playerPoseCollection.numberOfOwnPlayers)
    00499   {
    00500     return toDegrees(Geometry::angleTo(robotPose, playerPoseCollection.getOwnPlayerPose((int)angleToTeammateIndex).getPose().translation));
    00501   }
    00502   else
    00503   {
    00504     return toDegrees(Geometry::angleTo(robotPose,
    00505       Vector2<double>(xPosOpponentGroundline,yPosCenterGoal)));
    00506   }
    00507 }
    00508
    00509 double GT2005StrategySymbols::getTimeSinceLastCarryBall()
    00510 {
    00511   if (timeSinceLastCarryBall > 1)
    00512     return (double) SystemCall::getTimeSince(timeSinceLastCarryBall);
    00513   else return 99999.0; /* 99 secs since last using should be long enough for behaviour control */
    00514 }
    00515
    00516 double GT2005StrategySymbols::getTimeSinceLastKick()
    00517 {
    00518   if (timeSinceLastKick > 1)
    00519     return (double) SystemCall::getTimeSince(timeSinceLastKick);
    00520   else return 99999.0; /* 99 secs since last using should be long enough for behaviour control */
    00521 }
    00522
    00523 bool GT2005StrategySymbols::getAnotherPlayerIsInReadyState()
    00524 {
    00525   for (int i=0; i<3;i++)
    00526   {
    00527     if (teamMessageCollection[i].isActual())
    00528     {
    00529       if (teamMessageCollection[i].behaviorTeamMessage.gameState
    00530         == BehaviorTeamMessage::ready)
    00531       {
    00532         return true;
    00533       }
    00534     }
    00535   }
    00536   return false;
    00537 }
    00538
    00539 bool GT2005StrategySymbols::getAnotherPlayerIsInInitialState()
    00540 {
    00541   for (int i=0; i<3;i++)
    00542   {
    00543     if (teamMessageCollection[i].isActual())
    00544     {
    00545       if (teamMessageCollection[i].behaviorTeamMessage.gameState
    00546         == BehaviorTeamMessage::initial)
    00547       {
    00548         return true;
    00549       }
    00550     }
    00551   }
    00552   return false;
    00553 }
    00554
    00555 bool GT2005StrategySymbols::getAnotherTeammateIsPerformingAKick()
    00556 {
    00557   for (int i=0; i<3;i++)
    00558   {
    00559     if (teamMessageCollection[i].isActual())
    00560     {
    00561       if (teamMessageCollection[i].behaviorTeamMessage.message
    00562         == BehaviorTeamMessage::performingAKick)
    00563       {
    00564         return true;
    00565       }
    00566     }
    00567   }
    00568   return false;
    00569 }
    00570
    00571 bool GT2005StrategySymbols::getAnotherTeammateIsPerformingAPass()
    00572 {
    00573   for (int i=0; i<3;i++)
    00574   {
    00575     if (teamMessageCollection[i].isActual())
    00576     {
    00577       if (teamMessageCollection[i].behaviorTeamMessage.message
    00578         == BehaviorTeamMessage::passing)
    00579       {
    00580         return true;
    00581       }
    00582     }
    00583   }
    00584   return false;
    00585 }
    00586
    00587 bool GT2005StrategySymbols::getTheStrikerIsPlayingNearTheOpponentGoal()
    00588 {
    00589   for (int i=0; i<3;i++)
    00590   {
    00591     if (teamMessageCollection[i].isActual())
    00592     {
    00593       if (teamMessageCollection[i].behaviorTeamMessage.dynamicRole == BehaviorTeamMessage::striker
    00594         && teamMessageCollection[i].robotPose.translation.x > 1500)
    00595       {
    00596         return true;
    00597       }
    00598     }
    00599   }
    00600   return false;
    00601 }
    00602
    00603 bool GT2005StrategySymbols::getTheStrikerIsNotPlayingNearTheOpponentGoal()
    00604 {
    00605   for (int i=0; i<3;i++)
    00606   {
    00607     if (teamMessageCollection[i].isActual())
    00608     {
    00609       if (teamMessageCollection[i].behaviorTeamMessage.dynamicRole == BehaviorTeamMessage::striker
    00610         && teamMessageCollection[i].robotPose.translation.x < 1300)
    00611       {
    00612         return true;
    00613       }
    00614     }
    00615   }
    00616   return false;
    00617 }
    00618
    00619 bool GT2005StrategySymbols::getTheStrikerIsPlayingNearTheOwnGoal()
    00620 {
    00621   for (int i=0; i<3;i++)
    00622   {
    00623     if (teamMessageCollection[i].isActual())
    00624     {
    00625       if (teamMessageCollection[i].behaviorTeamMessage.dynamicRole == BehaviorTeamMessage::striker
    00626         && teamMessageCollection[i].robotPose.translation.x < -1200)
    00627       {
    00628         return true;
    00629       }
    00630     }
    00631   }
    00632   return false;
    00633 }
    00634
    00635 bool GT2005StrategySymbols::getTheStrikerIsNotPlayingNearTheOwnGoal()
    00636 {
    00637   for (int i=0; i<3;i++)
    00638   {
    00639     if (teamMessageCollection[i].isActual())
    00640     {
    00641       if (teamMessageCollection[i].behaviorTeamMessage.dynamicRole == BehaviorTeamMessage::striker
    00642         && teamMessageCollection[i].robotPose.translation.x > -1000)
    00643       {
    00644         return true;
    00645       }
    00646     }
    00647   }
    00648   return false;
    00649 }
    00650
    00651 double GT2005StrategySymbols::getSearchBallX()
    00652 {
    00653   // fall-back if no wlan
    00654   if (!teamMessageCollection[0].isActual(5000)
    00655     && !teamMessageCollection[1].isActual(5000)
    00656     && !teamMessageCollection[2].isActual(5000))
    00657   {
    00658     switch(getPlayer().getPlayerNumber())
    00659     {
    00660     case Player::two:
    00661       return -1000;
    00662     case Player::three:
    00663       return 0;
    00664     case Player::four:
    00665     default:
    00666       return 1000;
    00667     }
    00668   }
    00669   else
    00670   {
    00671     switch (role)
    00672     {
    00673     case BehaviorTeamMessage::defensiveSupporter:
    00674       return -1000;
    00675     case BehaviorTeamMessage::offensiveSupporter:
    00676       return 1000;
    00677     case BehaviorTeamMessage::striker:
    00678     default:
    00679       return 0;
    00680     }
    00681   }
    00682 }
    00683