Skip to content

Commit

Permalink
reset detection time
Browse files Browse the repository at this point in the history
  • Loading branch information
phillip kammradt committed Aug 7, 2024
1 parent 7c4e2d8 commit 4548d01
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions crates/control/src/referee_pose_detection_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ use serde::{Deserialize, Serialize};
use context_attribute::context;
use framework::{AdditionalOutput, MainOutput, PerceptionInput};
use hardware::NetworkInterface;
use spl_network_messages::{HulkMessage, PlayerNumber, VisualRefereeMessage};
use spl_network_messages::{GameState, HulkMessage, PlayerNumber, VisualRefereeMessage};
use types::{
cycle_time::CycleTime,
game_controller_state::GameControllerState,
messages::{IncomingMessage, OutgoingMessage},
players::Players,
pose_detection::VisualRefereeState,
Expand Down Expand Up @@ -41,7 +42,7 @@ pub struct CycleContext {
network_message: PerceptionInput<Option<IncomingMessage>, "SplNetwork", "filtered_message?">,

cycle_time: Input<CycleTime, "cycle_time">,

game_controller_state: Input<Option<GameControllerState>, "game_controller_state?">,
initial_message_grace_period:
Parameter<Duration, "referee_pose_detection_filter.initial_message_grace_period">,
minimum_above_head_arms_detections:
Expand Down Expand Up @@ -85,6 +86,14 @@ impl RefereePoseDetectionFilter {
let (is_referee_ready_pose_detected, did_detect_any_referee_this_cycle) =
self.update(&context)?;

let is_standby = matches!(
context.game_controller_state.unwrap().game_state,
GameState::Standby
);
if !is_standby {
self.detection_times = Default::default();
}

let majority_vote_is_referee_ready_pose_detected = decide(
self.detection_times,
cycle_start_time,
Expand Down

0 comments on commit 4548d01

Please sign in to comment.