@@ -37,7 +37,8 @@ PlaySwitcher::PlaySwitcher(const rclcpp::NodeOptions & options)
37
37
session_injection_sub = create_subscription<std_msgs::msg::String>(
38
38
" /session_injection" , 1 , [&](const std_msgs::msg::String & msg) {
39
39
// イベント注入(次のレフェリーイベント発生まで有効)
40
- play_situation_msg.command = crane_msgs::msg::PlaySituation::INJECTION;
40
+ play_situation_msg.command =
41
+ getSituationCommandNamedInt (crane_msgs::msg::PlaySituation::INJECTION);
41
42
play_situation_msg.header .stamp = now ();
42
43
play_situation_pub->publish (play_situation_msg);
43
44
});
@@ -80,8 +81,20 @@ void PlaySwitcher::referee_callback(const robocup_ssl_msgs::msg::Referee & msg)
80
81
std::optional<int > next_play_situation = std::nullopt;
81
82
82
83
// TODO(HansRobo): robocup_ssl_msgs/msg/Refereeをもう少しわかりやすい形式にする必要あり
83
- play_situation_msg.stage = msg.stage ;
84
- play_situation_msg.command_raw = msg.command ;
84
+ play_situation_msg.stage = getStageNamedInt (msg.stage );
85
+ play_situation_msg.command_raw = getRefereeCommandNamedInt (msg.command );
86
+ play_situation_msg.next_command_raw .clear ();
87
+ if (not msg.next_command .empty ()) {
88
+ play_situation_msg.next_command_raw .push_back (
89
+ getRefereeCommandNamedInt (msg.next_command .front ()));
90
+ }
91
+ if (bool is_yellow = msg.yellow .name == team_name; is_yellow) {
92
+ play_situation_msg.our_team_info = msg.yellow ;
93
+ play_situation_msg.their_team_info = msg.blue ;
94
+ } else {
95
+ play_situation_msg.our_team_info = msg.blue ;
96
+ play_situation_msg.their_team_info = msg.yellow ;
97
+ }
85
98
play_situation_msg.referee_raw = msg;
86
99
87
100
if (latest_raw_referee_command != static_cast <int >(msg.command )) {
@@ -95,7 +108,7 @@ void PlaySwitcher::referee_callback(const robocup_ssl_msgs::msg::Referee & msg)
95
108
// start_command_map[PlaySituation::THEIR_KICKOFF_START] = {}
96
109
97
110
if (msg.command == Referee::COMMAND_NORMAL_START) {
98
- next_play_situation = start_command_map[play_situation_msg.command ];
111
+ next_play_situation = start_command_map[play_situation_msg.command . value ];
99
112
inplay_command_info.reason =
100
113
" RAWコマンド変化&NORMAL_START:KICKOFF/"
101
114
" PENALTYはPREPARATIONからSTARTに移行" ;
@@ -171,14 +184,14 @@ void PlaySwitcher::referee_callback(const robocup_ssl_msgs::msg::Referee & msg)
171
184
172
185
// キックオフ・フリーキック・ペナルティーキック開始後,ボールが少なくとも0.05m動いた
173
186
if (
174
- play_situation_msg.command == PlaySituation::THEIR_KICKOFF_START or
175
- play_situation_msg.command == PlaySituation::THEIR_DIRECT_FREE or
187
+ play_situation_msg.command . value == PlaySituation::THEIR_KICKOFF_START or
188
+ play_situation_msg.command . value == PlaySituation::THEIR_DIRECT_FREE or
176
189
// 敵PKのINPLAYはOUR_PENALTY_STARTとして実装しているのでINPLAY遷移はしない
177
- // play_situation_msg.command == PlaySituation::THEIR_PENALTY_START or
178
- play_situation_msg.command == PlaySituation::OUR_KICKOFF_START or
179
- play_situation_msg.command == PlaySituation::OUR_DIRECT_FREE
190
+ // play_situation_msg.command.value == PlaySituation::THEIR_PENALTY_START or
191
+ play_situation_msg.command . value == PlaySituation::OUR_KICKOFF_START or
192
+ play_situation_msg.command . value == PlaySituation::OUR_DIRECT_FREE
180
193
// 味方PKのINPLAYはOUR_PENALTY_STARTとして実装しているのでINPLAY遷移はしない
181
- // play_situation_msg.command == PlaySituation::OUR_PENALTY_START
194
+ // play_situation_msg.command.value == PlaySituation::OUR_PENALTY_START
182
195
) {
183
196
if (0.05 <= (last_command_changed_state.ball_position - world_model->ball .pos ).norm ()) {
184
197
next_play_situation = PlaySituation::INPLAY;
@@ -195,13 +208,13 @@ void PlaySwitcher::referee_callback(const robocup_ssl_msgs::msg::Referee & msg)
195
208
196
209
// キックオフから10秒経過
197
210
if (
198
- play_situation_msg.command == PlaySituation::THEIR_KICKOFF_START &&
211
+ play_situation_msg.command . value == PlaySituation::THEIR_KICKOFF_START &&
199
212
10.0 <= (now () - last_command_changed_state.stamp ).seconds ()) {
200
213
next_play_situation = PlaySituation::INPLAY;
201
214
inplay_command_info.reason = " INPLAY判定:敵キックオフから10秒経過" ;
202
215
}
203
216
// フリーキックからN秒経過(N=5 @DivA, N=10 @DivB)
204
- if (play_situation_msg.command == PlaySituation::THEIR_DIRECT_FREE) {
217
+ if (play_situation_msg.command . value == PlaySituation::THEIR_DIRECT_FREE) {
205
218
if (30.0 <= (now () - last_command_changed_state.stamp ).seconds ()) {
206
219
next_play_situation = PlaySituation::INPLAY;
207
220
inplay_command_info.reason =
@@ -213,17 +226,17 @@ void PlaySwitcher::referee_callback(const robocup_ssl_msgs::msg::Referee & msg)
213
226
// コマンドが更新されているかを調べる
214
227
if (
215
228
next_play_situation != std::nullopt &&
216
- next_play_situation.value () != static_cast <int >(play_situation_msg.command )) {
217
- play_situation_msg.command = next_play_situation.value ();
229
+ next_play_situation.value () != static_cast <int >(play_situation_msg.command . value )) {
230
+ play_situation_msg.command = getSituationCommandNamedInt ( next_play_situation.value () );
218
231
play_situation_msg.reason_text = inplay_command_info.reason ;
219
232
220
233
RCLCPP_INFO (get_logger (), " ---" );
221
234
RCLCPP_INFO (
222
235
get_logger (), " RAW_CMD : %d (%s)" , msg.command ,
223
- PlaySituationWrapper:: getRefereeCommandText (msg.command ).c_str ());
236
+ getRefereeCommandText (msg.command ).c_str ());
224
237
RCLCPP_INFO (
225
- get_logger (), " INPLAY_CMD : %d (%s)" , play_situation_msg.command ,
226
- PlaySituationWrapper::getSituationCommandText ( play_situation_msg.command ) .c_str ());
238
+ get_logger (), " INPLAY_CMD : %d (%s)" , play_situation_msg.command . value ,
239
+ play_situation_msg.command . name .c_str ());
227
240
RCLCPP_INFO (get_logger (), " REASON : %s" , inplay_command_info.reason .c_str ());
228
241
RCLCPP_INFO (
229
242
get_logger (), " PREV_CMD_TIME: %f" , (now () - last_command_changed_state.stamp ).seconds ());
0 commit comments