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

# Representations/Perception/PlayersPercept.h

Go to the documentation of this file.

    00001 /**
    00002  * @file PlayersPercept.h
    00003  *
    00004  * Declaration of classes PlayersPercept and SinglePlayerPercept
    00005  * @author <A href=mailto:timlaue@informatik.uni-bremen.de>Tim Laue</A>
    00006  */
    00007
    00008 #ifndef __PlayersPercept_h_
    00009 #define __PlayersPercept_h_
    00010
    00011
    00012 #include "Tools/Streams/Streamable.h"
    00013 #include "Tools/Math/Vector2.h"
    00014
    00015
    00016 /**
    00017 * This class contains some information about a single perceived robot
    00018 */
    00019 class SinglePlayerPercept : public Streamable
    00020 {
    00021 public:
    00022   /** Simple constructor */
    00023   SinglePlayerPercept() : validity(0),directionOnField(0) {}
    00024
    00025   /** offset to the robot, relative to own robot */
    00026   Vector2<double> offsetOnField;
    00027
    00028   /** The direction of the perceived robot*/
    00029   double directionOnField;
    00030
    00031   /** position of the robot in the image */
    00032   Vector2<int> positionInImage;
    00033
    00034   double orientation;
    00035
    00036   /** The validity of this percept */
    00037   double validity;
    00038
    00039   void serialize(In* in, Out* out)
    00040   {
    00041     STREAM_REGISTER_BEGIN();
    00042     STREAM(offsetOnField);
    00043     STREAM(directionOnField);
    00044     STREAM(positionInImage);
    00045     STREAM(validity);
    00046     STREAM_REGISTER_FINISH();
    00047   }
    00048 };
    00049
    00050
    00051 /**
    00052 * This is a collection of SinglePlayerPercept for red and blue dressed robots.
    00053 */
    00054 class PlayersPercept : public Streamable
    00055 {
    00056 public:
    00057   /** Constants */
    00058   enum {
    00059     maxNumberOfRedPlayerPercepts = 13,
    00060     maxNumberOfBluePlayerPercepts = 17,
    00061     maxNumberOfOneRobotsPercepts = 17,
    00062     maxNumberOfPercepts = 34
    00063   };
    00064
    00065   /** Constructor */
    00066   PlayersPercept() : numberOfRedPlayers(0), numberOfBluePlayers(0), frameNumber(0)
    00067   {reset(0);};
    00068
    00069   /** Initializes the percept */
    00070   void reset(unsigned long frameNumber);
    00071
    00072   /**
    00073   * The function adds a red player percept.
    00074   * @param percept The percept to add.
    00075   */
    00076   void addRedPlayer(const SinglePlayerPercept& percept);
    00077
    00078   /**
    00079   * The function adds a blue player percept.
    00080   * @param percept The percept to add.
    00081   */
    00082   void addBluePlayer(const SinglePlayerPercept& percept);
    00083
    00084   /** List of perceived red robots */
    00085   SinglePlayerPercept redPlayers[maxNumberOfRedPlayerPercepts];
    00086
    00087   /** List of perceived blue robots */
    00088   SinglePlayerPercept bluePlayers[maxNumberOfBluePlayerPercepts];
    00089
    00090   /** Number of perceived red robots */
    00091   int numberOfRedPlayers;
    00092
    00093   /** Number of perceived blue robots */
    00094   int numberOfBluePlayers;
    00095
    00096   /** The frame number when perceived. */
    00097   unsigned long frameNumber;
    00098
    00099   void serialize(In* in, Out* out)
    00100   {
    00101     STREAM_REGISTER_BEGIN();
    00102     STREAM(frameNumber);
    00103     STREAM_DYN_ARRAY(redPlayers, numberOfRedPlayers);
    00104     STREAM_DYN_ARRAY(bluePlayers, numberOfBluePlayers);
    00105     STREAM_REGISTER_FINISH();
    00106   }
    00107 };
    00108
    00109
    00110 #endif //__PlayersPercept_h_