Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
backend_thread.h
1 
2 /***************************************************************************
3  * backend_thread.h - World Info Viewer backend thread
4  *
5  * Created: Thu April 10 21:53:24 2008
6  * Copyright 2008 Daniel Beck
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 __TOOL_WORLDINFO_VIEWER_BACKEND_THREAD_H_
24 #define __TOOL_WORLDINFO_VIEWER_BACKEND_THREAD_H_
25 
26 #include <netcomm/worldinfo/handler.h>
27 #include <netcomm/utils/resolver.h>
28 #include <netcomm/dns-sd/avahi_thread.h>
29 #include <core/threading/thread.h>
30 
31 #include <gtkmm.h>
32 #include <string>
33 
34 namespace fawkes {
35  class WorldInfoTransceiver;
36  class WorldInfoDataContainer;
37 }
38 
40 : public fawkes::Thread,
42 {
43  public:
45  const char* addr, unsigned short port,
46  const char* key, const char* iv );
47 
49 
50  Glib::Dispatcher& new_worldinfo_data();
51  Glib::Dispatcher& new_gamestate_data();
52 
53  // thread
54  void loop();
55 
56  // handler
57  virtual void pose_rcvd( const char *from_host,
58  float x, float y, float theta,
59  float *covariance );
60 
61  virtual void velocity_rcvd( const char *from_host, float vel_x,
62  float vel_y, float vel_theta, float *covariance );
63 
64  virtual void ball_pos_rcvd( const char *from_host,
65  bool visible, int visibility_history,
66  float dist, float pitch, float yaw,
67  float *covariance );
68 
69  virtual void global_ball_pos_rcvd( const char *from_host,
70  bool visible, int visibility_history,
71  float x, float y, float z,
72  float *covariance );
73 
74  virtual void ball_velocity_rcvd( const char *from_host,
75  float vel_x, float vel_y, float vel_z,
76  float *covariance );
77 
78  virtual void global_ball_velocity_rcvd(const char *from_host,
79  float vel_x, float vel_y, float vel_z,
80  float *covariance);
81 
82  virtual void opponent_pose_rcvd( const char *from_host, unsigned int uid,
83  float distance, float angle,
84  float *covarianceconst );
85 
86  virtual void opponent_disapp_rcvd( const char *from_host, unsigned int uid );
87 
88  virtual void gamestate_rcvd( const char *from_host,
89  unsigned int game_state,
91  unsigned int score_cyan, unsigned int score_magenta,
95 
96  virtual void penalty_rcvd(const char *from_host,
97  unsigned int player, unsigned int penalty,
98  unsigned int seconds_remaining);
99 
100  private:
101  fawkes::WorldInfoTransceiver* m_transceiver;
102  fawkes::WorldInfoDataContainer* m_data_container;
103 
104  Glib::Dispatcher m_signal_new_worldinfo_data;
105  Glib::Dispatcher m_signal_new_gamestate_data;
106 
107  std::string m_addr;
108  unsigned short m_port;
109  std::string m_key;
110  std::string m_iv;
111 
112  fawkes::NetworkNameResolver* m_resolver;
113  fawkes::AvahiThread* m_avahi;
114 
115 };
116 
117 #endif /* __TOOL_WORLDINFO_VIEWER_BACKEND_THREAD_H_ */
virtual void global_ball_velocity_rcvd(const char *from_host, float vel_x, float vel_y, float vel_z, float *covariance)
Ball velocity information received.
Data container to store and exchange worldinfo data.
WorldInfoViewerBackendThread(fawkes::WorldInfoDataContainer *data_container, const char *addr, unsigned short port, const char *key, const char *iv)
Constructor.
Glib::Dispatcher & new_worldinfo_data()
Access the dispatcher that is emitted whenever new data has arrived.
World info handler.
Definition: handler.h:31
virtual void pose_rcvd(const char *from_host, float x, float y, float theta, float *covariance)
Pose information received.
Class to send and receive world information.
Definition: transceiver.h:52
Thread class encapsulation of pthreads.
Definition: thread.h:42
Glib::Dispatcher & new_gamestate_data()
Access the dispatcher that is emitted whenever new game state data has arrived.
virtual void global_ball_pos_rcvd(const char *from_host, bool visible, int visibility_history, float x, float y, float z, float *covariance)
Global ball position information received.
worldinfo_gamestate_half_t
Game time half.
Definition: enums.h:70
virtual void gamestate_rcvd(const char *from_host, unsigned int game_state, fawkes::worldinfo_gamestate_team_t state_team, unsigned int score_cyan, unsigned int score_magenta, fawkes::worldinfo_gamestate_team_t our_team, fawkes::worldinfo_gamestate_goalcolor_t our_goal_color, fawkes::worldinfo_gamestate_half_t half)
Gamestate information received.
void loop()
Code to execute in the thread.
virtual ~WorldInfoViewerBackendThread()
Destructor.
Avahi main thread.
Definition: avahi_thread.h:55
virtual void opponent_pose_rcvd(const char *from_host, unsigned int uid, float distance, float angle, float *covarianceconst)
Opponent information received.
Network name and address resolver.
Definition: resolver.h:48
virtual void ball_velocity_rcvd(const char *from_host, float vel_x, float vel_y, float vel_z, float *covariance)
Ball velocity information received.
worldinfo_gamestate_team_t
Team.
Definition: enums.h:54
virtual void velocity_rcvd(const char *from_host, float vel_x, float vel_y, float vel_theta, float *covariance)
Robot velocity information received.
virtual void ball_pos_rcvd(const char *from_host, bool visible, int visibility_history, float dist, float pitch, float yaw, float *covariance)
Ball position information received.
virtual void opponent_disapp_rcvd(const char *from_host, unsigned int uid)
Opponent disappeared.
virtual void penalty_rcvd(const char *from_host, unsigned int player, unsigned int penalty, unsigned int seconds_remaining)
Penalty info received.
The backend thread of the worldinfo viewer application.
worldinfo_gamestate_goalcolor_t
Goal color.
Definition: enums.h:63