Skip to content

Commit

Permalink
Reset FreeKickSignalFilter outside of set plays
Browse files Browse the repository at this point in the history
  • Loading branch information
ThagonDuarte committed Jan 22, 2025
1 parent 4214727 commit 14ee607
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions crates/control/src/free_kick_signal_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use types::{
pub struct FreeKickSignalFilter {
free_kick_signal_detection_times: Players<Option<TimeTaggedKickingTeamDetections>>,
detected_free_kick_detections_queue: VecDeque<Team>,
has_sent_free_kick_signal_message: bool,
}

#[context]
Expand Down Expand Up @@ -73,6 +74,7 @@ impl FreeKickSignalFilter {
*context.referee_pose_queue_length,
),
free_kick_signal_detection_times: Default::default(),
has_sent_free_kick_signal_message: false,
})
}

Expand Down Expand Up @@ -104,6 +106,17 @@ impl FreeKickSignalFilter {
&mut self,
context: &CycleContext<impl NetworkInterface>,
) -> Result<FreeKickSignalDetectionResult> {
if context.game_controller_state.sub_state.is_none() {
self.detected_free_kick_detections_queue = Default::default();
self.free_kick_signal_detection_times = Default::default();
self.has_sent_free_kick_signal_message = false;

return Ok(FreeKickSignalDetectionResult {
did_detect_any_free_kick_signal_this_cycle: false,
detected_free_kick_kicking_team: None,
});
}

let time_tagged_persistent_messages =
unpack_message_tree(&context.network_message.persistent);

Expand Down Expand Up @@ -149,12 +162,14 @@ impl FreeKickSignalFilter {
time: context.cycle_time.start_time,
detected_kicking_team: own_detected_kicking_team,
});

send_own_detection_message(
context.hardware_interface.clone(),
*context.player_number,
Some(own_detected_kicking_team),
)?;
if self.has_sent_free_kick_signal_message {
send_own_detection_message(
context.hardware_interface.clone(),
*context.player_number,
Some(own_detected_kicking_team),
)?;
self.has_sent_free_kick_signal_message = true;
}
}

let majority_voted_kicking_team_detection = majority_vote_free_kick_signal(
Expand Down

0 comments on commit 14ee607

Please sign in to comment.