forked from ssl-core/ssl-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[decision-ms] Add decision world (#76)
Adds decision world with allies, enemies, ball and game status (referee) information. --------- Co-authored-by: ersaraujo <[email protected]>
- Loading branch information
1 parent
f8946b4
commit c06ede0
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
decision-ms/decision-guardiola/decision/processing/entities/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
robocin_cpp_library( | ||
NAME entities | ||
HDRS world.h | ||
SRCS world.cpp | ||
) |
33 changes: 33 additions & 0 deletions
33
decision-ms/decision-guardiola/decision/processing/entities/world.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "decision/processing/entities/world.h" | ||
|
||
#include "decision/processing/messages/referee/game_status_message.h" | ||
|
||
namespace decision { | ||
|
||
void World::update(std::optional<std::span<RobotMessage>>& allies, | ||
std::optional<std::span<RobotMessage>>& enemies, | ||
std::optional<BallMessage>& ball, | ||
std::optional<FieldMessage>& field, | ||
std::optional<GameStatusMessage>& game_status) { | ||
if (allies.has_value()) { | ||
this->allies = allies.value(); | ||
} | ||
|
||
if (enemies.has_value()) { | ||
this->enemies = enemies.value(); | ||
} | ||
|
||
if (ball.has_value()) { | ||
this->ball = std::move(ball.value()); | ||
} | ||
|
||
if (field.has_value()) { | ||
this->field = std::move(field.value()); | ||
} | ||
|
||
if (game_status.has_value()) { | ||
this->game_status = std::move(game_status.value()); | ||
} | ||
} | ||
|
||
} // namespace decision |
37 changes: 37 additions & 0 deletions
37
decision-ms/decision-guardiola/decision/processing/entities/world.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef DECISION_PROCESSING_ENTITIES_WORLD_H | ||
#define DECISION_PROCESSING_ENTITIES_WORLD_H | ||
|
||
#include "decision/processing/messages/perception/ball/ball_message.h" | ||
#include "decision/processing/messages/perception/field/field_message.h" | ||
#include "decision/processing/messages/perception/robot/robot_message.h" | ||
#include "decision/processing/messages/referee/game_status_message.h" | ||
|
||
namespace decision { | ||
|
||
class World { | ||
public: | ||
World() = default; | ||
|
||
World(const World&) = delete; | ||
World& operator=(const World&) = delete; | ||
World(World&&) noexcept = default; | ||
World& operator=(World&&) noexcept = default; | ||
|
||
virtual ~World() = default; | ||
|
||
std::span<RobotMessage> allies; | ||
std::span<RobotMessage> enemies; | ||
BallMessage ball; | ||
FieldMessage field; | ||
GameStatusMessage game_status; // referee | ||
|
||
void update(std::optional<std::span<RobotMessage>>& allies, | ||
std::optional<std::span<RobotMessage>>& enemies, | ||
std::optional<BallMessage>& ball, | ||
std::optional<FieldMessage>& field, | ||
std::optional<GameStatusMessage>& game_status); | ||
}; | ||
|
||
} // namespace decision | ||
|
||
#endif // DECISION_PROCESSING_ENTITIES_WORLD_H |