1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* @file TeamBallLocator.h
*
* Declaration of class TeamBallLocator
*/

#ifndef __TeamBallLocatorMedian_h_
#define __TeamBallLocatorMedian_h_

#include <ModuleFramework/Module.h>
#include <algorithm>

// Debug
#include "Tools/Debug/DebugRequest.h"
#include "Tools/Debug/DebugDrawings.h"
#include "Tools/Debug/DebugModify.h"
#include "Tools/Debug/DebugParameterList.h"

// Representations
#include "Representations/Modeling/PlayerInfo.h"
#include "Representations/Modeling/TeamMessage.h"
#include "Representations/Modeling/TeamMessageData.h"
#include "Representations/Modeling/TeamMessagePlayersState.h"
#include "Representations/Modeling/RobotPose.h"
#include "Representations/Modeling/TeamBallModel.h"
#include "Representations/Infrastructure/GameData.h"
#include "Representations/Infrastructure/FrameInfo.h"

// Tools
#include "Tools/DataStructures/ParameterList.h"

BEGIN_DECLARE_MODULE(TeamBallLocatorMedian)
  PROVIDE(DebugModify)
  PROVIDE(DebugRequest)
  PROVIDE(DebugDrawings)
  PROVIDE(DebugParameterList)
  
  REQUIRE(PlayerInfo)
  REQUIRE(TeamMessage)
  REQUIRE(TeamMessagePlayersState)
  REQUIRE(RobotPose)
  REQUIRE(GameData)
  REQUIRE(FrameInfo)

  PROVIDE(TeamBallModel)
  PROVIDE(TeamMessageData)
END_DECLARE_MODULE(TeamBallLocatorMedian)

class TeamBallLocatorMedian : protected TeamBallLocatorMedianBase
{
  public:
    // time stamped Vector2d
    class Vector2dTS
    {
      public:
        Vector2dTS() {}<--- Member variable 'Vector2dTS::t' is not initialized in the constructor.
        // this may be implemented the wrong way round
        bool operator< (const Vector2dTS &v2) const
        {
          return this->t < v2.t;
        }
      public:
        Vector2d vec;
        unsigned int t;
    };
    // parameters
    class Parameters: public ParameterList
    {
    public:
      Parameters() : ParameterList("TeamBallMedianParameters")
      {
        PARAMETER_REGISTER(maxTimeOffset) = 1000;
        PARAMETER_REGISTER(maxTimeValid) = 5000;
        syncWithConfig();
      }
      
      unsigned int maxTimeOffset;
      unsigned int maxTimeValid;

    } params;


  public:
    TeamBallLocatorMedian();
    ~TeamBallLocatorMedian();

    virtual void execute();

  private:
    std::vector<Vector2dTS> ballPosHist;
    std::vector<Vector2dTS> ownballPosHist;
    std::map<unsigned int, unsigned int> lastMessages;
};

#endif //__TeamBallLocatorMedian_h_