Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sim Alive Robots Publish #2215

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rj_constants/include/rj_constants/topic_names.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion soccer/src/soccer/radio/radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Radio::Radio()
}

alive_robots_pub_ =
create_publisher<rj_msgs::msg::AliveRobots>("/alive_robots", rclcpp::QoS(1));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason base Radio class (used by network_radio) and sim_radio used different topic names for alive robots. I went with the one used by sim.

create_publisher<rj_msgs::msg::AliveRobots>(strategy::topics::kAliveRobots, rclcpp::QoS(1));

tick_timer_ = create_wall_timer(tick_period_, [this]() { tick(); });
}
Expand Down
12 changes: 7 additions & 5 deletions soccer/src/soccer/radio/sim_radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <= 6; robot_id++) {
alive_robots_[robot_id] = true;
}
alive_robots_pub_ = this->create_publisher<rj_msgs::msg::AliveRobots>(
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<rj_msgs::msg::AliveRobots>("strategy/alive_robots", rclcpp::QoS(1));

buffer_.resize(1024);
start_receive();
Expand Down
2 changes: 1 addition & 1 deletion soccer/src/soccer/strategy/agent/agent_action_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<rj_msgs::msg::AliveRobots>(
"strategy/alive_robots", 1,
::strategy::topics::kAliveRobots, 1,
[this](rj_msgs::msg::AliveRobots::SharedPtr msg) { alive_robots_callback(msg); });

game_settings_sub_ = create_subscription<rj_msgs::msg::GameSettings>(
Expand Down
Loading