NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wak_game_shared.h
1 // Walk and kick: Class for shared walk and kick game state variables
2 // Author: Philipp Allgeuer <pallgeuer@ais.uni-bonn.de>
3 
4  // Ensure header is only included once
5 #ifndef WAK_GAME_SHARED_H
6 #define WAK_GAME_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_ros_interface.h>
14 #include <walk_and_kick/wak_utils.h>
15 #include <walk_and_kick/wak_vis.h>
16 #include <rc_utils/math_funcs.h>
17 #include <rc_utils/ros_time.h>
18 
19 // Walk and kick namespace
20 namespace walk_and_kick
21 {
22  // Class declarations
23  class WAKGameState;
24  class WAKGameManager;
25 
32  {
33  public:
34  // Constructor
35  WAKGameShared(WAKConfig& config, const SensorVars& SV, const WAKRosInterface& RI, WAKGameManager& GM);
36 
37  // Field dimensions
38  const FieldDimensions field;
39 
40  // Plot manager
41  plot_msgs::PlotManagerFS& PM;
42 
43  // Marker manager
44  WAKMarkerMan& MM;
45 
46  // Game state registration function
47  void registerState(WAKGameState* state, int ID, const std::string& name) const;
48 
49  // Reset function
50  void resetShared();
51 
52  // Update function
53  void updateShared();
54 
55  // Get functions
56  bool gameStateIsNew() const;
57 
58  // Cycle numbers and times
59  cycle_t wakCycle() const;
60  cycle_t stateCycle() const;
61  float wakTime() const;
62  float stateTime() const;
63 
64  // Shared game state functions
65  bool obstacleBallHandling(GameVars& GV) const;
66  Vec2f applyGoalSign(const Vec2f& pose) const { return (SV.goalSign > 0 ? pose : Vec2f(-pose.x(), -pose.y())); }
67  Vec3f applyGoalSign(const Vec3f& pose) const { return (SV.goalSign > 0 ? Vec3f(pose.x(), pose.y(), rc_utils::picut(pose.z())) : Vec3f(-pose.x(), -pose.y(), rc_utils::picut(pose.z() + M_PI))); }
68  Vec3f getKickoffPoseTarget() const;
69  bool poseIsLegalForKickoff(const Vec3f& pose) const;
70 
71  // Shared game state variables
72  /* None yet */
73 
74  private:
75  // Config parameters
76  WAKConfig& config;
77 
78  // Sensor variables
79  const SensorVars& SV;
80 
81  // ROS interface
82  const WAKRosInterface& RI;
83 
84  // Game manager
85  WAKGameManager& GM;
86  };
87 
94  {
95  public:
96  // Constructor
97  DynamicTargetPose() { clear(); }
98 
99  // Set functions
100  void clear() { m_targetPose.setZero(); m_targetPoseExists = false; rc_utils::zeroRosTime(m_targetPoseTime); }
101  void set(const Vec3f& targetPose, const ros::Time& now) { m_targetPose = targetPose; m_targetPoseExists = true; m_targetPoseTime = now; }
102 
103  // Get functions
104  bool exists() const { return m_targetPoseExists; }
105  const Vec3f& value() const { return m_targetPose; }
106  float timeSinceSet(const ros::Time& now) const { return (m_targetPoseExists ? (now - m_targetPoseTime).toSec() : INFINITY); }
107  bool hasExpired(float expireTime, const ros::Time& now) { return (!m_targetPoseExists || (now - m_targetPoseTime).toSec() >= expireTime); }
108 
109  private:
110  // Internal variables
111  Vec3f m_targetPose;
112  bool m_targetPoseExists;
113  ros::Time m_targetPoseTime;
114  };
115 }
116 
117 #endif
118 // EOF
Configuration struct for the walk and kick node.
Definition: wak_config.h:20
Simple class that encapsulates the variables needed to easily dynamically calculate a target pose...
Definition: wak_game_shared.h:93
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 shares the required walk and kick variables amongst the game state classes.
Definition: wak_game_shared.h:31
The base class for all walk and kick game states.
Definition: wak_game_state.h:26
A simple class for abstracting away the source of the field dimensions.
Definition: wak_utils.h:216
A class that manages and executes the walk and kick game states.
Definition: wak_game_manager.h:38
An interface class for encapsulating all of the data that the walk and kick game states should comman...
Definition: wak_game_vars.h:21
An interface class between the walk and kick and ROS worlds.
Definition: wak_ros_interface.h:54