Skip to content

Commit

Permalink
Make time to reach not an Option in Striker Message
Browse files Browse the repository at this point in the history
  • Loading branch information
knoellle committed Mar 7, 2025
1 parent beb75a1 commit e197cb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions crates/control/src/role_assignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ impl RoleAssignment {
player_number: *context.player_number,
pose,
ball_position,
time_to_reach_kick_position: context.time_to_reach_kick_position.copied(),
time_to_reach_kick_position: *context.time_to_reach_kick_position.unwrap(),
})))
.wrap_err("failed to write StrikerMessage to hardware")
}
Expand Down Expand Up @@ -457,7 +457,7 @@ enum Event {
#[derive(Clone, Copy, Debug)]
struct StrikerEvent {
player_number: PlayerNumber,
time_to_reach_kick_position: Option<Duration>,
time_to_reach_kick_position: Duration,
}

#[allow(clippy::too_many_arguments)]
Expand Down Expand Up @@ -580,7 +580,7 @@ fn claim_striker_or_other_role(
optional_roles: &[Role],
) -> Role {
let shorter_time_to_reach =
time_to_reach_kick_position < striker_event.time_to_reach_kick_position;
time_to_reach_kick_position.unwrap() < striker_event.time_to_reach_kick_position;
let time_to_reach_viable =
time_to_reach_kick_position.is_some_and(|duration| duration < Duration::from_secs(1200));

Expand Down
5 changes: 2 additions & 3 deletions crates/spl_network_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ pub struct StrikerMessage {
pub player_number: PlayerNumber,
pub pose: Pose2<Field>,
pub ball_position: BallPosition<Field>,
// TODO: make non-optional
pub time_to_reach_kick_position: Option<Duration>,
pub time_to_reach_kick_position: Duration,
}

#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize)]
Expand Down Expand Up @@ -127,7 +126,7 @@ mod tests {
position: Point::origin(),
age: Duration::MAX,
},
time_to_reach_kick_position: Some(Duration::MAX),
time_to_reach_kick_position: Duration::MAX,
});
assert!(bincode::serialize(&test_message).unwrap().len() <= 128)
}
Expand Down

0 comments on commit e197cb4

Please sign in to comment.