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

# Representations/Perception/BallPercept.h

Go to the documentation of this file.

    00001 /**
    00002 * @file BallPercept.h
    00003 *
    00004 * Declaration of class BallPercept
    00005 *
    00006 * @author <A href=mailto:roefer@tzi.de>Thomas Röfer</A>
    00007 * @author <a href="mailto:juengel@informatik.hu-berlin.de">Matthias Juengel</a>
    00008 * @author <a href="mailto:walter.nistico@uni-dortmund.de">Walter Nistico</a>
    00009 */
    00010
    00011
    00012 #ifndef __BallPercept_h_
    00013 #define __BallPercept_h_
    00014
    00015 #include "Tools/Streams/InOut.h"
    00016 #include "Tools/Math/Vector2.h"
    00017 #include "Tools/Math/Vector3.h"
    00018 #include "Tools/Math/Common.h"
    00019 #include "Tools/FieldDimensions.h"
    00020 #include "Tools/RobotConfiguration.h"
    00021 #include "MultipleBallPerceptElement.h"
    00022 #include "MultipleBallPerceptList.h"
    00023
    00024 /**
    00025 * Contains a percept for a ball
    00026 */
    00027 class BallPercept;
    00028
    00029 class BallPercept : public Streamable
    00030 {
    00031   void serialize(In* in, Out* out)
    00032   {
    00033     STREAM_REGISTER_BEGIN();
    00034     STREAM(ballWasSeen);
    00035     STREAM(offsetOnField);
    00036     STREAM(bearingBasedOffsetOnField);
    00037     STREAM(sizeBasedOffsetOnField);
    00038     STREAM(centerInImage);
    00039     STREAM(radiusInImage);
    00040     STREAM(reliability);
    00041     STREAM(isCameraMatrixValid);
    00042     STREAM(multiplePercepts);
    00043     STREAM(frameNumber);
    00044     STREAM_REGISTER_FINISH();
    00045   }
    00046
    00047 public:
    00048   /**
    00049   * Constructor.
    00050   */
    00051   BallPercept();
    00052
    00053   /** The functions resets the percept. */
    00054   void reset(unsigned long frameNumber) {this->frameNumber = frameNumber; ballWasSeen = false;}
    00055
    00056   /** The function adds a seen ball to the percept */
    00057   void add(const Vector2<double>& offsetOnField,
    00058     const Vector2<double>& bearingBasedOffsetOnField,
    00059     const Vector2<double>& sizeBasedOffsetOnField,
    00060     const Vector2<double>& centerInImage,
    00061     double radiusInImage,
    00062     double reliability,
    00063     bool isCameraMatrixValid);
    00064
    00065   /** Adds a seen ball to the percept, specifing its center and radius in image coords and additionally its reliability */
    00066   void addHighRes(const Vector2<int>& centerInPixel,
    00067                   const Vector2<double>& centerAsAngles,
    00068                   double radiusInPixel,
    00069                   double radiusAsAngle,
    00070                   const Vector3<double>& translationOfCamera,
    00071                   bool isCameraMatrixValid,
    00072                   double reliability);
    00073
    00074   bool ballWasSeen; /**< Indicates if the ball was seen. */
    00075   Vector2<double> offsetOnField; /**< Ball offset based interpolated between size based and bearing based. */
    00076   Vector2<double> bearingBasedOffsetOnField; /**< Ball offset based on intersection with the field plane. */
    00077   Vector2<double> sizeBasedOffsetOnField; /**< Ball offset based on the size in the image. */
    00078   Vector2<double> centerInImage; /**< The center of the ball in image coordinates. */
    00079   double radiusInImage; /**< The center of the ball in image coordinates. */
    00080   double reliability; /**< The reliability of the percept. */
    00081   bool isCameraMatrixValid; /**< Indicates, whether the camera matrix was reliable when the percept was created. */
    00082   MultipleBallPerceptList multiplePercepts; /**< Array stores the multiple ball percepts, ordered by reliability */
    00083   unsigned long frameNumber; /**< The frame number of the image that was used to create the percept. */
    00084
    00085 private:
    00086   void checkOffset(Vector2<double>& offset) const;
    00087
    00088   /** Calculates ball position based on intrinsic camera parameters, instead of opening angle width*/
    00089   //void getOffsetIntrinsic(Vector2<double>& offset) const;
    00090 };
    00091
    00092 #endif //__BallPercept_h_