NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wak_beh_shared.h
1 // Walk and kick: Class for shared walk and kick behaviour state variables
2 // Author: Philipp Allgeuer <pallgeuer@ais.uni-bonn.de>
3 
4  // Ensure header is only included once
5 #ifndef WAK_BEH_SHARED_H
6 #define WAK_BEH_SHARED_H
7 
8 // Includes
9 #include <walk_and_kick/wak_common.h>
10 #include <walk_and_kick/wak_config.h>
11 #include <walk_and_kick/wak_game_vars.h>
12 #include <walk_and_kick/wak_sensor_vars.h>
13 #include <walk_and_kick/wak_actuator_vars.h>
14 #include <walk_and_kick/wak_ros_interface.h>
15 #include <walk_and_kick/wak_utils.h>
16 #include <walk_and_kick/wak_vis.h>
17 
18 // Walk and kick namespace
19 namespace walk_and_kick
20 {
21  // Class declarations
22  class WAKBehState;
23  class WAKBehManager;
24 
25  // Ball action type enumeration
26  enum BAType
27  {
28  BA_UNKNOWN = 0,
29  BA_KICK, // Look to kick the ball
30  BA_DRIBBLE, // Look to dribble the ball
31  BA_COUNT,
32  BA_DEFAULT = BA_KICK
33  };
34  const std::string BATypeName[BA_COUNT] = {
35  "Unknown",
36  "Kick",
37  "Dribble"
38  };
39  inline bool ballActionTypeValid(int type) { return (type > BA_UNKNOWN && type < BA_COUNT); }
40  inline bool ballActionTypeValid(BAType type) { return ballActionTypeValid((int) type); }
41  inline const std::string& ballActionTypeName(BAType type) { if(ballActionTypeValid(type)) return BATypeName[type]; else return BATypeName[BA_UNKNOWN]; }
42 
49  {
50  public:
51  // Constructor
52  WAKBehShared(WAKConfig& config, const SensorVars& SV, const WAKRosInterface& RI, WAKBehManager& BM);
53 
54  // Field dimensions
55  const FieldDimensions field;
56 
57  // Plot manager
58  plot_msgs::PlotManagerFS& PM;
59 
60  // Marker manager
61  WAKMarkerMan& MM;
62 
63  // Behaviour state registration function
64  void registerState(WAKBehState* state, int ID, const std::string& name) const;
65 
66  // Reset function
67  void resetShared();
68 
69  // Update function
70  void updateShared(const GameVars& GV);
71 
72  // Game variable inputs
73  GameVars GV;
74 
75  // Get functions
76  BAType ballAction() const;
77 
78  // Set functions
79  void setWalkingTarget(const Vec2f& target, float tol = -1.0f) const; // Set the walking intent of the robot in the egocentric body-fixed frame
80  void setWalkingTargetTol(float tol) const;
81 
82  // Cycle numbers and times
83  cycle_t wakCycle() const;
84  cycle_t stateCycle() const;
85  float wakTime() const;
86  float stateTime() const;
87 
88  // Shared behaviour state functions
89  float walkToGlobalPose(ActuatorVars& AV, float targetX, float targetY) const { return walkToGlobalPose(AV, targetX, targetY, 0.0f, false); }
90  float walkToGlobalPose(ActuatorVars& AV, float targetX, float targetY, float targetZ, bool useZ = true) const;
91  bool obstacleAvoidance(Vec3f& GCV, const Vec2f& walkingTarget) const;
92  bool gazeAtBall(ActuatorVars& AV, const ActuatorVars& lastAV) const;
93  Vec2f calcGcvXY(float maxGcvX, float maxGcvY, float angle) const;
94 
95  // Shared behaviour state variables
96  float reqBallDirMidY;
97  Vec2f reqBallDirLeftKb;
98  Vec2f reqBallDirRightKb;
99  Vec2f reqBallDirLeftDb;
100  Vec2f reqBallDirRightDb;
101  bool haveBallTarget;
102  float ballTargetDist;
103  float ballTargetAngle;
104  Vec2f ballToTargetDir;
105  float ballToTargetDist;
106  float ballToTargetAngle;
107  float ballToTargetAngleOffsetKick;
108 
109  private:
110  // Config parameters
111  WAKConfig& config;
112 
113  // Sensor variables
114  const SensorVars& SV;
115 
116  // ROS interface
117  const WAKRosInterface& RI;
118 
119  // Behaviour manager
120  WAKBehManager& BM;
121  };
122 }
123 
124 #endif
125 // EOF
Configuration struct for the walk and kick node.
Definition: wak_config.h:20
Visualisation marker manager for the walk and kick node.
Definition: wak_vis.h:21
An interface class for encapsulating all of the ROS input data to the walk and kick node...
Definition: wak_sensor_vars.h:29
A class that manages and executes the walk and kick behaviour states.
Definition: wak_beh_manager.h:50
A simple class for abstracting away the source of the field dimensions.
Definition: wak_utils.h:216
The base class for all walk and kick behaviour states.
Definition: wak_beh_state.h:27
An interface class for encapsulating all of the data that the walk and kick game states should comman...
Definition: wak_game_vars.h:21
A class that shares the required walk and kick variables amongst the behaviour state classes...
Definition: wak_beh_shared.h:48
An interface class between the walk and kick and ROS worlds.
Definition: wak_ros_interface.h:54
An interface class for encapsulating all of the data that the walk and kick behaviour states should c...
Definition: wak_actuator_vars.h:22