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

# Modules/PlayersLocator/GTCamPlayersLocator.cpp

Go to the documentation of this file.

    00001 /**
    00002 * @file GTCamPlayersLocator.cpp
    00003 *
    00004 * This file contains a class for players localization using the worldstate of the GTCam.
    00005 *
    00006 * @author <a href="mailto:timo.diekmann@uni-dortmund.de">Timo Diekmann</a>
    00007 */
    00008
    00009 /*
    00010 GTCamPlayersLocator:
    00011
    00012 The GTCam solution for the module PlayersLocator uses the position of the three teammates and the four opponents of the GTCamWorldState to fill the playerPoseCollection.
    00013
    00014 These attributes of playerPoseCollection are calculated:
    00015   - ownPlayerPoses[], opponentPlayerPoses[]: for every PlayerPose these attributes are calculated
    00016     - frameNumber:
    00017     - pose
    00018       - rotation: set to the rotation calculated by GTCam for this player
    00019       - translation: set to the translation calculated by GTCam for this player
    00020     - validity: set to 1.0
    00021     - playerNumber: the number of the player
    00022     - sigmaMin: set to 0.0
    00023     - sigmaMaj: set to 0.0
    00024     - cosAngle: set to 1.0
    00025     - sinAngle: set to 0.0
    00026     - speed: set to the speed of the player
    00027
    00028 These attributes of playerPoseCollection are set once in the constructor of GTCamPlayersLocator:
    00029   - numberOfOwnPlayers: set to 3
    00030   - numberOfOpponentPlayers: set to 4
    00031
    00032 Proceeding:
    00033   For all teammates and opponents the positions and orientations are read out of the GTCamWorldState and written into playerPoseCollection.
    00034 */
    00035
    00036 #include "GTCamPlayersLocator.h"
    00037 #include "Tools/Player.h"
    00038
    00039 GTCamPlayersLocator::GTCamPlayersLocator(const PlayersLocatorInterfaces& interfaces)
    00040 : PlayersLocator(interfaces)
    00041 {
    00042   playerPoseCollection.numberOfOwnPlayers = NUMBER_OF_OWN_PLAYERS_TO_LOCATE;
    00043   playerPoseCollection.numberOfOpponentPlayers = NUMBER_OF_OPPONENT_PLAYERS_TO_LOCATE;
    00044 }
    00045
    00046 void GTCamPlayersLocator::execute() // speed of robots and other atributes are not set yet!
    00047 {
    00048   int me = getPlayer().getPlayerNumber();
    00049   int color = getPlayer().getTeamColor();
    00050   int oppColor = (color == Player::red ? Player::blue : Player::blue);
    00051   Vector2<double> pos;
    00052   for (int i = 0; i < NUMBER_OF_OPPONENT_PLAYERS_TO_LOCATE; i++) {
    00053     Vector2<double> speed;
    00054     double speed_abs;
    00055     if (i != me) {
    00056       pos = gtCamWorldState.getPlayerPos(i, color);
    00057       playerPoseCollection.setOwnPlayerPose
    00058         (i>me?i-1:i, pos.x, pos.y, gtCamWorldState.getPlayerOrientation(i, color), 1.0);
    00059       PlayerPose& playerPose = const_cast<PlayerPose&>(playerPoseCollection.getOwnPlayerPose(i>me?i-1:i));
    00060       playerPose.setPlayerNumber((Player::playerNumber)i);
    00061       playerPose.setSigmaMin(0.0);
    00062       playerPose.setSigmaMaj(0.0);
    00063       playerPose.setSinAngle(0.0);
    00064       playerPose.setCosAngle(1.0);
    00065       speed = gtCamWorldState.getPlayerSpeed(i, color);
    00066       speed_abs = sqrt(speed.x*speed.x+speed.y*speed.y);
    00067       playerPose.setSpeed(speed_abs);
    00068     }
    00069     pos = gtCamWorldState.getPlayerPos(i, oppColor);
    00070     playerPoseCollection.setOpponentPlayerPose
    00071       (i, pos.x, pos.y, gtCamWorldState.getPlayerOrientation(i, oppColor), 1.0);
    00072     PlayerPose& playerPose = const_cast<PlayerPose&>(playerPoseCollection.getOpponentPlayerPose(i));
    00073     playerPose.setPlayerNumber((Player::playerNumber)i);
    00074     playerPose.setSigmaMin(0.0);
    00075     playerPose.setSigmaMaj(0.0);
    00076     playerPose.setSinAngle(0.0);
    00077     playerPose.setCosAngle(1.0);
    00078     speed = gtCamWorldState.getPlayerSpeed(i, oppColor);
    00079     speed_abs = sqrt(speed.x*speed.x+speed.y*speed.y);
    00080     playerPose.setSpeed(speed_abs);
    00081   }
    00082 }
    00083
    00084 bool GTCamPlayersLocator::handleMessage(InMessage& message) {
    00085   return false;
    00086 }