24 #ifndef __NETCOMM_WORLDINFO_TRANSCEIVER_H_
25 #define __NETCOMM_WORLDINFO_TRANSCEIVER_H_
27 #include <core/exception.h>
28 #include <core/utils/lock_list.h>
30 #include <netcomm/worldinfo/handler.h>
31 #include <netcomm/worldinfo/defs.h>
32 #include <netcomm/worldinfo/messages.h>
42 class WorldInfoMessageEncryptor;
43 class WorldInfoMessageDecryptor;
44 class NetworkNameResolver;
62 const char *addr,
unsigned short port,
63 const char *key,
const char *iv,
72 void set_pose(
float x,
float y,
float theta,
float *covariance);
73 void set_velocity(
float vel_x,
float vel_y,
float vel_theta,
float *covariance);
75 void set_rel_ball_pos(
float dist,
float bearing,
float slope,
float *covariance);
84 void set_score(
unsigned int score_cyan,
unsigned int score_magenta);
88 void add_penalty(
unsigned int player,
unsigned int penalty,
89 unsigned int seconds_remaining);
96 void recv(
bool block =
false,
unsigned int max_num_msgs = 0);
107 void reset_outbound();
108 void crypt_outbound();
109 void append_outbound(uint16_t msg_type,
void *msg, uint16_t msg_size);
118 bool resolver_delete;
122 void *crypted_out_buffer;
123 void *crypted_in_buffer;
124 size_t crypt_buffer_size;
126 size_t crypted_out_bytes;
127 size_t crypted_in_bytes;
133 size_t fatmsg_bufsize;
138 unsigned int out_seq;
141 unsigned char *outbound_buffer;
142 unsigned int outbound_bytes;
143 unsigned int outbound_num_msgs;
145 unsigned char *inbound_buffer;
146 size_t inbound_bytes;
152 float *pose_covariance;
158 float *vel_covariance;
160 bool rel_ball_changed;
161 bool rel_ball_visible;
162 int rel_ball_visibility_history;
164 float rel_ball_bearing;
165 float rel_ball_slope;
166 float *rel_ball_covariance;
168 bool rel_ball_vel_changed;
169 float rel_ball_vel_x;
170 float rel_ball_vel_y;
171 float rel_ball_vel_z;
172 float *rel_ball_vel_covariance;
174 bool glob_ball_changed;
175 bool glob_ball_visible;
176 int glob_ball_visibility_history;
180 float *glob_ball_covariance;
182 bool glob_ball_vel_changed;
183 float glob_ball_vel_x;
184 float glob_ball_vel_y;
185 float glob_ball_vel_z;
186 float *glob_ball_vel_covariance;
188 bool gamestate_changed;
199 std::list<opponent_t> opponents;
200 std::list<opponent_t>::iterator oppit;
202 std::list<unsigned int> disappeared_opponents;
203 std::list<unsigned int>::iterator doppit;
205 std::map<unsigned int, worldinfo_penalty_message_t> penalties;
206 std::map<unsigned int, worldinfo_penalty_message_t>::iterator penit;
208 LockList<WorldInfoHandler *> handlers;
209 LockList<WorldInfoHandler *>::iterator hit;
212 std::map<uint32_t, unsigned int> sequence_numbers;
213 std::map<uint32_t, time_t> last_received_time;
214 std::map<uint32_t, time_t>::iterator lrtit;
void set_rel_ball_pos(float dist, float bearing, float slope, float *covariance)
Set ball position.
void set_glob_ball_velocity(float vel_x, float vel_y, float vel_z, float *covariance)
Set global ball velocity.
void clear_opponents()
Clear opponents list.
void add_disappeared_opponent(unsigned int uid)
Add disappeared opponent.
void send()
Send information.
WorldInfoException(const char *msg)
Constructor.
Class to send and receive world information.
float distance(float x1, float y1, float x2, float y2)
Get distance between two 2D cartesian coordinates.
void set_team_goal(worldinfo_gamestate_team_t our_color, worldinfo_gamestate_goalcolor_t goal_color)
Set team and goal info.
void set_half(worldinfo_gamestate_half_t half)
Set current half of the game time.
WorldInfo message decryptor.
void set_glob_ball_pos(float x, float y, float z, float *covariance)
Set global ball position.
Fawkes library namespace.
void set_rel_ball_velocity(float vel_x, float vel_y, float vel_z, float *covariance)
Set ball velocity.
void add_opponent(unsigned int uid, float distance, float bearing, float *covariance)
Add opponent to transmit list.
worldinfo_gamestate_half_t
Game time half.
size_t last_sent_plain_buffer_size()
Get last sent plain buffer size.
void add_penalty(unsigned int player, unsigned int penalty, unsigned int seconds_remaining)
Add penalty message.
void set_pose(float x, float y, float theta, float *covariance)
Set global pose of robot.
Base class for exceptions in Fawkes.
Use multicast socket for communication.
void * last_sent_crypted_buffer()
Get last sent crypted buffer.
void set_loop(bool loop)
Set loopback of sent packets.
Thrown on critical errors in world info handling.
void set_rel_ball_visible(bool visible, int visibility_history)
Set ball visibility.
void * last_sent_plain_buffer()
Get last sent plain buffer.
void rem_handler(WorldInfoHandler *h)
Remove handler for world information.
void set_score(unsigned int score_cyan, unsigned int score_magenta)
Set score.
void recv(bool block=false, unsigned int max_num_msgs=0)
Receive information.
~WorldInfoTransceiver()
Destructor.
void flush_sequence_numbers(unsigned int sec)
Flush sequence numbers conditionally.
Network name and address resolver.
void set_gamestate(int gamestate, worldinfo_gamestate_team_t state_team)
Set current game state.
worldinfo_gamestate_team_t
Team.
WorldInfo message encryptor.
void set_glob_ball_visible(bool visible, int visibility_history)
Set ball visibility for the global ball.
void add_handler(WorldInfoHandler *h)
Add a handler for world information.
Use broadcase socket for communication.
size_t last_sent_crypted_buffer_size()
Get last sent crypted buffer size.
void set_velocity(float vel_x, float vel_y, float vel_theta, float *covariance)
Set velocity of the robot.
WorldInfoTransceiver(SocketType socket_type, const char *addr, unsigned short port, const char *key, const char *iv, NetworkNameResolver *resolver=NULL)
Constructor.
worldinfo_gamestate_goalcolor_t
Goal color.
void set_fatmsg_enabled(bool fatmsg_enabled)
Enable or disable sending of fat message.