NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bench_vis.h
1 // Bench visualisation node
2 // Author: Philipp Allgeuer <pallgeuer@ais.uni-bonn.de>
3 // AndrĂ© Brandenburger <andre.brandenburger@uni-bonn.de>
4 
5 // Ensure header is only included once
6 #ifndef BENCH_VIS_H
7 #define BENCH_VIS_H
8 
9 // Includes
10 #include <bench_vis/bench_vis_config.h>
11 #include <walk_and_kick/wak_gc_ros.h>
12 #include <walk_and_kick/wak_gc_vars.h>
13 #include <walk_and_kick/wak_tc_ros.h>
14 #include <walk_and_kick/wak_tc_vars.h>
15 #include <rrlogger/LoggerHeartbeat.h>
16 #include <vis_utils/marker_manager.h>
17 #include <map>
18 #include <math.h>
19 #include <string>
20 #include <sstream>
21 #include <walk_and_kick/wak_common.h>
22 #include <walk_and_kick/wak_beh_manager.h>
23 #include <walk_and_kick/wak_game_manager.h>
24 #include <boost/lexical_cast.hpp>
25 #include <rot_conv/rot_conv.h>
26 #include <plot_msgs/plot_manager.h>
27 #include <walk_and_kick/wak_utils.h>
28 
29 // ATTENTION: If you change this, you need to add extra colors to the table!
30 #define ROBOT_LIMIT 10
31 
32 
33 // Bench visualisation namespace
34 namespace bench_vis
35 {
36  class GeneralMarkerManager : public vis_utils::MarkerManager
37  {
38  public:
39  explicit GeneralMarkerManager();
40  const std::string behField;
42 
43 
44  config_server::Parameter<bool> m_plotData;
45  plot_msgs::PlotManagerFS m_PM;
46  void configurePlotManager();
47 
48  enum PMIDS
49  {
50  PM_GC_SEQID,
51  PM_GC_TIMESINCEPACKETBASE,
52  PM_GC_TIMESINCEPACKETEXTRA,
53  PM_GC_EXTRAOUTOFDATE,
54  PM_GC_GAMEPHASE,
55  PM_GC_GAMESTATE,
56  PM_GC_TIMEPLAYING,
57  PM_GC_KICKOFFTYPE,
58  PM_GC_TIMEREMAINING_RAW,
59  PM_GC_TIMEREMAINING_SMOOTH,
60  PM_GC_SECONDARYTIME_RAW,
61  PM_GC_SECONDARYTIME_SMOOTH,
62  PM_GC_TIMETOBALLINPLAY_RAW,
63  PM_GC_TIMETOBALLINPLAY_SMOOTH,
64  PM_GC_OWNPENALTYSTATE,
65  PM_GC_OWNPENALTYTIME_RAW,
66  PM_GC_OWNPENALTYTIME_SMOOTH,
67  PM_GC_OWNSCORE,
68  PM_GC_OPPSCORE,
69  PM_GC_OWNNUMPLAYING,
70  PM_GC_OPPNUMPLAYING,
71  PM_COUNT
72  };
73  };
74 
75 
76  // Robot Marker Manager
77  class RobotMarkerManager : public vis_utils::MarkerManager
78  {
79  public:
80  explicit RobotMarkerManager(std::string robot);
81  void updateMarkerXYZ(vis_utils::GenMarker& marker, bool show, float x = 0.0f, float y = 0.0f, float z = 0.0f, float rot = 0.0f, float a = 1.0f);
82 
83  const std::string behField;
85 
86  vis_utils::BoxMarker robot_trunk;
87  vis_utils::SphereMarker robot_head;
88  vis_utils::TextMarker robot_name;
89  vis_utils::SphereMarker ball;
90  vis_utils::BoxMarker goalMarker;
91  vis_utils::ArrowMarker compass;
92  vis_utils::SphereMarker eye1;
93  vis_utils::SphereMarker eye2;
94  vis_utils::TextMarker ModeStateText;
95  vis_utils::TextMarker GameStateText;
96  vis_utils::TextMarker BehStateText;
97  vis_utils::TextMarker RoleText;
98  vis_utils::TextMarker StableText;
99  vis_utils::BoxMarker wt_cross1;
100  vis_utils::BoxMarker wt_cross2;
101  vis_utils::TextMarker northLabel;
102  vis_utils::CylinderMarker obstacle;
103 
104  config_server::Parameter<bool> m_plotData;
105  plot_msgs::PlotManagerFS m_PM;
106 
107 
108 
109  void configurePlotManager();
110  enum PMIDS
111  {
112  PM_ENABLED,
113  PM_TIME_SINCE_LAST_RECEIVED,
114  PM_FIELD_TYPE,
115  PM_ON_YELLOW,
116  PM_AS_CYAN,
117  PM_LISTEN_TO_GC,
118  PM_LISTEN_TO_TC,
119  PM_IS_PENALTY_SHOOT,
120  PM_KICKOFF_TYPE,
121  PM_BUTTON_STATE,
122  PM_GAME_COMMAND,
123  PM_GAME_ROLE,
124  PM_PLAY_STATE,
125  PM_GAME_STATE,
126  PM_BEH_STATE,
127  PM_FALLEN,
128  PM_COMPASS_HEADING,
129  PM_ROBOT_POSE_X,
130  PM_ROBOT_POSE_Y,
131  PM_ROBOT_POSE_T,
132  PM_ROBOT_POSE_CONF,
133  PM_ROBOT_POSE_VALID,
134  PM_BALL_POSE_X,
135  PM_BALL_POSE_Y,
136  PM_BALL_POSE_CONF,
137  PM_BALL_POSE_VALID,
138  PM_BALL_POSE_STABLE,
139  PM_OBSTACLE_CLOSEST_X,
140  PM_OBSTACLE_CLOSEST_Y,
141  PM_OBSTACLE_CLOSEST_CONF,
142  PM_OBSTACLE_CLOSEST_VALID,
143  PM_WALKING_TARGET_X,
144  PM_WALKING_TARGET_Y,
145  PM_WALKING_TARGET_VALID,
146  PM_TIME_SINCE_GC_BASE,
147  PM_TIME_SINCE_GC_EXTRA,
148  PM_TIME_SINCE_TC,
149  PM_NUM_FRESH_TC,
150  PM_COUNT
151  };
152 
153  ros::Time last_recieved;
154  private:
155 
156  };
157 
158 
159  // Robot Marker Manager typedefs
160  typedef boost::shared_ptr<RobotMarkerManager> RMM_ptr;
161  typedef std::map<unsigned int, RMM_ptr> RMM_map;
162  typedef std::map<unsigned int, uint16_t> PackID_to_UID_map;
163 
164  // BenchVis class
165  class BenchVis
166  {
167  public:
168  // Constructor
169  explicit BenchVis(ros::NodeHandle& nh);
170  // Step function
171  void step();
172 
173  private:
174  // Configuration parameters
175  BVConfig config;
176 
177  // ROS node handle
178  ros::NodeHandle m_nh;
179 
180  // Game controller variables
183  bool m_GCDataFresh;
184 
185  // Team communications variables
188 
189  GeneralMarkerManager gmm;
190 
191  RMM_map rmm_map;
192  PackID_to_UID_map pID_to_UID;
193 
194 
195 
196  // Logger functions and variables
197  void updateLoggerState();
198  void publishLoggerState(bool log);
199  rrlogger::LoggerHeartbeat m_loggerMsg;
200  ros::Publisher m_pub_logger;
201  ros::Time m_loggerStamp;
202  uint16_t last_packetID;
203 
204  const static float colors[ROBOT_LIMIT+1][3];
205 
206 
207  };
208 }
209 
210 #endif
211 // EOF
An interface class to the ROS world for getting game controller messages.
Definition: wak_gc_ros.h:21
A class that encapsulates all of the game controller input data to the walk and kick node...
Definition: wak_gc_vars.h:29
An interface class to the ROS world for team communications.
Definition: wak_tc_ros.h:30
A class that encapsulates all of the team communication input data to the walk and kick node...
Definition: wak_tc_vars.h:37
A simple class for abstracting away the source of the field dimensions.
Definition: wak_utils.h:216