Skip to content

Commit 8fdb49b

Browse files
committed
Parse KICKING_TEAM_NONE according to update header
With the updated version of the game controller, the `RoboCupGameControlData.h` now specifies a team number for `kicking_team = None`. This is now parsed correctly into the `GameControllerStateMessage`.
1 parent 506a967 commit 8fdb49b

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

crates/spl_network_messages/headers/RoboCupGameControlData.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#define SET_PLAY_KICK_IN 4
4949
#define SET_PLAY_PENALTY_KICK 5
5050

51+
#define KICKING_TEAM_NONE 255
52+
5153
#define PENALTY_NONE 0
5254
// SPL
5355
#define PENALTY_SPL_ILLEGAL_BALL_CONTACT 1 // ball holding / playing with hands
@@ -96,7 +98,7 @@ struct RoboCupGameControlData
9698
uint8_t state; // state of the game (STATE_READY, STATE_PLAYING, etc)
9799
uint8_t setPlay; // active set play (SET_PLAY_NONE, SET_PLAY_GOAL_KICK, etc)
98100
uint8_t firstHalf; // 1 = game in first half, 0 otherwise
99-
uint8_t kickingTeam; // the team number of the next team to kick off, free kick etc
101+
uint8_t kickingTeam; // the team number of the next team to kick off, free kick etc, or KICKING_TEAM_NONE
100102
int16_t secsRemaining; // estimate of number of seconds remaining in the half
101103
int16_t secondaryTime; // number of seconds shown as secondary time (remaining ready, until free ball, etc)
102104
struct TeamInfo teams[2];

crates/spl_network_messages/src/game_controller_state_message.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::{
2626
STATE_PLAYING, STATE_READY, STATE_SET, STATE_STANDBY, TEAM_BLACK, TEAM_BLUE, TEAM_BROWN,
2727
TEAM_GRAY, TEAM_GREEN, TEAM_ORANGE, TEAM_PURPLE, TEAM_RED, TEAM_WHITE, TEAM_YELLOW,
2828
},
29-
PlayerNumber, HULKS_TEAM_NUMBER,
29+
PlayerNumber, HULKS_TEAM_NUMBER, NONE_TEAM_NUMBER,
3030
};
3131

3232
#[derive(Clone, Debug, Deserialize, Serialize, PathSerialize, PathIntrospect)]
@@ -330,9 +330,13 @@ pub enum Team {
330330
Opponent,
331331
}
332332

333-
impl Team {
333+
impl TryFrom<u8> for Team {
334+
type Error = Report;
335+
334336
fn try_from(team_number: u8) -> Result<Self> {
335-
let team = if team_number == HULKS_TEAM_NUMBER {
337+
let team = if team_number == NONE_TEAM_NUMBER {
338+
return Err(Report::msg("kicking team is none"));
339+
} else if team_number == HULKS_TEAM_NUMBER {
336340
Team::Hulks
337341
} else {
338342
Team::Opponent

crates/spl_network_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ pub struct BallPosition<Frame> {
6161
}
6262

6363
pub const HULKS_TEAM_NUMBER: u8 = 24;
64+
pub const NONE_TEAM_NUMBER: u8 = 255;
6465

6566
#[derive(
6667
Clone,

0 commit comments

Comments
 (0)