Data container to store and exchange worldinfo data. More...
#include <>>
Classes | |
class | BallRecord |
struct | GameState |
Container struct for momentary game state infos. More... | |
class | OpponentsRecord |
class | PoseRecord |
Public Member Functions | |
WorldInfoDataContainer (Clock *clock, long timeout_msec=3000) | |
Constructor. | |
~WorldInfoDataContainer () | |
Destructor. | |
bool | check_timeout () |
Check for timed out hosts. | |
void | set_timeout (long msec) |
Set the time out. | |
std::list< std::string > | get_hosts (bool check_timeout_first=false) |
Obtain the list of active hosts. | |
std::list< std::string > | get_timedout_hosts () |
Obtain the list of timedout hosts. | |
bool | new_data_available () |
Check whehter new data is available. | |
bool | new_host () |
Check whether a new host has been added recently. | |
bool | host_timedout () |
Check whether a host has timed out. | |
void | set_robot_pose (const char *from_host, float x, float y, float theta, float *covariance) |
Set the pose of a robot. | |
bool | get_robot_pose (const char *host, HomPose2d &robot_pose) |
Obtain the pose of the given robot. | |
bool | get_robot_pose (const char *host, HomPose2d &robot_pose, Matrix &robot_pose_cov) |
Get the position of a certain robot. | |
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. | |
bool | get_robot_velocity (const char *host, HomVector &robot_vel) |
Obtain current velocity of the specified robot. | |
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. | |
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. | |
bool | get_ball_pos_relative (const char *host, HomPolar &ball_pos) |
Get the ball position estimation of a certain robot. | |
bool | get_ball_pos_relative (const char *host, HomPolar &ball_pos, Matrix &ball_pos_cov) |
Get the ball position estimation of a certain 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. | |
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. | |
bool | get_ball_velocity (const char *from_host, HomVector &ball_vel) |
Obtain ball velocity information for specified robot. | |
void | set_opponent_pos (const char *from_host, unsigned int uid, float distance, float angle, float *covariance) |
Set the position of a detected opponent. | |
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. | |
bool | get_opponent_pos (const char *host, std::map< unsigned int, HomPoint > &opp_positions) |
Get all oppenents detected by a certain robot. | |
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. | |
GameState | get_game_state () const |
Obtain the game state. | |
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. | |
unsigned int | get_own_score () const |
Get own score. | |
unsigned int | get_other_score () const |
Get score of the other team. | |
worldinfo_gamestate_team_t | get_own_team_color () const |
Get own team color. | |
std::string | get_own_team_color_string () const |
Get own team color as string. | |
worldinfo_gamestate_goalcolor_t | get_own_goal_color () const |
Get own goal color. | |
std::string | get_own_goal_color_string () const |
Get own goal color as string. |
Data container to store and exchange worldinfo data.
Definition at line 43 of file data_container.h.
fawkes::WorldInfoDataContainer::WorldInfoDataContainer | ( | Clock * | clock, | |
long | timeout_msec = 3000 | |||
) |
Constructor.
clock | pointer to a Clock | |
timeout_msec | timeout in milliseconds |
Definition at line 253 of file data_container.cpp.
References fawkes::WorldInfoDataContainer::GameState::game_state, fawkes::WorldInfoDataContainer::GameState::half, fawkes::WorldInfoDataContainer::GameState::score_cyan, fawkes::WorldInfoDataContainer::GameState::score_magenta, and fawkes::WorldInfoDataContainer::GameState::state_team.
fawkes::WorldInfoDataContainer::~WorldInfoDataContainer | ( | ) |
Destructor.
Definition at line 276 of file data_container.cpp.
bool fawkes::WorldInfoDataContainer::check_timeout | ( | ) |
Check for timed out hosts.
This method should be called regularly to remove hosts from the data container from which no data has been received in a certain amount of time.
Definition at line 287 of file data_container.cpp.
References fawkes::Time::in_msec(), fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), fawkes::LockList< Type >::lock(), fawkes::Time::stamp(), fawkes::LockMap< KeyType, ValueType, LessKey >::unlock(), and fawkes::LockList< Type >::unlock().
Referenced by get_hosts(), and WorldInfoViewer::update().
bool fawkes::WorldInfoDataContainer::get_ball_pos_global | ( | const char * | host, | |
HomPoint & | pos | |||
) |
Get the global position of the ball as it is estimated by the specified robot.
host | the robot's hostname | |
pos | refercence to a HomPoint where the position of the ball written to |
Definition at line 710 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), fawkes::LockMap< KeyType, ValueType, LessKey >::unlock(), fawkes::HomPose2d::x(), fawkes::HomPose2d::y(), and fawkes::HomPose2d::yaw().
Referenced by FieldView::on_expose_event().
bool fawkes::WorldInfoDataContainer::get_ball_pos_relative | ( | const char * | host, | |
HomPolar & | pos, | |||
Matrix & | pos_cov | |||
) |
Get the ball position estimation of a certain robot.
host | the hostname of the robot | |
pos | reference to a HomPolar where the position is written to | |
pos_cov | reference to a Matrix where the ball position covariance is written to |
Definition at line 680 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
bool fawkes::WorldInfoDataContainer::get_ball_pos_relative | ( | const char * | host, | |
HomPolar & | pos | |||
) |
Get the ball position estimation of a certain robot.
host | the hostname of the robot | |
pos | reference to a HomPolar where the position is written to |
Definition at line 652 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by FieldView::on_expose_event().
bool fawkes::WorldInfoDataContainer::get_ball_velocity | ( | const char * | host, | |
HomVector & | ball_vel | |||
) |
Obtain ball velocity information for specified robot.
host | the hostname of the robot | |
ball_vel | refrence to a HomVector where the velocity information is written to |
Definition at line 784 of file data_container.cpp.
WorldInfoDataContainer::GameState fawkes::WorldInfoDataContainer::get_game_state | ( | ) | const |
Obtain the game state.
Definition at line 912 of file data_container.cpp.
std::string fawkes::WorldInfoDataContainer::get_game_state_string | ( | ) | const |
Get the current game state as string.
Definition at line 921 of file data_container.cpp.
References fawkes::WorldInfoDataContainer::GameState::game_state, fawkes::WorldInfoDataContainer::GameState::state_team, fawkes::worldinfo_gamestate_team_tostring(), and fawkes::worldinfo_msl_gamestate_tostring().
Referenced by WorldInfoViewer::gamestate_changed().
std::string fawkes::WorldInfoDataContainer::get_half_string | ( | ) | const |
Get the current half as string.
Definition at line 939 of file data_container.cpp.
References fawkes::WorldInfoDataContainer::GameState::half, and fawkes::worldinfo_gamestate_half_tostring().
Referenced by WorldInfoViewer::gamestate_changed().
std::list< std::string > fawkes::WorldInfoDataContainer::get_hosts | ( | bool | check_timeout_first = false |
) |
Obtain the list of active hosts.
check_timeout_first | if true check_timeout() is called before the list is compiled |
Definition at line 347 of file data_container.cpp.
References check_timeout(), fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by FieldView::on_expose_event(), and WorldInfoViewer::update().
bool fawkes::WorldInfoDataContainer::get_opponent_pos | ( | const char * | host, | |
std::map< unsigned int, HomPoint > & | opp_positions | |||
) |
Get all oppenents detected by a certain robot.
host | hostname of the robot | |
opp_positions | map containing the positions of the detected opponents |
Definition at line 862 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by FieldView::on_expose_event().
unsigned int fawkes::WorldInfoDataContainer::get_other_score | ( | ) | const |
Get score of the other team.
Definition at line 962 of file data_container.cpp.
References fawkes::WorldInfoDataContainer::GameState::score_cyan, fawkes::WorldInfoDataContainer::GameState::score_magenta, and fawkes::TEAM_CYAN.
Referenced by WorldInfoViewer::gamestate_changed().
worldinfo_gamestate_goalcolor_t fawkes::WorldInfoDataContainer::get_own_goal_color | ( | ) | const |
Get own goal color.
Definition at line 994 of file data_container.cpp.
std::string fawkes::WorldInfoDataContainer::get_own_goal_color_string | ( | ) | const |
Get own goal color as string.
Definition at line 1003 of file data_container.cpp.
References fawkes::worldinfo_gamestate_goalcolor_tostring().
Referenced by WorldInfoViewer::gamestate_changed().
unsigned int fawkes::WorldInfoDataContainer::get_own_score | ( | ) | const |
Get own score.
Definition at line 950 of file data_container.cpp.
References fawkes::WorldInfoDataContainer::GameState::score_cyan, fawkes::WorldInfoDataContainer::GameState::score_magenta, and fawkes::TEAM_CYAN.
Referenced by WorldInfoViewer::gamestate_changed().
worldinfo_gamestate_team_t fawkes::WorldInfoDataContainer::get_own_team_color | ( | ) | const |
Get own team color.
Definition at line 974 of file data_container.cpp.
std::string fawkes::WorldInfoDataContainer::get_own_team_color_string | ( | ) | const |
Get own team color as string.
Definition at line 983 of file data_container.cpp.
References fawkes::worldinfo_gamestate_team_tostring().
Referenced by WorldInfoViewer::gamestate_changed().
bool fawkes::WorldInfoDataContainer::get_robot_pose | ( | const char * | host, | |
HomPose2d & | pose | |||
) |
Obtain the pose of the given robot.
host | the hostname of the robot | |
pose | reference to a HomPose where the pose will be stored |
Definition at line 460 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by FieldView::on_expose_event().
bool fawkes::WorldInfoDataContainer::get_robot_pose | ( | const char * | host, | |
HomPose2d & | pose, | |||
Matrix & | pose_cov | |||
) |
Get the position of a certain robot.
host | the hostname of the robot | |
pose | reference to a HomPoint where the global position of the robot is written to | |
pose_cov | reference to a Matrix where the covariance of the robot position is written to |
Definition at line 489 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
bool fawkes::WorldInfoDataContainer::get_robot_velocity | ( | const char * | host, | |
HomVector & | robot_vel | |||
) |
Obtain current velocity of the specified robot.
host | the hostname of the robot | |
robot_vel | reference to a HomVector where the velocity information is written to |
Definition at line 555 of file data_container.cpp.
std::list< std::string > fawkes::WorldInfoDataContainer::get_timedout_hosts | ( | ) |
Obtain the list of timedout hosts.
Hosts that have been marked as timedout in the last call of check_timeout().
Definition at line 370 of file data_container.cpp.
References fawkes::LockList< Type >::lock(), and fawkes::LockList< Type >::unlock().
Referenced by WorldInfoViewer::update().
bool fawkes::WorldInfoDataContainer::host_timedout | ( | ) |
Check whether a host has timed out.
Definition at line 410 of file data_container.cpp.
bool fawkes::WorldInfoDataContainer::new_data_available | ( | ) |
Check whehter new data is available.
Definition at line 388 of file data_container.cpp.
Referenced by WorldInfoViewer::update().
bool fawkes::WorldInfoDataContainer::new_host | ( | ) |
Check whether a new host has been added recently.
Definition at line 399 of file data_container.cpp.
void fawkes::WorldInfoDataContainer::opponent_disappeared | ( | const char * | host, | |
unsigned int | uid | |||
) |
Remove the opponent with the given ID form the list of opponents seen by the given robot.
host | the hostname of the robot | |
uid | the uid of the opponent |
Definition at line 840 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by WorldInfoViewerBackendThread::opponent_disapp_rcvd().
void fawkes::WorldInfoDataContainer::set_ball_pos | ( | const char * | host, | |
bool | visible, | |||
int | visibility_history, | |||
float | dist, | |||
float | bearing, | |||
float | slope, | |||
float * | covariance | |||
) |
Set the ball position estimation of a robot.
host | the hostname of the robot | |
visible | visible or not | |
visibility_history | visible/not visible for n iterations | |
dist | distance to the robot | |
bearing | vertical angle to the ball | |
slope | the horizontal angle to the ball | |
covariance | covariance associated with the position estimation |
Definition at line 573 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by WorldInfoViewerBackendThread::ball_pos_rcvd().
void fawkes::WorldInfoDataContainer::set_ball_pos_global | ( | const char * | host, | |
bool | visible, | |||
int | visibility_history, | |||
float | x, | |||
float | y, | |||
float | z, | |||
float * | covariance | |||
) |
Set the global ball position estimation of a robot.
host | the hostname of the robot | |
visible | visible or not | |
visibility_history | visible/not visible for n iterations | |
x | the x-coordinte of the global ball position | |
y | the y-coordinte of the global ball position | |
z | the z-coordinte of the global ball position | |
covariance | covariance associated with the position estimation |
Definition at line 614 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by WorldInfoViewerBackendThread::global_ball_pos_rcvd().
void fawkes::WorldInfoDataContainer::set_ball_velocity | ( | const char * | host, | |
float | vel_x, | |||
float | vel_y, | |||
float | vel_z, | |||
float * | covariance | |||
) |
Set the ball velocity as it is estimated by the specified robot.
host | the hostname of the robot | |
vel_x | the ball velocity in x-direction of the robot-centered coordinate system | |
vel_y | the ball velocity in y-direction of the robot-centered coordinate system | |
vel_z | the ball velocity in z-direction of the robot-centered coordinate system | |
covariance | ball velocity covariance |
Definition at line 748 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by WorldInfoViewerBackendThread::ball_velocity_rcvd().
void fawkes::WorldInfoDataContainer::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.
game_state | the current game state | |
state_team | team association of the game state | |
score_cyan | score of the cyan-colored team | |
score_magenta | score of the magenta-colored team | |
own_team | own team color | |
own_goal_color | own goal color | |
half | first or second half |
Definition at line 890 of file data_container.cpp.
References fawkes::WorldInfoDataContainer::GameState::game_state, fawkes::WorldInfoDataContainer::GameState::half, fawkes::WorldInfoDataContainer::GameState::score_cyan, fawkes::WorldInfoDataContainer::GameState::score_magenta, and fawkes::WorldInfoDataContainer::GameState::state_team.
Referenced by WorldInfoViewerBackendThread::gamestate_rcvd().
void fawkes::WorldInfoDataContainer::set_opponent_pos | ( | const char * | host, | |
unsigned int | uid, | |||
float | distance, | |||
float | angle, | |||
float * | covariance | |||
) |
Set the position of a detected opponent.
host | hostname of the robot that detected the robot | |
uid | opponent id | |
distance | distance to the robot | |
angle | angle at which the opponent is detected | |
covariance | corresponding covariance matrix |
Definition at line 799 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by WorldInfoViewerBackendThread::opponent_pose_rcvd().
void fawkes::WorldInfoDataContainer::set_robot_pose | ( | const char * | host, | |
float | x, | |||
float | y, | |||
float | theta, | |||
float * | covariance | |||
) |
Set the pose of a robot.
host | the hostname of the robot | |
x | the x-coordinate of the robot's global position | |
y | the y-coordinate of the robot's global position | |
theta | the global orientation of the robot | |
covariance | covariance associated with the position estimation |
Definition at line 427 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by WorldInfoViewerBackendThread::pose_rcvd().
void fawkes::WorldInfoDataContainer::set_robot_velocity | ( | const char * | host, | |
float | vel_x, | |||
float | vel_y, | |||
float | vel_theta, | |||
float * | covariance | |||
) |
Set the velocity of the robot.
host | the hostname of the robot | |
vel_x | the current forward velocity of the robot | |
vel_y | the current sideward velocity of the robot | |
vel_theta | the current rotational velociy of the robot | |
covariance | the velocity covariance |
Definition at line 519 of file data_container.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by WorldInfoViewerBackendThread::velocity_rcvd().
void fawkes::WorldInfoDataContainer::set_timeout | ( | long | msec | ) |
Set the time out.
msec | time out value in milliseconds |
Definition at line 336 of file data_container.cpp.