23 #ifndef __TOOLS_WORLDINFO_VIEWER_DATA_CONTAINER_H_
24 #define __TOOLS_WORLDINFO_VIEWER_DATA_CONTAINER_H_
26 #include <geometry/matrix.h>
27 #include <geometry/hom_point.h>
28 #include <geometry/hom_polar.h>
29 #include <geometry/hom_pose_2d.h>
30 #include <core/utils/lock_map.h>
31 #include <core/utils/lock_list.h>
32 #include <netcomm/worldinfo/enums.h>
62 std::list<std::string>
get_hosts(
bool check_timeout_first =
false);
70 void set_robot_pose(
const char* from_host,
float x,
float y,
float theta,
78 float vel_x,
float vel_y,
float vel_theta,
83 void set_ball_pos(
const char* from_host,
bool visible,
int visibility_history,
84 float dist,
float bearing,
float slope,
float* covariance );
86 bool visible,
int visibility_history,
87 float x,
float y,
float z,
float* covariance );
95 float vel_x,
float vel_y,
float vel_z,
101 float distance,
float angle,
float* covariance );
104 std::map<unsigned int, HomPoint>& opp_positions );
109 unsigned int score_cyan,
110 unsigned int score_magenta,
136 virtual ~BallRecord();
138 void set_pos(
float dist,
float bearing,
float slope,
139 float* covariance = NULL );
140 void set_pos_global(
float x,
float y,
float z,
141 float* covariance = NULL );
142 void set_visible(
bool visible,
int visibility_history );
143 void set_velocity(
float vel_x,
float vel_y,
float vel_z,
144 float* covariance = NULL );
146 bool visible()
const;
147 int visibility_history()
const;
150 Matrix covariance_relative();
152 HomPoint pos_global(
float ref_x,
float ref_y,
float ref_theta );
153 HomVector vel_global(
float vel_x,
float vel_y,
float vel_theta,
163 int m_visibility_history;
171 virtual ~PoseRecord();
173 void set_pose(
float x,
float y,
float theta,
174 float* covariance = NULL );
175 void set_velocity(
float vel_x,
float vel_y,
float vel_theta,
176 float* covariance = NULL );
181 Matrix velocity_covariance();
187 Matrix m_velocity_covariance;
191 class OpponentsRecord
195 virtual ~OpponentsRecord();
197 void set_pos(
unsigned int opp_id,
float distance,
float bearing,
198 float* covariance = NULL );
199 void set_pos( HomPose2d robot_pose,
200 unsigned int opp_id,
float rel_dist,
float rel_bearing,
201 float* rel_covariance = NULL );
202 void disappeared(
unsigned int opp_id );
204 std::map<unsigned int, HomPoint> positions();
207 std::map<unsigned int, HomPoint> m_glob_opp_positions;
213 unsigned int get_host_id(std::string host);
214 void clock_in_host(
unsigned int id);
218 typedef LockMap<std::string, unsigned int> HostLockMap;
219 typedef LockList<std::string> HostLockList;
220 typedef LockMap<unsigned int, long> TimeLockMap;
221 typedef LockMap<unsigned int, BallRecord> BallLockMap;
222 typedef LockMap<unsigned int, PoseRecord> PoseLockMap;
223 typedef LockMap<unsigned int, OpponentsRecord> OpponentsLockMap;
226 unsigned int m_host_id;
229 HostLockList m_timedout_hosts;
230 TimeLockMap m_last_seen;
231 BallLockMap m_ball_positions;
232 PoseLockMap m_robot_poses;
233 OpponentsLockMap m_opponents;
235 GameState m_game_state;
242 bool m_new_data_available;
244 bool m_host_timedout;
Data container to store and exchange worldinfo data.
bool host_timedout()
Check whether a host has timed out.
bool get_ball_velocity(const char *from_host, HomVector &ball_vel)
Obtain ball velocity information for specified robot.
void set_timeout(long msec)
Set the time out.
~WorldInfoDataContainer()
Destructor.
GameState get_game_state() const
Obtain the game state.
float distance(float x1, float y1, float x2, float y2)
Get distance between two 2D cartesian coordinates.
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.
unsigned int get_own_score() const
Get own score.
unsigned int score_magenta
score of the magenta-colored team
A homogeneous representation of a polar coordinate.
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.
This is supposed to be the central clock in Fawkes.
bool check_timeout()
Check for timed out hosts.
A 2-dimensional pose, i.e.
worldinfo_gamestate_team_t get_own_team_color() const
Get own team color.
WorldInfoDataContainer(Clock *clock, long timeout_msec=3000)
Constructor.
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...
std::list< std::string > get_hosts(bool check_timeout_first=false)
Obtain the list of active hosts.
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.
std::string get_own_goal_color_string() const
Get own goal color as string.
bool new_data_available()
Check whehter new data is available.
worldinfo_gamestate_half_t
Game time half.
worldinfo_gamestate_goalcolor_t get_own_goal_color() const
Get own goal color.
std::string get_game_state_string() const
Get the current game state as string.
std::string get_half_string() const
Get the current half as string.
worldinfo_gamestate_team_t state_team
team association of the game state
std::list< std::string > get_timedout_hosts()
Obtain the list of timedout hosts.
bool get_opponent_pos(const char *host, std::map< unsigned int, HomPoint > &opp_positions)
Get all oppenents detected by a certain robot.
int game_state
current game state
worldinfo_gamestate_half_t half
first or second half
unsigned int score_cyan
socre of the cyan-colored team
bool get_robot_pose(const char *host, HomPose2d &robot_pose)
Obtain the pose of the given robot.
bool get_ball_pos_global(const char *host, HomPoint &ball_pos)
Get the global position of the ball as it is estimated by the specified robot.
unsigned int get_other_score() const
Get score of the other team.
void set_opponent_pos(const char *from_host, unsigned int uid, float distance, float angle, float *covariance)
Set the position of a detected opponent.
std::string get_own_team_color_string() const
Get own team color as string.
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.
worldinfo_gamestate_team_t
Team.
void set_robot_pose(const char *from_host, float x, float y, float theta, float *covariance)
Set the pose of a robot.
Container struct for momentary game state infos.
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.
bool get_robot_velocity(const char *host, HomVector &robot_vel)
Obtain current velocity of the specified robot.
bool get_ball_pos_relative(const char *host, HomPolar &ball_pos)
Get the ball position estimation of a certain robot.
bool new_host()
Check whether a new host has been added recently.
worldinfo_gamestate_goalcolor_t
Goal color.