Skip to content

Kick in kicking team detection #1646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

ThagonDuarte
Copy link
Contributor

@ThagonDuarte ThagonDuarte commented Feb 20, 2025

Why? What?

The rule update for the 2025 season introduces a change to the set play of free kicks. Instead of sending the kicking team in the game controller message during all free kicks, now, during CornerKick, GoalKick, KickIn, PenaltyKick and PushingFreeKick no kicking team will be sent in the game controller message. Instead, the head referee will give a visual signal to indicate the direction of play for the kicking team. This means a signal in the direction of the goal of the HULKs indicates that the Opponent is the kicking team. This signal can be seen below:

Set play visual referee signal

This expands our current visual referee implementation to now also detect this free kick visual referee signal.
We only try to detect the visual referee signal in KickIn since the kicking_team during CornerKick, GoalKick, and PenaltyKick can be deduced from the current ball position and the teams GlobalFieldSide, i.e. whether their are home or away and PushingFreeKick can be deduced by looking at the changed penalties. During KickIn when Home the DefenderRight and MidfielderRight should look at the referee and do the detection. When Away, this is done by DefenderLeft and MidfielderLeft. On both sides the first two non-penalized Searchers that are not the keeper also look at the referee, for the case, that both the currently detecting roles are Searcher.

Depends on #1782
Fixes #1476

ToDo / Known Issues

  • Implement behavior for looking at the referee for pose detection during set plays.
  • Implement detection logic and filtering.
  • Implement bevyhavior simulator scenarios for
    • Check behavior for visual referee during free kicks works correctly
  • Make NAOs look further up to better see referee during detection

Ideas for Next Iterations (Not This PR)

  • Add standby to ready visual referee to bevyhavior simulator

How to Test

  • In play, trigger KickIn
    • Check that only the correct defender and midfielder or searcher look at the referee and do the visual signal detection.
    • Check that the visual referee free kick pose signal is detected, filtered, and interpreted correctly.

@ThagonDuarte ThagonDuarte added rules:2025 Changes needed to comply to rule changes for the SPL 2025 Season. GO25 labels Feb 20, 2025
@ThagonDuarte ThagonDuarte self-assigned this Feb 20, 2025
@ThagonDuarte ThagonDuarte force-pushed the kicking-team-detection branch from 02fbf70 to f24baba Compare February 21, 2025 13:13
@ThagonDuarte ThagonDuarte removed their assignment Feb 21, 2025
@oleflb oleflb self-assigned this Feb 26, 2025
Copy link
Contributor

@oleflb oleflb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review not yet complete

@ThagonDuarte ThagonDuarte force-pushed the kicking-team-detection branch 5 times, most recently from 3eb1e77 to 8788ae5 Compare March 7, 2025 10:46
@ThagonDuarte ThagonDuarte force-pushed the kicking-team-detection branch 8 times, most recently from 6fbfb8d to a165dd4 Compare March 13, 2025 16:52
.filtered_game_controller_state
.clone()
.is_some_and(|filtered_game_controller_state| {
is_free_kick(filtered_game_controller_state, world_state.clone())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no clone please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +122 to +126
global_field_side: if message.hulks_team_is_home_after_coin_toss {
GlobalFieldSide::Home
} else {
GlobalFieldSide::Away
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: check correctness of hulks_team_is_home_after_coin_toss (second half)

.truncate(*context.referee_pose_queue_length);

let (own_detected_kicking_team, number_of_detections) =
most_detections(self.detected_free_kick_detections_queue.clone().into());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use references here

.iter()
.cloned()
.filter(|kicking_team| *kicking_team == Team::Hulks)
.collect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use .count() instead of .collect().len()

.collect();
let own_detections_opponent: Vec<Team> = detections
.iter()
.cloned()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer copied here

Comment on lines 179 to 249
match (global_field_side, free_kick_signal_pose) {
(
GlobalFieldSide::Home,
Some(PoseKind::FreeKick {
global_field_side: GlobalFieldSide::Away,
}),
) => Some(Team::Hulks),
(
GlobalFieldSide::Home,
Some(PoseKind::FreeKick {
global_field_side: GlobalFieldSide::Home,
}),
) => Some(Team::Opponent),
(
GlobalFieldSide::Away,
Some(PoseKind::FreeKick {
global_field_side: GlobalFieldSide::Away,
}),
) => Some(Team::Opponent),
(
GlobalFieldSide::Away,
Some(PoseKind::FreeKick {
global_field_side: GlobalFieldSide::Home,
}),
) => Some(Team::Hulks),
_ => None,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
match (global_field_side, free_kick_signal_pose) {
(
GlobalFieldSide::Home,
Some(PoseKind::FreeKick {
global_field_side: GlobalFieldSide::Away,
}),
) => Some(Team::Hulks),
(
GlobalFieldSide::Home,
Some(PoseKind::FreeKick {
global_field_side: GlobalFieldSide::Home,
}),
) => Some(Team::Opponent),
(
GlobalFieldSide::Away,
Some(PoseKind::FreeKick {
global_field_side: GlobalFieldSide::Away,
}),
) => Some(Team::Opponent),
(
GlobalFieldSide::Away,
Some(PoseKind::FreeKick {
global_field_side: GlobalFieldSide::Home,
}),
) => Some(Team::Hulks),
_ => None,
}
free_kick_signal_pose.and_then(|a| if a.global_field_side == global_field_side { Team::Opponent } else { Team::Hulks })

@ThagonDuarte ThagonDuarte moved this from Request for Review to In Progress in Development Mar 29, 2025
@ThagonDuarte ThagonDuarte force-pushed the kicking-team-detection branch from 05ec27b to 82beb18 Compare April 1, 2025 09:58
@ThagonDuarte ThagonDuarte changed the title Visual referee update: Free kick signal detection Kick in kicking team detection Apr 1, 2025
@ThagonDuarte ThagonDuarte moved this from In Progress to Request for Review in Development Apr 1, 2025
@ThagonDuarte ThagonDuarte enabled auto-merge April 1, 2025 10:28
@ThagonDuarte ThagonDuarte moved this from Request for Review to In Progress in Development Apr 1, 2025
@ThagonDuarte ThagonDuarte force-pushed the kicking-team-detection branch from 8d077e2 to accc70a Compare April 2, 2025 14:36
@oleflb oleflb removed the GO25 label Apr 8, 2025
@ThagonDuarte ThagonDuarte force-pushed the kicking-team-detection branch 4 times, most recently from 74339cf to 57c816e Compare April 16, 2025 17:46
`LookAtReferee` during free kicks

Detect `FreeKickPose` `PoseKind`

Filter detected `FreeKickPose`

Led status feedback for visual referee free kick detections

Fix parameter import in `FreeKickSignalFilter`

Make clippy happy

Add fallback `Action` after `Action` `LookAtReferee`

Co-authored-by: MaikRe <[email protected]>

Always produce `MotionCommand` in `LookAtReferee`

Co-authored-by: MaikRe <[email protected]>

Fix `MotionCommand` matching

Co-authored-by: MaikRe <[email protected]>

Add scenario for visual referee free kick behavior

Co-authored-by: MaikRe <[email protected]>

Only add `Option<Team>` where necessary

Reset `ReadySignalDetectionFilter` outside of `Standby`

Reset `FreeKickSignalFilter` outside of `KickIn` and `PushingFreeKick`

Freeze role assignment during free kick detection

Add full image pose detection

Let two searcher look at referee during free kicks

Lower `ImageRegion::Bottom` y pixel target

Address review comments

Fix scenario to updated behavior and renaming

Better free kick pose interpretation

Only draw pose detection dead zone overlay in `Standby`

Formatting

Remove `target` from `HeadMotion::LookAtReferee`

Refactor `initial.rs`

Address review comments II

Only keep role for relevant roles during free kicks

Throw error in path deserialize `Option<T>` if its `None`

Produce correct `head_yaw` for `LookAtReferee`

Change `hulks_team_is_home_after_coin_toss` to `GlobalFieldSide`

Change default `expected_referee_position` to center circle

Dequadruplicate free kick behavior

Dont copy world state

Address review comments III
@ThagonDuarte ThagonDuarte force-pushed the kicking-team-detection branch from 57c816e to 831eaa7 Compare April 17, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rules:2025 Changes needed to comply to rule changes for the SPL 2025 Season.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Rule Changes: Visual Referee
3 participants