Skip to content

Commit

Permalink
[decision-ms] Add decision world (#76)
Browse files Browse the repository at this point in the history
Adds decision world with allies, enemies, ball and game status (referee)
information.

---------

Co-authored-by: ersaraujo <[email protected]>
  • Loading branch information
fnalmeidap and ersaraujo authored Oct 31, 2024
1 parent f8946b4 commit c06ede0
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
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
)
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
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

0 comments on commit c06ede0

Please sign in to comment.