23 #include "backend_thread.h" 24 #include <worldinfo_utils/data_container.h> 25 #include <netcomm/worldinfo/transceiver.h> 47 :
Thread(
"WorldInfoViewerBackendThread")
49 m_data_container = data_container;
88 return m_signal_new_worldinfo_data;
98 return m_signal_new_gamestate_data;
105 m_transceiver->
recv(
true, 100);
117 printf(
"Received pose data from host %s: x=%.3f y=%.3f theta=%.3f\n",
118 from_host, x, y, theta );
121 m_data_container->
set_robot_pose( from_host, x, y, theta, covariance );
122 m_signal_new_worldinfo_data();
133 printf(
"Received velocity data from host %s: vx=%.3f vy=%.3f vtheta=%.3f\n",
134 from_host, vel_x, vel_y, vel_theta );
139 m_signal_new_worldinfo_data();
145 int visibility_history,
153 { printf(
"Received ball data from host %s: dist=%.3f bearing=%.3f\n",
154 from_host, dist, bearing ); }
156 { printf(
"Received ball not visible from host %s\n", from_host ); }
159 m_data_container->
set_ball_pos( from_host, visible, visibility_history,
160 dist, bearing, slope, covariance );
161 m_signal_new_worldinfo_data();
167 int visibility_history,
175 { printf(
"Received global ball data from host %s: x=%.3f y=%.3f\n",
178 { printf(
"Received global ball not visible from host %s\n", from_host ); }
182 x, y, z, covariance );
183 m_signal_new_worldinfo_data();
195 m_signal_new_worldinfo_data();
226 m_signal_new_worldinfo_data();
235 m_signal_new_worldinfo_data();
241 unsigned int game_state,
243 unsigned int score_cyan,
244 unsigned int score_magenta,
250 printf(
"Received gamestate data from host %s\n", from_host );
254 score_cyan, score_magenta,
255 own_team, own_goal_color, half );
256 m_signal_new_gamestate_data();
262 unsigned int penalty,
263 unsigned int seconds_remaining)
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.
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.
void set_ball_velocity(const char *from_host, float vel_x, float vel_y, float vel_z, float *covariance)
Set the ball velocity as it is estimated by the specified robot.
Fawkes library namespace.
void set_ball_pos_global(const char *from_host, bool visible, int visibility_history, float x, float y, float z, float *covariance)
Set the global ball position estimation of a robot.
void opponent_disappeared(const char *from_host, unsigned int uid)
Remove the opponent with the given ID form the list of opponents seen by the given robot...
Thread class encapsulation of pthreads.
void set_game_state(int game_state, worldinfo_gamestate_team_t state_team, unsigned int score_cyan, unsigned int score_magenta, worldinfo_gamestate_team_t own_team, worldinfo_gamestate_goalcolor_t own_goal_color, worldinfo_gamestate_half_t half)
Set the gamestate.
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.
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.
void recv(bool block=false, unsigned int max_num_msgs=0)
Receive information.
void cancel()
Cancel a thread.
void flush_sequence_numbers(unsigned int sec)
Flush sequence numbers conditionally.
virtual void opponent_pose_rcvd(const char *from_host, unsigned int uid, float distance, float angle, float *covarianceconst)
Opponent information received.
void set_opponent_pos(const char *from_host, unsigned int uid, float distance, float angle, float *covariance)
Set the position of a detected opponent.
Network name and address resolver.
void set_robot_velocity(const char *from_host, float vel_x, float vel_y, float vel_theta, float *covariance)
Set the velocity of the robot.
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.
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.
void set_robot_pose(const char *from_host, float x, float y, float theta, float *covariance)
Set the pose of a robot.
void join()
Join the thread.
void add_handler(WorldInfoHandler *h)
Add a handler for world information.
void set_ball_pos(const char *from_host, bool visible, int visibility_history, float dist, float bearing, float slope, float *covariance)
Set the ball position estimation of a robot.
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.
worldinfo_gamestate_goalcolor_t
Goal color.
void start(bool wait=true)
Call this method to start the thread.