From 91d37687cb1673f44139801432cb3d6aeae7f4aa Mon Sep 17 00:00:00 2001 From: oddlyspookycherry Date: Tue, 5 Mar 2024 21:55:59 -0500 Subject: [PATCH 1/6] Add topic name constant for strategy/alive_robots --- rj_constants/include/rj_constants/topic_names.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rj_constants/include/rj_constants/topic_names.hpp b/rj_constants/include/rj_constants/topic_names.hpp index 4e1385ab792..6a96df7fe00 100644 --- a/rj_constants/include/rj_constants/topic_names.hpp +++ b/rj_constants/include/rj_constants/topic_names.hpp @@ -69,6 +69,7 @@ static inline std::string trajectory_topic(int robot_id) { } // namespace planning::topics namespace strategy::topics { + constexpr auto kAliveRobots("strategy/alive_robots"); } // namespace strategy::topics namespace control { From 421029be6b8b262f4d85b44f57e854beb3cd594a Mon Sep 17 00:00:00 2001 From: oddlyspookycherry Date: Tue, 5 Mar 2024 21:56:51 -0500 Subject: [PATCH 2/6] Publish robots 0-6 as alive in sim_radio --- soccer/src/soccer/radio/sim_radio.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/soccer/src/soccer/radio/sim_radio.cpp b/soccer/src/soccer/radio/sim_radio.cpp index 6fb5100606f..648585473f7 100644 --- a/soccer/src/soccer/radio/sim_radio.cpp +++ b/soccer/src/soccer/radio/sim_radio.cpp @@ -94,17 +94,19 @@ SimRadio::SimRadio(bool blue_team) ip::udp::endpoint(address_, blue_team_ ? kSimBlueCommandPort : kSimYellowCommandPort); sim_control_endpoint_ = ip::udp::endpoint(address_, kSimCommandPort); + // assume robots 0-6 are always alive in sim + for (uint8_t robot_id = 0; robot_id < 7; robot_id++) { + alive_robots_[robot_id] = true; + } + alive_robots_pub_ = + this->create_publisher(strategy::topics::kAliveRobots, rclcpp::QoS(1)); + alive_robots_timer_ = create_wall_timer(std::chrono::milliseconds(500), [this]() { rj_msgs::msg::AliveRobots alive_message{}; alive_message.alive_robots = alive_robots_; publish_alive_robots(alive_message); }); - for (uint8_t robot_id = 0; robot_id < kNumShells; robot_id++) { - alive_robots_[robot_id] = true; - } - alive_robots_pub_ = - this->create_publisher("strategy/alive_robots", rclcpp::QoS(1)); buffer_.resize(1024); start_receive(); From d3e49bc5068d6eb15a00c60977030ba272add601 Mon Sep 17 00:00:00 2001 From: oddlyspookycherry Date: Tue, 5 Mar 2024 21:57:41 -0500 Subject: [PATCH 3/6] Use global topic name declaration in agent_action_client --- soccer/src/soccer/strategy/agent/agent_action_client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soccer/src/soccer/strategy/agent/agent_action_client.cpp b/soccer/src/soccer/strategy/agent/agent_action_client.cpp index c251859ea44..d358694adf1 100644 --- a/soccer/src/soccer/strategy/agent/agent_action_client.cpp +++ b/soccer/src/soccer/strategy/agent/agent_action_client.cpp @@ -34,7 +34,7 @@ AgentActionClient::AgentActionClient(int r_id) [this](rj_msgs::msg::FieldDimensions::SharedPtr msg) { field_dimensions_callback(msg); }); alive_robots_sub_ = create_subscription( - "strategy/alive_robots", 1, + ::strategy::topics::kAliveRobots, 1, [this](rj_msgs::msg::AliveRobots::SharedPtr msg) { alive_robots_callback(msg); }); game_settings_sub_ = create_subscription( From 1b2b0ed5ad3372800a790c86b97809f7549f3316 Mon Sep 17 00:00:00 2001 From: oddlyspookycherry Date: Tue, 5 Mar 2024 21:58:40 -0500 Subject: [PATCH 4/6] Change topic name in radio to use the global costant declaration (strategy/alive_robots) for consistency --- soccer/src/soccer/radio/radio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soccer/src/soccer/radio/radio.cpp b/soccer/src/soccer/radio/radio.cpp index 57b0e5fdf04..32f65e02104 100644 --- a/soccer/src/soccer/radio/radio.cpp +++ b/soccer/src/soccer/radio/radio.cpp @@ -39,7 +39,7 @@ Radio::Radio() } alive_robots_pub_ = - create_publisher("/alive_robots", rclcpp::QoS(1)); + create_publisher(strategy::topics::kAliveRobots, rclcpp::QoS(1)); tick_timer_ = create_wall_timer(tick_period_, [this]() { tick(); }); } From 170fbb34c256a9a6d424b44e06d34ed9ec55c278 Mon Sep 17 00:00:00 2001 From: oddlyspookycherry Date: Tue, 5 Mar 2024 22:05:12 -0500 Subject: [PATCH 5/6] Fix style formatting --- rj_constants/include/rj_constants/topic_names.hpp | 2 +- soccer/src/soccer/radio/sim_radio.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rj_constants/include/rj_constants/topic_names.hpp b/rj_constants/include/rj_constants/topic_names.hpp index 6a96df7fe00..cfaa1eed432 100644 --- a/rj_constants/include/rj_constants/topic_names.hpp +++ b/rj_constants/include/rj_constants/topic_names.hpp @@ -69,7 +69,7 @@ static inline std::string trajectory_topic(int robot_id) { } // namespace planning::topics namespace strategy::topics { - constexpr auto kAliveRobots("strategy/alive_robots"); +constexpr auto kAliveRobots("strategy/alive_robots"); } // namespace strategy::topics namespace control { diff --git a/soccer/src/soccer/radio/sim_radio.cpp b/soccer/src/soccer/radio/sim_radio.cpp index 648585473f7..39a621a094d 100644 --- a/soccer/src/soccer/radio/sim_radio.cpp +++ b/soccer/src/soccer/radio/sim_radio.cpp @@ -98,8 +98,8 @@ SimRadio::SimRadio(bool blue_team) for (uint8_t robot_id = 0; robot_id < 7; robot_id++) { alive_robots_[robot_id] = true; } - alive_robots_pub_ = - this->create_publisher(strategy::topics::kAliveRobots, rclcpp::QoS(1)); + alive_robots_pub_ = this->create_publisher( + strategy::topics::kAliveRobots, rclcpp::QoS(1)); alive_robots_timer_ = create_wall_timer(std::chrono::milliseconds(500), [this]() { rj_msgs::msg::AliveRobots alive_message{}; From 1c834bb12acd98bca1257015f6e5b51037b9d9b3 Mon Sep 17 00:00:00 2001 From: Daniel Savrasov <84584430+oddlyspookycherry@users.noreply.github.com> Date: Wed, 6 Mar 2024 12:47:46 -0500 Subject: [PATCH 6/6] Minor semantic update to sim_radio Co-authored-by: Sid Parikh --- soccer/src/soccer/radio/sim_radio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soccer/src/soccer/radio/sim_radio.cpp b/soccer/src/soccer/radio/sim_radio.cpp index 39a621a094d..fd8b6222655 100644 --- a/soccer/src/soccer/radio/sim_radio.cpp +++ b/soccer/src/soccer/radio/sim_radio.cpp @@ -95,7 +95,7 @@ SimRadio::SimRadio(bool blue_team) sim_control_endpoint_ = ip::udp::endpoint(address_, kSimCommandPort); // assume robots 0-6 are always alive in sim - for (uint8_t robot_id = 0; robot_id < 7; robot_id++) { + for (uint8_t robot_id = 0; robot_id <= 6; robot_id++) { alive_robots_[robot_id] = true; } alive_robots_pub_ = this->create_publisher(