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
 96
 97
 98
 99
100
101
102
/**
* @file SoccerStrategyProvider.h
*
* @author <a href="mailto:xu@informatik.hu-berlin.de">Xu, Yuan</a>
* provides soccer strategy
*/

#ifndef _SoccerStrategyProvider_h_
#define _SoccerStrategyProvider_h_

#include <ModuleFramework/Module.h>

#include "Tools/DataStructures/RingBufferWithSum.h"
#include "Tools/Math/Vector3.h"
#include "Tools/Math/Common.h"
#include "Tools/Debug/DebugPlot.h"
#include "Tools/Debug/DebugRequest.h"

// Representations
#include "Representations/Infrastructure/FrameInfo.h"
#include "Representations/Infrastructure/FieldInfo.h"
#include "Representations/Modeling/BallModel.h"
#include "Representations/Modeling/ObstacleModel.h"
#include "Representations/Modeling/RobotPose.h"
#include "Representations/Modeling/PlayerInfo.h"
#include "Representations/Modeling/SoccerStrategy.h"
#include "Representations/Modeling/RawAttackDirection.h"
#include "Representations/Modeling/BodyState.h"
#include "Representations/Modeling/PlayersModel.h"
#include "Representations/Motion/MotionStatus.h"

//////////////////// BEGIN MODULE INTERFACE DECLARATION ////////////////////

BEGIN_DECLARE_MODULE(SoccerStrategyProvider)
  PROVIDE(DebugPlot)
  PROVIDE(DebugRequest)
  
  REQUIRE(FrameInfo)
  REQUIRE(FieldInfo)
  REQUIRE(BallModel)
  REQUIRE(RobotPose)
  REQUIRE(PlayerInfo)
  REQUIRE(BodyState)
  REQUIRE(PlayersModel)
  REQUIRE(ObstacleModel)
  REQUIRE(RawAttackDirection)
  REQUIRE(MotionStatus)

  PROVIDE(SoccerStrategy)
END_DECLARE_MODULE(SoccerStrategyProvider)

//////////////////// END MODULE INTERFACE DECLARATION //////////////////////

class SoccerStrategyProvider : public SoccerStrategyProviderBase
{
public: 

  class FormationParameters
  {
  public:
    FormationParameters();

    FormationParameters(unsigned int playerNumber);

    ~FormationParameters(){}

    unsigned int num;
    Vector2<double> home;
    Vector3<double> attr;
    Vector2<double> min;
    Vector2<double> max;
    bool behindBall;
    bool penaltyAreaAllowed;
  };

  SoccerStrategyProvider();
  virtual ~SoccerStrategyProvider(){}

  /** executes the module */
  virtual void execute();

protected:
  Vector2<double> calculateForamtion() const;
  
  double estimateTimeToBall() const;

  double estimateTimeToPoint(const Vector2d& p) const;
  //NEW:double estimateTimeToPoint(const Vector2d& p, const double& offensiveness=0.0) const;

  //NEW:double estimateTimeFromBallTo_GoalDir(const Vector2d& attackDir, const Vector2d& p) const;

  //NEW:int timeToGetPastObstacle(const Vector2d& ballPos) const;

  //NEW:bool isSomethingBetweenPoints(const Vector2d& p1, Vector2d& p2) const;
  bool isSomeoneBetweenMeAndPoint(const Vector2d& p) const;

private:
  FormationParameters theFormationParameters;
  RingBufferWithSum<Vector2<double>, 3> attackDirectionBuffer;
};

#endif //__SoccerStrategyProvider_h_