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

Modules/TeamBallLocator/GT2004TeamBallLocator.cpp

Go to the documentation of this file.
00001 /**
00002 * @file GT2004TeamBallLocator.cpp
00003 * 
00004 * Implementation of class TeamBallLocator
00005 *
00006 * @author <a href="mailto:roefer@tzi.de">Thomas Röfer</a>
00007 * @author Martin Lötzsch
00008 */
00009 
00010 #include "GT2004TeamBallLocator.h"
00011 #include "Platform/SystemCall.h"
00012 
00013 GT2004TeamBallLocator::GT2004TeamBallLocator(const TeamBallLocatorInterfaces& interfaces)
00014 : TeamBallLocator(interfaces)
00015 {
00016 }
00017 
00018 void GT2004TeamBallLocator::execute()
00019 {
00020   double validityMax = 0;
00021   int bestIndex = -1;
00022 
00023   for(int i = 0; i < teamMessageCollection.numberOfTeamMessages; ++i)
00024   {
00025     // get the time until the ball was seen consecutively in own time
00026     unsigned long timeUntilSeenConsecutively
00027       = teamMessageCollection[i]
00028       .getTimeInOwnTime(teamMessageCollection[i].seenBallPosition.timeWhenLastSeen);
00029 
00030     if(SystemCall::getTimeSince(timeUntilSeenConsecutively) < 2000)
00031     {
00032       // The ball was seen consecutively by the other robot in the last 2 seconds
00033 
00034       double v = teamMessageCollection[i].robotPose.getValidity();
00035 
00036       if(v > validityMax)
00037       {
00038         // take the ball of the robot with the highest validity of the robot's pose
00039         validityMax = v;
00040         bestIndex = i;
00041       }
00042     }
00043   }
00044 
00045   if(bestIndex >= 0)
00046   {
00047     // copy the seen ball position of the best other robot to
00048     // the communicated ball position
00049     communicatedBallPosition.x = teamMessageCollection[bestIndex].seenBallPosition.x;
00050     communicatedBallPosition.y = teamMessageCollection[bestIndex].seenBallPosition.y;
00051     communicatedBallPosition.timeWhenLastObserved
00052       = teamMessageCollection[bestIndex].getTimeInOwnTime
00053       (teamMessageCollection[bestIndex].seenBallPosition.timeUntilSeenConsecutively);
00054   }
00055 }
00056 
00057 
00058 /*
00059 * Change log :
00060 * 
00061 * $Log: GT2004TeamBallLocator.cpp,v $
00062 * Revision 1.1  2004/07/10 00:18:32  spranger
00063 * renamed (readded) for coderelease
00064 *
00065 * Revision 1.1.1.1  2004/05/22 17:22:25  cvsadm
00066 * created new repository GT2004_WM
00067 *
00068 * Revision 1.1  2004/04/05 17:56:47  loetzsch
00069 * merged the local German Open CVS of the aibo team humboldt with the tamara CVS
00070 *
00071 * Revision 1.2  2004/04/01 22:46:55  loetzsch
00072 * experiments
00073 *
00074 * Revision 1.1.1.1  2004/03/31 11:16:50  loetzsch
00075 * created ATH repository for german open 2004
00076 */

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