@@ -18,13 +18,13 @@ namespace crane::skills
18
18
class Goalie : public SkillBase <>
19
19
{
20
20
public:
21
- explicit Goalie (uint8_t id, const std::shared_ptr<WorldModelWrapper> & world_model );
21
+ explicit Goalie (uint8_t id, const std::shared_ptr<WorldModelWrapper> & wm );
22
22
23
- void emitBallFromPenaltyArea (crane::RobotCommandWrapper & target )
23
+ void emitBallFromPenaltyArea (crane::RobotCommandWrapper::SharedPtr & command )
24
24
{
25
25
auto ball = world_model->ball .pos ;
26
26
// パスできるロボットのリストアップ
27
- auto passable_robot_list = world_model->ours .getAvailableRobots (target. robot ->id );
27
+ auto passable_robot_list = world_model->ours .getAvailableRobots (command-> robot ->id );
28
28
passable_robot_list.erase (
29
29
std::remove_if (
30
30
passable_robot_list.begin (), passable_robot_list.end (),
@@ -52,25 +52,26 @@ class Goalie : public SkillBase<>
52
52
53
53
Point intermediate_point = ball + (ball - pass_target).normalized () * 0 .2f ;
54
54
double angle_ball_to_target = getAngle (pass_target - ball);
55
- double dot = (world_model->ball .pos - target. robot ->pose .pos )
55
+ double dot = (world_model->ball .pos - command-> robot ->pose .pos )
56
56
.normalized ()
57
57
.dot ((pass_target - world_model->ball .pos ).normalized ());
58
58
// ボールと目標の延長線上にいない && 角度があってないときは,中間ポイントを経由
59
59
if (
60
- dot < 0.95 || std::abs (getAngleDiff (angle_ball_to_target, target.robot ->pose .theta )) > 0.05 ) {
61
- target.setTargetPosition (intermediate_point);
62
- target.enableCollisionAvoidance ();
60
+ dot < 0.95 ||
61
+ std::abs (getAngleDiff (angle_ball_to_target, command->robot ->pose .theta )) > 0.05 ) {
62
+ command->setTargetPosition (intermediate_point);
63
+ command->enableCollisionAvoidance ();
63
64
} else {
64
- target. setTargetPosition (world_model->ball .pos );
65
- target. kickWithChip (0.4 ).disableCollisionAvoidance ();
66
- target. enableCollisionAvoidance ();
67
- target. disableBallAvoidance ();
65
+ command-> setTargetPosition (world_model->ball .pos );
66
+ command-> kickWithChip (0.4 ).disableCollisionAvoidance ();
67
+ command-> enableCollisionAvoidance ();
68
+ command-> disableBallAvoidance ();
68
69
}
69
- target. setTargetTheta (getAngle (pass_target - ball));
70
- target. disableGoalAreaAvoidance ();
70
+ command-> setTargetTheta (getAngle (pass_target - ball));
71
+ command-> disableGoalAreaAvoidance ();
71
72
}
72
73
73
- void inplay (crane::RobotCommandWrapper & target , bool enable_emit = true )
74
+ void inplay (crane::RobotCommandWrapper::SharedPtr & command , bool enable_emit = true )
74
75
{
75
76
auto goals = world_model->getOurGoalPosts ();
76
77
auto ball = world_model->ball .pos ;
@@ -83,14 +84,14 @@ class Goalie : public SkillBase<>
83
84
// シュートブロック
84
85
phase = " シュートブロック" ;
85
86
ClosestPoint result;
86
- bg::closest_point (ball_line, target. robot ->pose .pos , result);
87
- target. setTargetPosition (result.closest_point );
88
- target. setTargetTheta (getAngle (-world_model->ball .vel ));
87
+ bg::closest_point (ball_line, command-> robot ->pose .pos , result);
88
+ command-> setTargetPosition (result.closest_point );
89
+ command-> setTargetTheta (getAngle (-world_model->ball .vel ));
89
90
} else {
90
91
if (world_model->ball .isStopped () && world_model->isFriendDefenseArea (ball) && enable_emit) {
91
92
// ボールが止まっていて,味方ペナルティエリア内にあるときは,ペナルティエリア外に出す
92
93
phase = " ボール排出" ;
93
- emitBallFromPenaltyArea (target );
94
+ emitBallFromPenaltyArea (command );
94
95
} else {
95
96
phase = " " ;
96
97
const double BLOCK_DIST = 0.15 ;
@@ -103,8 +104,8 @@ class Goalie : public SkillBase<>
103
104
phase = " ボールを待ち受ける" ;
104
105
Point goal_center = world_model->getOurGoalCenter ();
105
106
goal_center << goals.first .x (), 0 .0f ;
106
- target. setTargetPosition (goal_center + (ball - goal_center).normalized () * BLOCK_DIST);
107
- target. lookAtBall ();
107
+ command-> setTargetPosition (goal_center + (ball - goal_center).normalized () * BLOCK_DIST);
108
+ command-> lookAtBall ();
108
109
}
109
110
}
110
111
}
0 commit comments