NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wak_game_vars.h
1 // Walk and kick: Game variables
2 // Author: Philipp Allgeuer <pallgeuer@ais.uni-bonn.de>
3 
4  // Ensure header is only included once
5 #ifndef WAK_GAME_VARS_H
6 #define WAK_GAME_VARS_H
7 
8 // Includes
9 #include <walk_and_kick/wak_common.h>
10 
11 // Walk and kick namespace
12 namespace walk_and_kick
13 {
21  class GameVars
22  {
23  public:
24  // Ball target type enumeration
25  enum BTType // Ball target type
26  {
27  BTT_UNKNOWN = 0, // Unknown source of ball target
28  BTT_GOAL, // Ball target based on goal detection
29  BTT_POSE, // Ball target based on localised robot pose
30  BTT_COMPASS, // Ball target based on compass heading
31  BTT_COUNT
32  };
33  static bool ballTargetTypeValid(int type) { return (type > BTT_UNKNOWN && type < BTT_COUNT); }
34  static bool ballTargetTypeValid(BTType type) { return ballTargetTypeValid((int) type); }
35  static char ballTargetTypeChar(BTType type) { if(ballTargetTypeValid(type)) return BallTargetTypeChar[type]; else return BallTargetTypeChar[BTT_UNKNOWN]; }
36  static const std::string& ballTargetTypeName(BTType type) { if(ballTargetTypeValid(type)) return BallTargetTypeName[type]; else return BallTargetTypeName[BTT_UNKNOWN]; }
37  private:
38  static const char BallTargetTypeChar[BTT_COUNT];
39  static const std::string BallTargetTypeName[BTT_COUNT];
40 
41  public:
42  // Foot selection enumeration
43  enum FootSelection
44  {
45  FS_LEFT_FOOT = -1, // Suggest use of the left foot
46  FS_EITHER_FOOT = 0, // No particular reason to prefer either foot
47  FS_RIGHT_FOOT = 1 // Suggest use of the right foot
48  };
49  static const std::string& footSelectionName(FootSelection foot) { if(foot < 0) return FootSelectionName[0]; else if(foot > 0) return FootSelectionName[2]; else return FootSelectionName[1]; }
50  private:
51  static const std::string FootSelectionName[3];
52 
53  public:
54  // Constructor
55  GameVars() { reset(); }
56 
57  // Reset function
58  void reset();
59 
60  // Validation function
61  bool coerceEnums();
62 
63  // Get functions
64  char ballTargetTypeChar() const { return ballTargetTypeChar(ballTargetType); }
65  const std::string& ballTargetTypeName() const { return ballTargetTypeName(ballTargetType); }
66  bool suggestLeftFoot() const { return (suggestFoot < 0); }
67  bool suggestRightFoot() const { return (suggestFoot > 0); }
68  bool noSuggestedFoot() const { return (suggestFoot == 0); }
69 
70  // Member variables
71  int forceBehStateByID; // Force a particular behaviour state, specified by its behaviour state ID
72  FootSelection suggestFoot; // Strongly suggest the use of a particular foot
73  bool dribbleIfPossible; // Dribble the ball towards the ball target if this is possible
74  bool kickIfPossible; // Kick the ball towards the ball target if this is possible
75  DiveDirection diveIfPossible; // Dive to save the ball if this is possible
76  float ballTargetConf; // Confidence of the ball target
77  Vec2f ballTargetDir; // Egocentric vector from the robot to the ball target
78  float ballTargetWedge; // The width of the ball target expressed as the angle it subtends at the ball position
79  BTType ballTargetType; // Enumeration value specifying the type of ball target that was calculated
80  Vec3f targetPose; // The target walking pose for the robot
81  float targetPoseTol; // The tolerance in the specified target pose
82  bool targetPoseValid; // Boolean flag whether the target pose is valid
83  };
84 }
85 
86 #endif
87 // EOF
An interface class for encapsulating all of the data that the walk and kick game states should comman...
Definition: wak_game_vars.h:21