Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
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
45
class
WorldModelNetworkThread
46
:
public
fawkes::Thread
,
47
public
fawkes::LoggingAspect
,
48
public
fawkes::ConfigurableAspect
,
49
public
fawkes::ClockAspect
,
50
public
fawkes::NetworkAspect
,
51
public
fawkes::BlackBoardAspect
,
52
public
fawkes::WorldInfoHandler
53
{
54
public
:
55
WorldModelNetworkThread
();
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,
99
fawkes::worldinfo_gamestate_team_t
state_team,
100
unsigned
int
score_cyan,
unsigned
int
score_magenta,
101
fawkes::worldinfo_gamestate_team_t
our_team,
102
fawkes::worldinfo_gamestate_goalcolor_t
our_goal_color,
103
fawkes::worldinfo_gamestate_half_t
half);
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
121
fawkes::LockMap<std::string, fawkes::ObjectPositionInterface *>
__pose_ifs;
122
fawkes::LockMap<std::string, fawkes::ObjectPositionInterface *>
__ball_ifs;
123
//host -> (uid -> if)
124
fawkes::LockMap<std::string, UidTimeObjPosMap >
__opponent_ifs;
125
fawkes::GameStateInterface
* __gamestate_if;
126
127
unsigned
int
__opponent_id;
128
129
// host -> time
130
fawkes::LockMap<std::string, fawkes::Time>
__last_seen;
131
};
132
133
134
#endif
src
plugins
worldmodel
net_thread.h
Generated by
1.8.3.1