@@ -24,11 +24,17 @@ namespace crane
24
24
class OurKickOffPlanner : public PlannerBase
25
25
{
26
26
private:
27
- std::shared_ptr<skills::KickoffAttack> kickoff_attack_;
27
+ std::shared_ptr<skills::KickoffAttack> kickoff_attack;
28
+ std::shared_ptr<RobotCommandWrapper> attacker_command;
28
29
29
- std::shared_ptr<skills::KickoffSupport> kickoff_support_ public
30
- : COMPOSITION_PUBLIC explicit OurKickOffPlanner (
31
- WorldModelWrapper::SharedPtr & world_model, ConsaiVisualizerWrapper::SharedPtr visualizer)
30
+ std::shared_ptr<skills::KickoffSupport> kickoff_support;
31
+ std::shared_ptr<RobotCommandWrapper> supporter_command;
32
+
33
+ // std::shared_ptr<ConsaiVisualizerWrapper> visualizer;
34
+
35
+ public:
36
+ COMPOSITION_PUBLIC explicit OurKickOffPlanner (
37
+ WorldModelWrapper::SharedPtr & world_model, ConsaiVisualizerWrapper::SharedPtr visualizer)
32
38
: PlannerBase(" our_kickoff_planner" , world_model, visualizer)
33
39
{
34
40
}
@@ -37,24 +43,14 @@ class OurKickOffPlanner : public PlannerBase
37
43
const std::vector<RobotIdentifier> & robots) override
38
44
{
39
45
std::vector<crane_msgs::msg::RobotCommand> robot_commands;
40
- for (auto robot_id : robots) {
41
- crane_msgs::msg::RobotCommand target;
42
- auto robot = world_model->getRobot (robot_id);
43
-
44
- target.robot_id = robot_id.robot_id ;
45
- target.chip_enable = false ;
46
- target.dribble_power = 0.0 ;
47
- target.kick_power = 0.0 ;
48
46
49
- // TODO: implement
50
- target. motion_mode_enable = false ;
47
+ kickoff_attack-> run (*attacker_command, visualizer);
48
+ kickoff_support-> run (*supporter_command, visualizer) ;
51
49
52
- // setTarget(target.target_x, 0.0);
53
- // setTarget(target.target_y, 0.0);
54
- // target.target_velocity.theta = 0.0;
50
+ robot_commands.emplace_back (attacker_command->getMsg ());
51
+ robot_commands.emplace_back (supporter_command->getMsg ());
55
52
56
- robot_commands.emplace_back (target);
57
- }
53
+ // いい感じにSUCCESSも返す
58
54
return {PlannerBase::Status::RUNNING, robot_commands};
59
55
}
60
56
@@ -64,20 +60,32 @@ class OurKickOffPlanner : public PlannerBase
64
60
{
65
61
// 一番ボールに近いロボットをkickoff attack
66
62
auto best_attacker = std::max_element (
67
- selectable_robots.begin (), selectable_robots.end (),
68
- [this ](const uint8_t & a, const uint8_t & b) {
69
- return world_model->getRobot (a)->getDistance (world_model->ball .pos ) <
70
- world_model->getRobot (b)->getDistance (world_model->ball .pos );
63
+ selectable_robots.begin (), selectable_robots.end (), [this ](const auto & a, const auto & b) {
64
+ return world_model->getOurRobot (a)->getDistance (world_model->ball .pos ) <
65
+ world_model->getOurRobot (b)->getDistance (world_model->ball .pos );
71
66
});
72
67
Point supporter_pos{0.0 , 2.0 };
73
68
auto best_supporter = std::max_element (
74
69
selectable_robots.begin (), selectable_robots.end (),
75
- [this , supporter_pos](const uint8_t & a, const uint8_t & b) {
76
- return world_model->getRobot (a)->getDistance (supporter_pos) <
77
- world_model->getRobot (b)->getDistance (supporter_pos);
70
+ [this , supporter_pos, best_attacker](const auto & a, const auto & b) {
71
+ if (a == *best_attacker) {
72
+ // bの方大きい => best_attackerであるaが除外される
73
+ return true ;
74
+ } else if (b == *best_attacker) {
75
+ // bの方大きくない => best_attackerであるbが除外される
76
+ return false ;
77
+ } else {
78
+ return world_model->getOurRobot (a)->getDistance (supporter_pos) <
79
+ world_model->getOurRobot (b)->getDistance (supporter_pos);
80
+ }
78
81
});
79
82
80
- // TODO return
83
+ kickoff_attack = std::make_shared<skills::KickoffAttack>(*best_attacker, world_model);
84
+ attacker_command = std::make_shared<RobotCommandWrapper>(*best_attacker, world_model);
85
+ kickoff_support = std::make_shared<skills::KickoffSupport>(*best_supporter, world_model);
86
+ supporter_command = std::make_shared<RobotCommandWrapper>(*best_supporter, world_model);
87
+
88
+ return {*best_attacker, *best_supporter};
81
89
}
82
90
};
83
91
0 commit comments