Skip to content

Commit

Permalink
Attackerが間違ったIDを選択してしまうバグを修正 (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
HansRobo authored Jan 30, 2025
1 parent f7292b6 commit b14c8a9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class KickEventDetector
// print detected bots
std::optional<KickOrigin> kick_event_origin = std::nullopt;
for (const auto & id : detected_bots.friends) {
RCLCPP_INFO_STREAM(rclcpp::get_logger("aaaa"), "Detected friend: " << static_cast<int>(id));
SvgCircleBuilder circle_builder;
circle_builder.center(world_model.getOurRobot(id)->pose.pos)
.radius(0.5)
Expand All @@ -71,7 +70,6 @@ class KickEventDetector
kick_event_origin.emplace(ros_clock.now(), world_model.ball.pos, RobotIdentifier{true, id});
}
for (const auto & id : detected_bots.enemies) {
RCLCPP_INFO_STREAM(rclcpp::get_logger("aaaa"), "Detected enemy: " << static_cast<int>(id));
SvgCircleBuilder circle_builder;
circle_builder.center(world_model.getTheirRobot(id)->pose.pos)
.radius(0.5)
Expand All @@ -92,14 +90,6 @@ class KickEventDetector
// キック中断判定
kick_history.emplace_back(ongoing_kick_origin.value(), world_model.ball.pos);
ongoing_kick_origin = std::nullopt;
SvgCircleBuilder circle_builder;
circle_builder.center(world_model.ball.pos)
.radius(3.5)
.stroke("green")
.fill("black")
.strokeWidth(2);
visualizer->add(circle_builder.getSvgString());
// visualizer->addCircle(world_model.ball.pos, 3.5, 2, "green", "black", 1.0, "EVENT");
}
}

Expand All @@ -108,8 +98,8 @@ class KickEventDetector
SvgLineBuilder line_builder;
line_builder.start(ongoing_kick_origin.value().position)
.end(world_model.ball.pos)
.stroke("red")
.strokeWidth(2);
.stroke("red", 0.3)
.strokeWidth(200);
visualizer->add(line_builder.getSvgString());
// visualizer->addTube(
// world_model.ball.pos, ongoing_kick_origin.value().position,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ class AttackerSkillPlanner : public PlannerBase
const std::unordered_map<uint8_t, RobotRole> & prev_roles, PlannerContext & context)
-> std::vector<uint8_t> override
{
std::cout << "AttackerSkillPlanner::getSelectedRobots: " << selectable_robots << std::endl;
if (auto our_frontier = world_model->getOurFrontier();
our_frontier && ranges::contains(selectable_robots, our_frontier->robot->id)) {
std::cout << "有効なフロンティア、" << static_cast<int>(our_frontier->robot->id) << "を選択"
<< std::endl;
auto base =
std::make_shared<RobotCommandWrapperBase>("attacker", our_frontier->robot->id, world_model);
skill = std::make_shared<skills::Attacker>(base);
Expand All @@ -101,13 +98,11 @@ class AttackerSkillPlanner : public PlannerBase
},
prev_roles, context);
if (not selected_robots.empty()) {
std::cout << "ボールに一番近いロボット、" << static_cast<int>(selected_robots.front())
<< "を選択" << std::endl;
auto base = std::make_shared<RobotCommandWrapperBase>(
"attacker", selectable_robots.front(), world_model);
"attacker", selected_robots.front(), world_model);
skill = std::make_shared<skills::Attacker>(base);
}
return selected_robots;
return {selected_robots.front()};
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class VisualizationAggregator : public rclcpp::Node
});
publisher =
create_publisher<crane_visualization_interfaces::msg::SvgLayerArray>("/aggregated_svgs", 10);
timer = create_wall_timer(std::chrono::milliseconds(100), [this]() {
timer = create_wall_timer(std::chrono::milliseconds(16), [this]() {
crane_visualization_interfaces::msg::SvgLayerArray msg;

for (const auto & [layer, primitives] : layers) {
Expand Down

0 comments on commit b14c8a9

Please sign in to comment.