From ba95382d7057405b1445e51176b783299eb7de8c Mon Sep 17 00:00:00 2001 From: Squid5678 Date: Sun, 15 Oct 2023 19:10:39 +0000 Subject: [PATCH] updated files for testing --- .../strategy/agent/agent_action_client.cpp | 23 +++++++++++++++---- .../soccer/strategy/agent/position/runner.cpp | 2 +- .../src/soccer/strategy/coach/coach_node.cpp | 4 ++-- .../src/soccer/strategy/coach/coach_node.hpp | 7 +++--- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/soccer/src/soccer/strategy/agent/agent_action_client.cpp b/soccer/src/soccer/strategy/agent/agent_action_client.cpp index a8288568615..7beb277d44e 100644 --- a/soccer/src/soccer/strategy/agent/agent_action_client.cpp +++ b/soccer/src/soccer/strategy/agent/agent_action_client.cpp @@ -1,4 +1,5 @@ #include "agent_action_client.hpp" +#include #include "rj_constants/topic_names.hpp" @@ -75,7 +76,9 @@ AgentActionClient::AgentActionClient(int r_id) if (r_id == 0) { current_position_ = std::make_unique(r_id); - } else if (r_id == 1 || r_id == 3 || r_id == 5) { + } else if (r_id == 1) { + current_position_ = std::make_unique(r_id); + } else if (r_id == 3 || r_id == 5) { current_position_ = std::make_unique(r_id); } else if (r_id == 2 || r_id == 4) { current_position_ = std::make_unique(r_id); @@ -144,6 +147,8 @@ void AgentActionClient::get_task() { if (robot_id_ == 0) { current_position_ = std::make_unique(robot_id_); } else if (robot_id_ == 1) { + current_position_ = std::make_unique(robot_id_); + } else if (robot_id_ == 2) { current_position_ = std::make_unique(robot_id_); } else { current_position_ = std::make_unique(robot_id_); @@ -170,13 +175,13 @@ void AgentActionClient::update_position(const rj_msgs::msg::PositionAssignment:: next_position_ = std::make_unique(robot_id_); break; case 1: - next_position_ = std::make_unique(robot_id_); + next_position_ = std::make_unique(robot_id_); break; case 2: next_position_ = std::make_unique(robot_id_); break; case 3: - next_position_ = std::make_unique(robot_id_); + next_position_ = std::make_unique(robot_id_); break; case 4: next_position_ = std::make_unique(robot_id_); @@ -223,6 +228,8 @@ void AgentActionClient::goal_response_callback( if (robot_id_ == 0) { current_position_ = std::make_unique(robot_id_); } else if (robot_id_ == 1) { + current_position_ = std::make_unique(robot_id_); + } else if (robot_id_ == 2) { current_position_ = std::make_unique(robot_id_); } else { current_position_ = std::make_unique(robot_id_); @@ -242,6 +249,8 @@ void AgentActionClient::feedback_callback( if (robot_id_ == 0) { current_position_ = std::make_unique(robot_id_); } else if (robot_id_ == 1) { + current_position_ = std::make_unique(robot_id_); + } else if (robot_id_ == 2) { current_position_ = std::make_unique(robot_id_); } else { current_position_ = std::make_unique(robot_id_); @@ -258,6 +267,8 @@ void AgentActionClient::result_callback(const GoalHandleRobotMove::WrappedResult if (robot_id_ == 0) { current_position_ = std::make_unique(robot_id_); } else if (robot_id_ == 1) { + current_position_ = std::make_unique(robot_id_); + } else if (robot_id_ == 2) { current_position_ = std::make_unique(robot_id_); } else { current_position_ = std::make_unique(robot_id_); @@ -289,6 +300,8 @@ void AgentActionClient::get_communication() { if (robot_id_ == 0) { current_position_ = std::make_unique(robot_id_); } else if (robot_id_ == 1) { + current_position_ = std::make_unique(robot_id_); + } else if (robot_id_ == 2) { current_position_ = std::make_unique(robot_id_); } else { current_position_ = std::make_unique(robot_id_); @@ -437,6 +450,8 @@ void AgentActionClient::check_communication_timeout() { if (robot_id_ == 0) { current_position_ = std::make_unique(robot_id_); } else if (robot_id_ == 1) { + current_position_ = std::make_unique(robot_id_); + } else if (robot_id_ == 2) { current_position_ = std::make_unique(robot_id_); } else { current_position_ = std::make_unique(robot_id_); @@ -475,4 +490,4 @@ void AgentActionClient::update_position_alive_robots() { } } -} // namespace strategy +} // namespace strategy \ No newline at end of file diff --git a/soccer/src/soccer/strategy/agent/position/runner.cpp b/soccer/src/soccer/strategy/agent/position/runner.cpp index c5cfa1955a2..f5b6ccde34c 100644 --- a/soccer/src/soccer/strategy/agent/position/runner.cpp +++ b/soccer/src/soccer/strategy/agent/position/runner.cpp @@ -17,7 +17,7 @@ Runner::State Runner::update_state() { rj_geometry::Point robot_position = world_state->get_robot(true, robot_id_).pose.position(); switch (latest_state_) { case IDLING: - initial_position_ = robot_position; + initi+al_position_ = robot_position; return RUN_FIRST_SIDE; case RUN_FIRST_SIDE: if ((robot_position.y() - initial_position_.y()) > kSideLength) { diff --git a/soccer/src/soccer/strategy/coach/coach_node.cpp b/soccer/src/soccer/strategy/coach/coach_node.cpp index 20acb3d0d90..a86bab5d245 100644 --- a/soccer/src/soccer/strategy/coach/coach_node.cpp +++ b/soccer/src/soccer/strategy/coach/coach_node.cpp @@ -293,7 +293,7 @@ void CoachNode::assign_positions_normal(std::array& positi positions[robot_id] = Positions::Goalie; break; case 1: - positions[robot_id] = Positions::Offense; + positions[robot_id] = Positions::Runner; break; case 2: positions[robot_id] = Positions::Defense; @@ -423,4 +423,4 @@ bool CoachNode::check_robot_alive(u_int8_t robot_id) { } } -} // namespace strategy +} // namespace strategy \ No newline at end of file diff --git a/soccer/src/soccer/strategy/coach/coach_node.hpp b/soccer/src/soccer/strategy/coach/coach_node.hpp index 81a19ac747b..1ee11df7e66 100644 --- a/soccer/src/soccer/strategy/coach/coach_node.hpp +++ b/soccer/src/soccer/strategy/coach/coach_node.hpp @@ -23,6 +23,7 @@ #include "strategy/agent/position/defense.hpp" #include "strategy/agent/position/goalie.hpp" #include "strategy/agent/position/offense.hpp" +#include "strategy/agent/position/runner.hpp" #include "strategy/agent/position/position.hpp" namespace strategy { @@ -35,12 +36,12 @@ enum MatchSituation { in_play, // normal play }; -enum Positions { Goalie, Defense, Offense, PenaltyPlayer, GoalKicker }; +enum Positions { Goalie, Defense, Runner, Offense, PenaltyPlayer, GoalKicker }; // These values are explicitly declared because they are the ints that are published to // strategy/positions i.e. the same values as strategy::Positions namespace OverridePosition { -enum OverridePosition { Goalie = 0, Defense = 1, Offense = 2, None = 3 }; +enum OverridePosition { Goalie = 0, Defense = 1, Offense = 2, Runner = 3, None = 4 }; } // namespace OverridePosition /** @@ -163,4 +164,4 @@ class CoachNode : public rclcpp::Node { bool check_robot_alive(u_int8_t robot_id); }; -} // namespace strategy +} // namespace strategy \ No newline at end of file