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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/**
* @file PathPlanner2018.h
*
* @author <a href="mailto:akcayyig@hu-berlin.de">Yigit Can Akcay</a>
* Definition of class PathPlanner2018
*/

#ifndef _PathPlanner2018_H_
#define _PathPlanner2018_H_

#include <ModuleFramework/Module.h>

#include "Tools/Math/Geometry.h"

// debug
#include "Tools/Debug/DebugRequest.h"
#include "Tools/Debug/DebugPlot.h"
#include "Tools/Debug/DebugModify.h"
#include "Tools/Debug/DebugParameterList.h"

// representations
#include "Representations/Infrastructure/FieldInfo.h"
#include "Representations/Infrastructure/FrameInfo.h"
#include "Representations/Motion/Request/HeadMotionRequest.h"
#include "Representations/Motion/Request/MotionRequest.h"
#include "Representations/Motion/MotionStatus.h"
#include "Representations/Perception/MultiBallPercept.h"
#include "Representations/Modeling/BallModel.h"
#include "Representations/Modeling/PathModel.h"
#include "Representations/Debug/Stopwatch.h"


BEGIN_DECLARE_MODULE(PathPlanner2018)
PROVIDE(DebugPlot)
PROVIDE(DebugRequest)
PROVIDE(DebugModify)
PROVIDE(DebugParameterList)

REQUIRE(FieldInfo)
REQUIRE(MultiBallPercept)
REQUIRE(MotionStatus)
REQUIRE(BallModel)
REQUIRE(FrameInfo)

PROVIDE(PathModel)
PROVIDE(MotionRequest)
PROVIDE(HeadMotionRequest)
PROVIDE(StopwatchManager)
END_DECLARE_MODULE(PathPlanner2018)



class PathPlanner2018 : public PathPlanner2018Base
{
public:
  PathPlanner2018();
  ~PathPlanner2018();

  virtual void execute();

private:
  class Parameters : public ParameterList
  {
  public:
    Parameters() : ParameterList("PathPlanner2018")
    {
      PARAMETER_REGISTER(readyForSideKickThresholdX)            = 4.0;
      PARAMETER_REGISTER(readyForSideKickThresholdY)            = 0.3;
      PARAMETER_REGISTER(forwardKickThreshold_near.x)           = 25; // mm
      PARAMETER_REGISTER(forwardKickThreshold_near.y)           = 25; // mm
      PARAMETER_REGISTER(forwardKickThreshold_far.x)            = 50; // mm
      PARAMETER_REGISTER(forwardKickThreshold_far.y)            = 25; // mm
      //PARAMETER_REGISTER(nearApproachForwardKickBallPosOffsetX) = 110;
      PARAMETER_REGISTER(nearApproachSideKickBallPosOffsetX)    = 100;
      PARAMETER_REGISTER(sidekickOffsetY) = 40.0;
      PARAMETER_REGISTER(sideKickTime) = 300;

      PARAMETER_REGISTER(farToNearApproachThreshold)            = 10.0;

      //Parameters for 2019 - needs cleanup
      PARAMETER_REGISTER(moveAroundBallCharacter) = 1.0;
      PARAMETER_REGISTER(moveAroundBallCharacterStable) = 0.3;

      PARAMETER_REGISTER(stepLength) = 80.0;
      PARAMETER_REGISTER(nearApproach_step_character) = 0.3;

      PARAMETER_REGISTER(forwardKickOffset.x) = 120; // mm
      PARAMETER_REGISTER(forwardKickOffset.y) = 0; // mm
      PARAMETER_REGISTER(forwardKickThreshold.x) = 50; // mm
      PARAMETER_REGISTER(forwardKickThreshold.y) = 25; // mm
      PARAMETER_REGISTER(forwardKickAdaptive) = false; // mm
      PARAMETER_REGISTER(forwardKickTime) = 300;

      syncWithConfig();
    }

    virtual ~Parameters(){}

    double readyForSideKickThresholdX;
    double readyForSideKickThresholdY;
    Vector2d forwardKickThreshold_far;
    Vector2d forwardKickThreshold_near;
    //double nearApproachForwardKickBallPosOffsetX;
    double nearApproachSideKickBallPosOffsetX;
    double sidekickOffsetY;
    int sideKickTime;

    double farToNearApproachThreshold;

    double moveAroundBallCharacter;
    double moveAroundBallCharacterStable;

    double stepLength;
    double nearApproach_step_character;

    Vector2d forwardKickThreshold;
    Vector2d forwardKickOffset;
    bool forwardKickAdaptive;
    int forwardKickTime;
  } params;

  // NONE means hip
  enum Foot
  {
    RIGHT,
    LEFT,
    NONE
  };

  typedef WalkRequest::StepControlRequest::StepType StepType;
  typedef WalkRequest::StepControlRequest::RestrictionMode RestrictionMode;
  typedef WalkRequest::Coordinate Coordinate;

  void moveAroundBall(const double direction, const double radius, const bool stable);

  bool target_reached;
  void moveAroundBall2(const double direction, const double radius, const bool stable);

  // goToBall is split up between sideKick and forwardKick so that changing things in upcoming RoboCup 2018
  // won't be so complex as to introduce bugs easily
  bool farApproach();
  bool nearApproach_forwardKick(const double offsetX, const double offsetY);
  bool nearApproach_sideKick(const Foot& foot, const double offsetX, const double offsetY);
  bool sidesteps(const Foot& foot, const double direction);

  void forwardKick();
  void sideKick(const Foot& foot);

// generate a setter method
#define SET(Type, SetName, Name) \
  public: StepBufferElement& set##SetName(const Type& v) { Name = v; return *this; } \
  public: Type Name

  struct StepBufferElement
  {
    StepBufferElement() {}<--- Member variable 'StepBufferElement::speedDirection' is not initialized in the constructor.<--- Member variable 'StepBufferElement::time' is not initialized in the constructor.<--- Member variable 'StepBufferElement::character' is not initialized in the constructor.<--- Member variable 'StepBufferElement::scale' is not initialized in the constructor.<--- Member variable 'StepBufferElement::foot' is not initialized in the constructor.<--- Member variable 'StepBufferElement::isProtected' is not initialized in the constructor.
    StepBufferElement(const std::string& name) : debug_name(name) {}<--- Member variable 'StepBufferElement::speedDirection' is not initialized in the constructor.<--- Member variable 'StepBufferElement::time' is not initialized in the constructor.<--- Member variable 'StepBufferElement::character' is not initialized in the constructor.<--- Member variable 'StepBufferElement::scale' is not initialized in the constructor.<--- Member variable 'StepBufferElement::foot' is not initialized in the constructor.<--- Member variable 'StepBufferElement::isProtected' is not initialized in the constructor.

    SET(Pose2D,Pose, pose);
    SET(double,SpeedDirection, speedDirection);
    SET(StepType,StepType,type);
    SET(int,Time,time);
    SET(double,Character,character);
    SET(double,Scale,scale);
    SET(Foot,Foot,foot);
    SET(WalkRequest::Coordinate,Coordinate,coordinate);
    SET(RestrictionMode,Restriction,restriction);
    SET(bool,Protected,isProtected);

  public:
    std::string debug_name;
  };

  std::vector<StepBufferElement> stepBuffer;

  // Used to alternate between left and right foot
  // or to specify which foot to use
  Foot footToUse;

  // Used to synchronize stepIDs of WalkEngine to take control
  unsigned int lastStepRequestID;

  void addStep(const StepBufferElement& new_step);
  void updateSpecificStep(const unsigned int index, StepBufferElement& step);
  void manageStepBuffer();
  void executeStepBuffer();


private:
  bool kickPlanned;

};

#endif // _PathPlanner2018_H_