Fawkes API  Fawkes Development Version
net_thread.h
1 
2 /***************************************************************************
3  * net_thread.h - Fawkes WorldModel Plugin Network Thread
4  *
5  * Created: Fri Jun 29 16:55:52 2007 (on flight to RoboCup 2007, Atlanta)
6  * Copyright 2006-2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_WORLDMODEL_NET_THREAD_H_
24 #define __PLUGINS_WORLDMODEL_NET_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <aspect/blackboard.h>
28 #include <aspect/logging.h>
29 #include <aspect/configurable.h>
30 #include <aspect/clock.h>
31 #include <aspect/network.h>
32 #include <netcomm/worldinfo/handler.h>
33 #include <core/utils/lock_map.h>
34 
35 
36 #include <map>
37 #include <string>
38 
39 namespace fawkes {
40  class WorldInfoTransceiver;
41  class ObjectPositionInterface;
42  class GameStateInterface;
43 }
44 
46 : public fawkes::Thread,
47  public fawkes::LoggingAspect,
49  public fawkes::ClockAspect,
50  public fawkes::NetworkAspect,
53 {
54  public:
56  virtual ~WorldModelNetworkThread();
57 
58  virtual void init();
59  virtual void loop();
60  virtual void finalize();
61 
62  fawkes::WorldInfoTransceiver* get_transceiver();
63 
64  /* WorldInfoHandler methods follow */
65  virtual void pose_rcvd(const char *from_host,
66  float x, float y, float theta,
67  float *covariance);
68 
69  virtual void velocity_rcvd(const char *from_host, float vel_x,
70  float vel_y, float vel_theta, float *covariance);
71 
72  virtual void ball_pos_rcvd(const char *from_host,
73  bool visible, int visibility_history,
74  float dist, float bearing, float slope,
75  float *covariance);
76 
77  virtual void global_ball_pos_rcvd(const char *from_host,
78  bool visible, int visibility_history,
79  float x, float y, float z,
80  float *covariance);
81 
82  virtual void ball_velocity_rcvd(const char *from_host,
83  float vel_x, float vel_y, float vel_z,
84  float *covariance);
85 
86  virtual void global_ball_velocity_rcvd(const char *from_host,
87  float vel_x, float vel_y, float vel_z,
88  float *covariance);
89 
90  virtual void opponent_pose_rcvd(const char *from_host,
91  unsigned int uid,
92  float distance, float bearing,
93  float *covariance);
94 
95  virtual void opponent_disapp_rcvd(const char *from_host, unsigned int uid);
96 
97  virtual void gamestate_rcvd(const char *from_host,
98  unsigned int game_state,
100  unsigned int score_cyan, unsigned int score_magenta,
104 
105  virtual void penalty_rcvd(const char *from_host,
106  unsigned int player, unsigned int penalty,
107  unsigned int seconds_remaining);
108 
109  private:
110  fawkes::WorldInfoTransceiver *__worldinfo_transceiver;
111 
112  unsigned int __cfg_sleep_time_msec;
113  unsigned int __cfg_max_msgs_per_recv;
114  unsigned int __cfg_flush_time_sec;
115  bool __cfg_multicast_loopback;
116 
117  typedef std::pair<fawkes::Time, fawkes::ObjectPositionInterface *> TimeObjPosPair;
118  typedef std::map<unsigned int, TimeObjPosPair> UidTimeObjPosMap;
119 
120  // host -> if
123  //host -> (uid -> if)
125  fawkes::GameStateInterface * __gamestate_if;
126 
127  unsigned int __opponent_id;
128 
129  // host -> time
131 };
132 
133 
134 #endif
World info handler.
Definition: handler.h:31
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Class to send and receive world information.
Definition: transceiver.h:52
float distance(float x1, float y1, float x2, float y2)
Get distance between two 2D cartesian coordinates.
Definition: angle.h:62
Fawkes library namespace.
Thread aspect for network communication.
Definition: network.h:37
Thread class encapsulation of pthreads.
Definition: thread.h:42
worldinfo_gamestate_half_t
Game time half.
Definition: enums.h:70
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
worldinfo_gamestate_team_t
Team.
Definition: enums.h:54
GameStateInterface Fawkes BlackBoard Interface.
Network thread of worldmodel plugin.
Definition: net_thread.h:45
worldinfo_gamestate_goalcolor_t
Goal color.
Definition: enums.h:63