|
Thunderbots Project
|
#include <world.h>
Public Member Functions | |
| World (const Field &field, const Ball &ball, const Team &friendly_team, const Team &enemy_team, unsigned int buffer_size=20) | |
| World (const TbotsProto::World &world_proto) | |
| void | updateBall (const Ball &new_ball) |
| void | updateFriendlyTeamState (const Team &new_friendly_team_data) |
| void | updateEnemyTeamState (const Team &new_enemy_team_data) |
| void | updateRefereeCommand (const RefereeCommand &command) |
| void | updateRefereeCommand (const RefereeCommand &command, Point ball_placement_point) |
| void | updateRefereeStage (const RefereeStage &stage) |
| const Field & | field () const |
| const Ball & | ball () const |
| const Team & | friendlyTeam () const |
| const Team & | enemyTeam () const |
| const GameState & | gameState () const |
| void | updateGameState (const GameState &game_state) |
| void | updateGameStateBall (const Ball &ball) |
| const RefereeStage & | getRefereeStage () const |
| const Timestamp | getMostRecentTimestamp () const |
| void | updateTimestamp (Timestamp timestamp) |
| void | setTeamWithPossession (TeamPossession possession) |
| TeamPossession | getTeamWithPossession () const |
| bool | operator== (const World &other) const |
| bool | operator!= (const World &other) const |
| void | setDribbleDisplacement (const std::optional< Segment > &displacement) |
| const std::optional< Segment > & | getDribbleDisplacement () const |
Static Public Attributes | |
| static constexpr unsigned int | REFEREE_COMMAND_BUFFER_SIZE = 3 |
The world object describes the entire state of the world, which for us is all the information we have about the field, robots, and ball. The world object acts as a convenient way to pass all this information around to modules that may need it.
WARNING: This class should never hold any data that is pointed to anywhere else. This means no raw pointers, no shared pointers, no shared references. This is because in some cases we copy World's over multiple threads where having a shared member between multiple instances of a World on multiple threads could result in data corruption that would lead to absurdly hard to track bugs. YOU HAVE BEEN WARNED.
|
explicit |
Creates a new world.
| field | the field for the world |
| ball | the ball for the world |
| friendly_team | the friendly team for the world |
| enemy_team | the enemy_team for the world |
|
explicit |
Creates a new world based on the TbotsProto::World protobuf representation.
| world_proto | The TbotsProto::World protobuf which this world should be based on |
| const Ball & ball | ( | ) | const |
| const Team & enemyTeam | ( | ) | const |
| const Field & field | ( | ) | const |
| const Team & friendlyTeam | ( | ) | const |
| const GameState & gameState | ( | ) | const |
Returns a const reference to the Game State
| const std::optional< Segment > & getDribbleDisplacement | ( | ) | const |
Gets a segment representing the displacement of the ball (in metres) due to the friendly team continuously dribbling the ball across the field.
If the friendly team does not have possession over the ball, std::nullopt is returned.
| const Timestamp getMostRecentTimestamp | ( | ) | const |
Returns the most recent timestamp value of all timestamped member objects of the world
| const RefereeStage & getRefereeStage | ( | ) | const |
Returns the current referee stage
| TeamPossession getTeamWithPossession | ( | ) | const |
Gets the team with possession
| bool operator!= | ( | const World & | other | ) | const |
Defines the inequality operator for a World.
| other | The world to compare against for inequality |
| bool operator== | ( | const World & | other | ) | const |
Defines the equality operator for a World. Worlds are equal if their field, ball friendly_team, enemy_team and game_state are equal. The last update timestamp and histories are not part of the equality.
| other | The world to compare against for equality |
| void setDribbleDisplacement | ( | const std::optional< Segment > & | displacement | ) |
Sets the segment representing the displacement of the ball (in metres) due to the friendly team continuously dribbling the ball across the field.
| distance | the displacement of the ball |
| void setTeamWithPossession | ( | TeamPossession | possession | ) |
Sets the team with possession
| possession | The team with possession |
| void updateBall | ( | const Ball & | new_ball | ) |
Updates the state of the ball in the world with the new ball data
| new_ball | A Ball containing new ball information |
| void updateEnemyTeamState | ( | const Team & | new_enemy_team_data | ) |
Updates the state of the enemy team in the world with the new team data
| new_enemy_team_msg | The message containing new enemy team information |
| void updateFriendlyTeamState | ( | const Team & | new_friendly_team_data | ) |
Updates the state of the friendly team in the world with the new team data
| new_friendly_team_msg | The message containing new friendly team information |
| void updateGameState | ( | const GameState & | game_state | ) |
Updates the current Game State
| game_state | the game state to update with |
| void updateGameStateBall | ( | const Ball & | ball | ) |
Updates the ball inside of game state
| ball | the ball to update with |
| void updateRefereeCommand | ( | const RefereeCommand & | command | ) |
Updates the referee command
| command | the command sent by the referee |
| void updateRefereeCommand | ( | const RefereeCommand & | command, |
| Point | ball_placement_point | ||
| ) |
Updates the referee command
| command | the command sent by the referee |
| ball_placement_point | ball placement point |
| void updateRefereeStage | ( | const RefereeStage & | stage | ) |
Updates the referee stage
| stage | the stage sent by the referee |
| void updateTimestamp | ( | Timestamp | timestamp | ) |
Updates the last update timestamp
| timestamp | The last time this World was updated |
| std::invalid_argument | if timestamp is older than the current last update timestamp |