diff --git a/rj_msgs/msg/AgentState.msg b/rj_msgs/msg/AgentState.msg index e69de29bb2d..04355828888 100644 --- a/rj_msgs/msg/AgentState.msg +++ b/rj_msgs/msg/AgentState.msg @@ -0,0 +1 @@ +string state \ No newline at end of file diff --git a/soccer/src/soccer/strategy/agent/position/defense.cpp b/soccer/src/soccer/strategy/agent/position/defense.cpp index 78b0ebfb528..3e72a81a478 100644 --- a/soccer/src/soccer/strategy/agent/position/defense.cpp +++ b/soccer/src/soccer/strategy/agent/position/defense.cpp @@ -9,6 +9,10 @@ std::optional Defense::derived_get_task(RobotIntent intent) { return state_to_task(intent); } +std::string Defense::get_current_state() { + return std::string{"Defense"} + std::to_string(static_cast(current_state_)); +} + Defense::State Defense::update_state() { State next_state = current_state_; // handle transitions between states diff --git a/soccer/src/soccer/strategy/agent/position/defense.hpp b/soccer/src/soccer/strategy/agent/position/defense.hpp index f66ae8c975b..86ee80e50f3 100644 --- a/soccer/src/soccer/strategy/agent/position/defense.hpp +++ b/soccer/src/soccer/strategy/agent/position/defense.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -35,6 +36,7 @@ class Defense : public Position { void derived_acknowledge_pass() override; void derived_pass_ball() override; void derived_acknowledge_ball_in_transit() override; + std::string get_current_state() override; void die() override; void revive() override; diff --git a/soccer/src/soccer/strategy/agent/position/goal_kicker.cpp b/soccer/src/soccer/strategy/agent/position/goal_kicker.cpp index ead8901107b..2efb9576218 100644 --- a/soccer/src/soccer/strategy/agent/position/goal_kicker.cpp +++ b/soccer/src/soccer/strategy/agent/position/goal_kicker.cpp @@ -28,6 +28,8 @@ std::optional GoalKicker::derived_get_task(RobotIntent intent) { return intent; } +std::string GoalKicker::get_current_state() { return "GoalKicker"; } + void GoalKicker::derived_acknowledge_pass() {} void GoalKicker::derived_pass_ball() {} diff --git a/soccer/src/soccer/strategy/agent/position/goal_kicker.hpp b/soccer/src/soccer/strategy/agent/position/goal_kicker.hpp index 7397b9293c5..249010a81df 100644 --- a/soccer/src/soccer/strategy/agent/position/goal_kicker.hpp +++ b/soccer/src/soccer/strategy/agent/position/goal_kicker.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include "planning/instant.hpp" @@ -32,6 +34,8 @@ class GoalKicker : public Position { */ void derived_acknowledge_ball_in_transit() override; + std::string get_current_state() override; + private: std::optional derived_get_task(RobotIntent intent) override; }; diff --git a/soccer/src/soccer/strategy/agent/position/goalie.cpp b/soccer/src/soccer/strategy/agent/position/goalie.cpp index e91952eac3e..782daf18f73 100644 --- a/soccer/src/soccer/strategy/agent/position/goalie.cpp +++ b/soccer/src/soccer/strategy/agent/position/goalie.cpp @@ -11,6 +11,8 @@ std::optional Goalie::derived_get_task(RobotIntent intent) { return state_to_task(intent); } +std::string Goalie::get_current_state() { return "Goalie"; } + Goalie::State Goalie::update_state() { // if a shot is coming, override all and go block it WorldState* world_state = last_world_state_; diff --git a/soccer/src/soccer/strategy/agent/position/goalie.hpp b/soccer/src/soccer/strategy/agent/position/goalie.hpp index 4ca34ef8737..76115002ce9 100644 --- a/soccer/src/soccer/strategy/agent/position/goalie.hpp +++ b/soccer/src/soccer/strategy/agent/position/goalie.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include @@ -28,6 +29,8 @@ class Goalie : public Position { void derived_pass_ball() override; void derived_acknowledge_ball_in_transit() override; + std::string get_current_state() override; + private: // point goalie will aim for when clearing balls const rj_geometry::Point clear_point_{0.0, 4.5}; diff --git a/soccer/src/soccer/strategy/agent/position/offense.cpp b/soccer/src/soccer/strategy/agent/position/offense.cpp index 3c1a6ef680c..c64d49b5177 100644 --- a/soccer/src/soccer/strategy/agent/position/offense.cpp +++ b/soccer/src/soccer/strategy/agent/position/offense.cpp @@ -14,6 +14,10 @@ std::optional Offense::derived_get_task(RobotIntent intent) { return state_to_task(intent); } +std::string Offense::get_current_state() { + return std::string{"Offense"} + std::to_string(static_cast(current_state_)); +} + Offense::State Offense::update_state() { State next_state = current_state_; // handle transitions between current state diff --git a/soccer/src/soccer/strategy/agent/position/offense.hpp b/soccer/src/soccer/strategy/agent/position/offense.hpp index 705890dc482..e45df52e772 100644 --- a/soccer/src/soccer/strategy/agent/position/offense.hpp +++ b/soccer/src/soccer/strategy/agent/position/offense.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -36,6 +37,8 @@ class Offense : public Position { void derived_pass_ball() override; void derived_acknowledge_ball_in_transit() override; + std::string get_current_state() override; + private: bool kicking_{true}; diff --git a/soccer/src/soccer/strategy/agent/position/penalty_player.cpp b/soccer/src/soccer/strategy/agent/position/penalty_player.cpp index 53a2e61a8e8..82e58044768 100644 --- a/soccer/src/soccer/strategy/agent/position/penalty_player.cpp +++ b/soccer/src/soccer/strategy/agent/position/penalty_player.cpp @@ -31,6 +31,8 @@ std::optional PenaltyPlayer::derived_get_task(RobotIntent intent) { return intent; } +std::string PenaltyPlayer::get_current_state() { return "PenaltyPlayer"; } + void PenaltyPlayer::derived_acknowledge_pass() {} void PenaltyPlayer::derived_pass_ball() {} diff --git a/soccer/src/soccer/strategy/agent/position/penalty_player.hpp b/soccer/src/soccer/strategy/agent/position/penalty_player.hpp index ea52e65e477..2942db29d83 100644 --- a/soccer/src/soccer/strategy/agent/position/penalty_player.hpp +++ b/soccer/src/soccer/strategy/agent/position/penalty_player.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include "planning/instant.hpp" @@ -32,6 +34,8 @@ class PenaltyPlayer : public Position { */ void derived_acknowledge_ball_in_transit() override; + std::string get_current_state() override; + private: std::optional derived_get_task(RobotIntent intent) override; }; diff --git a/soccer/src/soccer/strategy/agent/position/position.hpp b/soccer/src/soccer/strategy/agent/position/position.hpp index 308293d6175..9faca6c378d 100644 --- a/soccer/src/soccer/strategy/agent/position/position.hpp +++ b/soccer/src/soccer/strategy/agent/position/position.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -75,6 +76,9 @@ class Position { void update_alive_robots(std::vector alive_robots); const std::string get_name(); + // returns the current state of the robot + virtual std::string get_current_state() = 0; + /** * @brief setter for time_left_ */ diff --git a/soccer/src/soccer/strategy/agent/position/robot_factory_position.cpp b/soccer/src/soccer/strategy/agent/position/robot_factory_position.cpp index 8f87db3f764..99f91b56656 100644 --- a/soccer/src/soccer/strategy/agent/position/robot_factory_position.cpp +++ b/soccer/src/soccer/strategy/agent/position/robot_factory_position.cpp @@ -120,4 +120,8 @@ void RobotFactoryPosition::die() { current_position_->die(); } void RobotFactoryPosition::revive() { current_position_->revive(); } +std::string RobotFactoryPosition::get_current_state() { + return current_position_->get_current_state(); +} + } // namespace strategy diff --git a/soccer/src/soccer/strategy/agent/position/robot_factory_position.hpp b/soccer/src/soccer/strategy/agent/position/robot_factory_position.hpp index f5a6aefa827..7edc6d8595e 100644 --- a/soccer/src/soccer/strategy/agent/position/robot_factory_position.hpp +++ b/soccer/src/soccer/strategy/agent/position/robot_factory_position.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -54,6 +55,8 @@ class RobotFactoryPosition : public Position { void derived_pass_ball() override; void derived_acknowledge_ball_in_transit() override; + std::string get_current_state() override; + void set_is_done() override; void die() override; void revive() override;