Fawkes API
Fawkes Development Version
|
GameStateInterface Fawkes BlackBoard Interface. More...
#include <>>
Classes | |
class | SetKickoffMessage |
SetKickoffMessage Fawkes BlackBoard Interface Message. More... | |
class | SetStateTeamMessage |
SetStateTeamMessage Fawkes BlackBoard Interface Message. More... | |
class | SetTeamColorMessage |
SetTeamColorMessage Fawkes BlackBoard Interface Message. More... | |
Public Types | |
enum | if_gamestate_team_t { TEAM_NONE, TEAM_CYAN, TEAM_MAGENTA, TEAM_BOTH } |
Enumeration defining the different teams. More... | |
enum | if_gamestate_goalcolor_t { GOAL_BLUE, GOAL_YELLOW } |
Enumeration defining the different teams. More... | |
enum | if_gamestate_half_t { HALF_FIRST, HALF_SECOND } |
Enumeration defining the different teams. More... | |
enum | if_gamestate_role_t { ROLE_GOALIE, ROLE_DEFENDER, ROLE_MID_LEFT, ROLE_MID_RIGHT, ROLE_ATTACKER } |
Enumeration defining the different robot roles. More... | |
Public Member Functions | |
const char * | tostring_if_gamestate_team_t (if_gamestate_team_t value) const |
Convert if_gamestate_team_t constant to string. More... | |
const char * | tostring_if_gamestate_goalcolor_t (if_gamestate_goalcolor_t value) const |
Convert if_gamestate_goalcolor_t constant to string. More... | |
const char * | tostring_if_gamestate_half_t (if_gamestate_half_t value) const |
Convert if_gamestate_half_t constant to string. More... | |
const char * | tostring_if_gamestate_role_t (if_gamestate_role_t value) const |
Convert if_gamestate_role_t constant to string. More... | |
virtual bool | message_valid (const Message *message) const |
Check if message is valid and can be enqueued. More... | |
uint32_t | game_state () const |
Get game_state value. More... | |
void | set_game_state (const uint32_t new_game_state) |
Set game_state value. More... | |
size_t | maxlenof_game_state () const |
Get maximum length of game_state value. More... | |
if_gamestate_team_t | state_team () const |
Get state_team value. More... | |
void | set_state_team (const if_gamestate_team_t new_state_team) |
Set state_team value. More... | |
size_t | maxlenof_state_team () const |
Get maximum length of state_team value. More... | |
if_gamestate_team_t | our_team () const |
Get our_team value. More... | |
void | set_our_team (const if_gamestate_team_t new_our_team) |
Set our_team value. More... | |
size_t | maxlenof_our_team () const |
Get maximum length of our_team value. More... | |
if_gamestate_goalcolor_t | our_goal_color () const |
Get our_goal_color value. More... | |
void | set_our_goal_color (const if_gamestate_goalcolor_t new_our_goal_color) |
Set our_goal_color value. More... | |
size_t | maxlenof_our_goal_color () const |
Get maximum length of our_goal_color value. More... | |
if_gamestate_half_t | half () const |
Get half value. More... | |
void | set_half (const if_gamestate_half_t new_half) |
Set half value. More... | |
size_t | maxlenof_half () const |
Get maximum length of half value. More... | |
bool | is_kickoff () const |
Get kickoff value. More... | |
void | set_kickoff (const bool new_kickoff) |
Set kickoff value. More... | |
size_t | maxlenof_kickoff () const |
Get maximum length of kickoff value. More... | |
if_gamestate_role_t | role () const |
Get role value. More... | |
void | set_role (const if_gamestate_role_t new_role) |
Set role value. More... | |
size_t | maxlenof_role () const |
Get maximum length of role value. More... | |
uint32_t | score_cyan () const |
Get score_cyan value. More... | |
void | set_score_cyan (const uint32_t new_score_cyan) |
Set score_cyan value. More... | |
size_t | maxlenof_score_cyan () const |
Get maximum length of score_cyan value. More... | |
uint32_t | score_magenta () const |
Get score_magenta value. More... | |
void | set_score_magenta (const uint32_t new_score_magenta) |
Set score_magenta value. More... | |
size_t | maxlenof_score_magenta () const |
Get maximum length of score_magenta value. More... | |
virtual Message * | create_message (const char *type) const |
Create message based on type name. More... | |
virtual void | copy_values (const Interface *other) |
Copy values from other interface. More... | |
virtual const char * | enum_tostring (const char *enumtype, int val) const |
Convert arbitrary enum value to string. More... | |
![]() | |
virtual | ~Interface () |
Destructor. More... | |
bool | oftype (const char *interface_type) const |
Check if interface is of given type. More... | |
const void * | datachunk () const |
Get data chunk. More... | |
unsigned int | datasize () const |
Get data size. More... | |
const char * | type () const |
Get type of interface. More... | |
const char * | id () const |
Get identifier of interface. More... | |
const char * | uid () const |
Get unique identifier of interface. More... | |
unsigned short | serial () const |
Get instance serial of interface. More... | |
unsigned int | mem_serial () const |
Get memory serial of interface. More... | |
bool | operator== (Interface &comp) const |
Check equality of two interfaces. More... | |
const unsigned char * | hash () const |
Get interface hash. More... | |
size_t | hash_size () const |
Get size of interface hash. More... | |
const char * | hash_printable () const |
Get printable interface hash. More... | |
bool | is_writer () const |
Check if this is a writing instance. More... | |
void | set_validity (bool valid) |
Mark this interface invalid. More... | |
bool | is_valid () const |
Check validity of interface. More... | |
const char * | owner () const |
Get owner of interface. More... | |
void | set_from_chunk (void *chunk) |
Set from a raw data chunk. More... | |
void | resize_buffers (unsigned int num_buffers) |
Resize buffer array. More... | |
unsigned int | num_buffers () const |
Get number of buffers. More... | |
void | copy_shared_to_buffer (unsigned int buffer) |
Copy data from private memory to buffer. More... | |
void | copy_private_to_buffer (unsigned int buffer) |
Copy data from private memory to buffer. More... | |
void | read_from_buffer (unsigned int buffer) |
Copy data from buffer to private memory. More... | |
int | compare_buffers (unsigned int buffer) |
Compare buffer to private memory. More... | |
Time | buffer_timestamp (unsigned int buffer) |
Get time of a buffer. More... | |
void | buffer_timestamp (unsigned int buffer, Time *timestamp) |
Get time of a buffer. More... | |
void | read () |
Read from BlackBoard into local copy. More... | |
void | write () |
Write from local copy into BlackBoard memory. More... | |
bool | has_writer () const |
Check if there is a writer for the interface. More... | |
unsigned int | num_readers () const |
Get the number of readers. More... | |
std::string | writer () const |
Get owner name of writing interface instance. More... | |
std::list< std::string > | readers () const |
Get owner names of reading interface instances. More... | |
bool | changed () const |
Check if data has been changed. More... | |
const Time * | timestamp () const |
Get timestamp of last write. More... | |
void | set_auto_timestamping (bool enabled) |
Enable or disable automated timestamping. More... | |
void | set_timestamp (const Time *t=NULL) |
Set timestamp. More... | |
void | set_clock (Clock *clock) |
Set clock to use for timestamping. More... | |
void | mark_data_changed () |
Mark data as changed. More... | |
std::list< const char * > | get_message_types () |
Obtain a list of textual representations of the message types available for this interface. More... | |
unsigned int | msgq_enqueue (Message *message) |
Enqueue message at end of queue. More... | |
unsigned int | msgq_enqueue_copy (Message *message) |
Enqueue copy of message at end of queue. More... | |
void | msgq_remove (Message *message) |
Remove message from queue. More... | |
void | msgq_remove (unsigned int message_id) |
Remove message from queue. More... | |
unsigned int | msgq_size () |
Get size of message queue. More... | |
void | msgq_flush () |
Flush all messages. More... | |
void | msgq_lock () |
Lock message queue. More... | |
bool | msgq_try_lock () |
Try to lock message queue. More... | |
void | msgq_unlock () |
Unlock message queue. More... | |
void | msgq_pop () |
Erase first message from queue. More... | |
Message * | msgq_first () |
Get the first message from the message queue. More... | |
bool | msgq_empty () |
Check if queue is empty. More... | |
void | msgq_append (Message *message) |
Enqueue message. More... | |
template<class MessageType > | |
bool | msgq_first_is () |
Check if first message has desired type. More... | |
template<class MessageType > | |
MessageType * | msgq_first () |
Get first message casted to the desired type. More... | |
template<class MessageType > | |
MessageType * | msgq_first (MessageType *&msg) |
Get first message casted to the desired type. More... | |
template<class MessageType > | |
MessageType * | msgq_first_safe (MessageType *&msg) throw () |
Get first message casted to the desired type without exceptions. More... | |
MessageQueue::MessageIterator | msgq_begin () |
Get start iterator for message queue. More... | |
MessageQueue::MessageIterator | msgq_end () |
Get end iterator for message queue. More... | |
InterfaceFieldIterator | fields () |
Get iterator over all fields of this interface instance. More... | |
InterfaceFieldIterator | fields_end () |
Invalid iterator. More... | |
unsigned int | num_fields () |
Get the number of fields in the interface. More... | |
Static Public Attributes | |
static const uint32_t | GS_FROZEN = 0u |
GS_FROZEN constant. More... | |
static const uint32_t | GS_PLAY = 1u |
GS_PLAY constant. More... | |
static const uint32_t | GS_KICK_OFF = 2u |
GS_KICK_OFF constant. More... | |
static const uint32_t | GS_DROP_BALL = 3u |
GS_DROP_BALL constant. More... | |
static const uint32_t | GS_PENALTY = 4u |
GS_PENALTY constant. More... | |
static const uint32_t | GS_CORNER_KICK = 5u |
GS_CORNER_KICK constant. More... | |
static const uint32_t | GS_THROW_IN = 6u |
GS_THROW_IN constant. More... | |
static const uint32_t | GS_FREE_KICK = 7u |
GS_FREE_KICK constant. More... | |
static const uint32_t | GS_GOAL_KICK = 8u |
GS_GOAL_KICK constant. More... | |
static const uint32_t | GS_HALF_TIME = 9u |
GS_HALF_TIME constant. More... | |
static const uint32_t | GS_SPL_INITIAL = 0u |
GS_SPL_INITIAL constant. More... | |
static const uint32_t | GS_SPL_READY = 1u |
GS_SPL_READY constant. More... | |
static const uint32_t | GS_SPL_SET = 2u |
GS_SPL_SET constant. More... | |
static const uint32_t | GS_SPL_PLAY = 3u |
GS_SPL_PLAY constant. More... | |
static const uint32_t | GS_SPL_FINISHED = 4u |
GS_SPL_FINISHED constant. More... | |
Additional Inherited Members | |
![]() | |
static void | parse_uid (const char *uid, std::string &type, std::string &id) |
Parse UID to type and ID strings. More... | |
![]() | |
Interface () | |
Constructor. More... | |
void | set_hash (unsigned char *ihash) |
Set hash. More... | |
void | add_fieldinfo (interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0) |
Add an entry to the field info list. More... | |
void | add_messageinfo (const char *name) |
Add an entry to the message info list. More... | |
![]() | |
void * | data_ptr |
Pointer to local memory storage. More... | |
unsigned int | data_size |
Minimal data size to hold data storage. More... | |
bool | data_changed |
Indicator if data has changed. More... | |
interface_data_ts_t * | data_ts |
Pointer to data casted to timestamp struct. More... | |
GameStateInterface Fawkes BlackBoard Interface.
This interface provides access to the current game state. It is closely related to the WorldInfo network protocol.
Definition at line 33 of file GameStateInterface.h.
Enumeration defining the different teams.
Keep in sync with worldinfo_gamestate_goalcolor_t.
Enumerator | |
---|---|
GOAL_BLUE | Blue goal. |
GOAL_YELLOW | Yellow goal. |
Definition at line 72 of file GameStateInterface.h.
Enumeration defining the different teams.
Keep in sync with worldinfo_gamestate_half_t.
Enumerator | |
---|---|
HALF_FIRST | First half. |
HALF_SECOND | Second half. |
Definition at line 82 of file GameStateInterface.h.
Enumeration defining the different robot roles.
Keep in sync with worldinfo_gamestate_role_t.
Enumerator | |
---|---|
ROLE_GOALIE | Goalie. |
ROLE_DEFENDER | Defender. |
ROLE_MID_LEFT | Midfield left. |
ROLE_MID_RIGHT | Midfield right. |
ROLE_ATTACKER | Attacker. |
Definition at line 92 of file GameStateInterface.h.
Enumeration defining the different teams.
Keep in sync with worldinfo_gamestate_team_t.
Enumerator | |
---|---|
TEAM_NONE | No team, not team-specific. |
TEAM_CYAN | Cyan team. |
TEAM_MAGENTA | Magenta team. |
TEAM_BOTH | Both teams. |
Definition at line 60 of file GameStateInterface.h.
|
virtual |
Copy values from other interface.
other | other interface to copy values from |
Implements fawkes::Interface.
Definition at line 477 of file GameStateInterface.cpp.
References fawkes::Message::type(), and fawkes::Interface::type().
|
virtual |
Create message based on type name.
This will create a new message of the given type. The type must be given without the InterfaceName:: prefix but just the plain class name of the message.
type | message type |
UnknownTypeException | thrown if this interface cannot create a message of the given type. |
Implements fawkes::Interface.
Definition at line 458 of file GameStateInterface.cpp.
|
virtual |
Convert arbitrary enum value to string.
Given the string representation of the enum type and the value this method returns the string representation of the specific value, or the string UNKNOWN if the value is not defined. An exception is thrown if the enum type is invalid.
enumtype | enum type as string |
val | value to convert |
UnknownTypeException | thrown if enumtype is not specified for interface. |
Implements fawkes::Interface.
Definition at line 488 of file GameStateInterface.cpp.
uint32_t fawkes::GameStateInterface::game_state | ( | ) | const |
Get game_state value.
Current game state
Definition at line 182 of file GameStateInterface.cpp.
Referenced by RemoteBlackBoardRefBoxProcessor::refbox_process().
GameStateInterface::if_gamestate_half_t fawkes::GameStateInterface::half | ( | ) | const |
Get half value.
Current game half
Definition at line 306 of file GameStateInterface.cpp.
Referenced by RemoteBlackBoardRefBoxProcessor::refbox_process().
bool fawkes::GameStateInterface::is_kickoff | ( | ) | const |
Get kickoff value.
Whether we have kickoff
Definition at line 337 of file GameStateInterface.cpp.
Referenced by RemoteBlackBoardRefBoxProcessor::refbox_process().
size_t fawkes::GameStateInterface::maxlenof_game_state | ( | ) | const |
Get maximum length of game_state value.
Definition at line 192 of file GameStateInterface.cpp.
size_t fawkes::GameStateInterface::maxlenof_half | ( | ) | const |
Get maximum length of half value.
Definition at line 316 of file GameStateInterface.cpp.
size_t fawkes::GameStateInterface::maxlenof_kickoff | ( | ) | const |
Get maximum length of kickoff value.
Definition at line 347 of file GameStateInterface.cpp.
size_t fawkes::GameStateInterface::maxlenof_our_goal_color | ( | ) | const |
Get maximum length of our_goal_color value.
Definition at line 285 of file GameStateInterface.cpp.
size_t fawkes::GameStateInterface::maxlenof_our_team | ( | ) | const |
Get maximum length of our_team value.
Definition at line 254 of file GameStateInterface.cpp.
size_t fawkes::GameStateInterface::maxlenof_role | ( | ) | const |
Get maximum length of role value.
Definition at line 378 of file GameStateInterface.cpp.
size_t fawkes::GameStateInterface::maxlenof_score_cyan | ( | ) | const |
Get maximum length of score_cyan value.
Definition at line 409 of file GameStateInterface.cpp.
size_t fawkes::GameStateInterface::maxlenof_score_magenta | ( | ) | const |
Get maximum length of score_magenta value.
Definition at line 440 of file GameStateInterface.cpp.
size_t fawkes::GameStateInterface::maxlenof_state_team | ( | ) | const |
Get maximum length of state_team value.
Definition at line 223 of file GameStateInterface.cpp.
|
virtual |
Check if message is valid and can be enqueued.
message | Message to check |
Implements fawkes::Interface.
Definition at line 859 of file GameStateInterface.cpp.
GameStateInterface::if_gamestate_goalcolor_t fawkes::GameStateInterface::our_goal_color | ( | ) | const |
Get our_goal_color value.
Our own goal color
Definition at line 275 of file GameStateInterface.cpp.
Referenced by RemoteBlackBoardRefBoxProcessor::refbox_process().
GameStateInterface::if_gamestate_team_t fawkes::GameStateInterface::our_team | ( | ) | const |
Get our_team value.
Our team color
Definition at line 244 of file GameStateInterface.cpp.
Referenced by RemoteBlackBoardRefBoxProcessor::refbox_process().
GameStateInterface::if_gamestate_role_t fawkes::GameStateInterface::role | ( | ) | const |
Get role value.
Current role of this robot
Definition at line 368 of file GameStateInterface.cpp.
uint32_t fawkes::GameStateInterface::score_cyan | ( | ) | const |
Get score_cyan value.
Score of team cyan
Definition at line 399 of file GameStateInterface.cpp.
Referenced by RemoteBlackBoardRefBoxProcessor::refbox_process().
uint32_t fawkes::GameStateInterface::score_magenta | ( | ) | const |
Get score_magenta value.
Score of team magenta
Definition at line 430 of file GameStateInterface.cpp.
Referenced by RemoteBlackBoardRefBoxProcessor::refbox_process().
void fawkes::GameStateInterface::set_game_state | ( | const uint32_t | new_game_state | ) |
Set game_state value.
Current game state
new_game_state | new game_state value |
Definition at line 202 of file GameStateInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by RefBoxCommThread::set_gamestate().
void fawkes::GameStateInterface::set_half | ( | const if_gamestate_half_t | new_half | ) |
Set half value.
Current game half
new_half | new half value |
Definition at line 326 of file GameStateInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by RefBoxCommThread::set_half().
void fawkes::GameStateInterface::set_kickoff | ( | const bool | new_kickoff | ) |
Set kickoff value.
Whether we have kickoff
new_kickoff | new kickoff value |
Definition at line 357 of file GameStateInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by RefBoxCommThread::loop(), and RefBoxCommThread::set_half().
void fawkes::GameStateInterface::set_our_goal_color | ( | const if_gamestate_goalcolor_t | new_our_goal_color | ) |
Set our_goal_color value.
Our own goal color
new_our_goal_color | new our_goal_color value |
Definition at line 295 of file GameStateInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by RefBoxCommThread::set_team_goal().
void fawkes::GameStateInterface::set_our_team | ( | const if_gamestate_team_t | new_our_team | ) |
Set our_team value.
Our team color
new_our_team | new our_team value |
Definition at line 264 of file GameStateInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by RefBoxCommThread::loop(), and RefBoxCommThread::set_team_goal().
void fawkes::GameStateInterface::set_role | ( | const if_gamestate_role_t | new_role | ) |
Set role value.
Current role of this robot
new_role | new role value |
Definition at line 388 of file GameStateInterface.cpp.
References fawkes::Interface::data_changed.
void fawkes::GameStateInterface::set_score_cyan | ( | const uint32_t | new_score_cyan | ) |
Set score_cyan value.
Score of team cyan
new_score_cyan | new score_cyan value |
Definition at line 419 of file GameStateInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by RefBoxCommThread::set_score().
void fawkes::GameStateInterface::set_score_magenta | ( | const uint32_t | new_score_magenta | ) |
Set score_magenta value.
Score of team magenta
new_score_magenta | new score_magenta value |
Definition at line 450 of file GameStateInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by RefBoxCommThread::set_score().
void fawkes::GameStateInterface::set_state_team | ( | const if_gamestate_team_t | new_state_team | ) |
Set state_team value.
Team referred to by game state
new_state_team | new state_team value |
Definition at line 233 of file GameStateInterface.cpp.
References fawkes::Interface::data_changed.
Referenced by RefBoxCommThread::loop(), and RefBoxCommThread::set_gamestate().
GameStateInterface::if_gamestate_team_t fawkes::GameStateInterface::state_team | ( | ) | const |
Get state_team value.
Team referred to by game state
Definition at line 213 of file GameStateInterface.cpp.
Referenced by RemoteBlackBoardRefBoxProcessor::refbox_process().
const char * fawkes::GameStateInterface::tostring_if_gamestate_goalcolor_t | ( | if_gamestate_goalcolor_t | value | ) | const |
Convert if_gamestate_goalcolor_t constant to string.
value | value to convert to string |
Definition at line 139 of file GameStateInterface.cpp.
References fawkes::GOAL_BLUE, and fawkes::GOAL_YELLOW.
const char * fawkes::GameStateInterface::tostring_if_gamestate_half_t | ( | if_gamestate_half_t | value | ) | const |
Convert if_gamestate_half_t constant to string.
value | value to convert to string |
Definition at line 152 of file GameStateInterface.cpp.
References fawkes::HALF_FIRST, and fawkes::HALF_SECOND.
const char * fawkes::GameStateInterface::tostring_if_gamestate_role_t | ( | if_gamestate_role_t | value | ) | const |
Convert if_gamestate_role_t constant to string.
value | value to convert to string |
Definition at line 165 of file GameStateInterface.cpp.
const char * fawkes::GameStateInterface::tostring_if_gamestate_team_t | ( | if_gamestate_team_t | value | ) | const |
Convert if_gamestate_team_t constant to string.
value | value to convert to string |
Definition at line 124 of file GameStateInterface.cpp.
References fawkes::TEAM_BOTH, fawkes::TEAM_CYAN, fawkes::TEAM_MAGENTA, and fawkes::TEAM_NONE.
|
static |
GS_CORNER_KICK constant.
Definition at line 45 of file GameStateInterface.h.
|
static |
GS_DROP_BALL constant.
Definition at line 43 of file GameStateInterface.h.
|
static |
GS_FREE_KICK constant.
Definition at line 47 of file GameStateInterface.h.
|
static |
GS_FROZEN constant.
Definition at line 40 of file GameStateInterface.h.
|
static |
GS_GOAL_KICK constant.
Definition at line 48 of file GameStateInterface.h.
|
static |
GS_HALF_TIME constant.
Definition at line 49 of file GameStateInterface.h.
|
static |
GS_KICK_OFF constant.
Definition at line 42 of file GameStateInterface.h.
|
static |
GS_PENALTY constant.
Definition at line 44 of file GameStateInterface.h.
|
static |
GS_PLAY constant.
Definition at line 41 of file GameStateInterface.h.
|
static |
GS_SPL_FINISHED constant.
Definition at line 54 of file GameStateInterface.h.
|
static |
GS_SPL_INITIAL constant.
Definition at line 50 of file GameStateInterface.h.
|
static |
GS_SPL_PLAY constant.
Definition at line 53 of file GameStateInterface.h.
|
static |
GS_SPL_READY constant.
Definition at line 51 of file GameStateInterface.h.
|
static |
GS_SPL_SET constant.
Definition at line 52 of file GameStateInterface.h.
|
static |
GS_THROW_IN constant.
Definition at line 46 of file GameStateInterface.h.