Skip to content
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

Visual referee update: Free kick signal detection #1646

Open
wants to merge 32 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, 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 and PushingFreeKick, since the kicking_team during CornerKick and GoalKick can be deduced from the current ball position and the teams GlobalFieldSide, i.e. whether their are home or away. During KickIn and PushingFreeKick, when Home the DefenderRight and MidfielderRight should look at the referee and do the detection. When Away, this is done by DefenderLeft and MidfielderLeft and the first two non-penalized Searchers that are not the keeper.

This PR only implements the detection of the signal. It does not yet apply the detection to the kicking_team in the FilteredGameControllerState, since the game controller currently still always sends the kicking team, as it has not been updated yet (see RoboCup-SPL/GameController3) (EDIT: It has been updated).

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)

How to Test

  • In play, trigger the four free kicks CornerKick, GoalKick, KickIn, and PushingFreeKick.
    • Check that during KickIn and PushingFreeKick 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

@@ -325,6 +326,7 @@ impl GameState {
)]
pub enum Team {
Hulks,
#[default]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why should Team::Opponent be default? I don't think it is a good idea to add this default impl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. I only did this, because our implementation of PathDeserialize for Option<T> requires Default and I changed the kicking_team to a Option<Team>. I don't think there is another way to specialize the implementation of PathDeserialize specifically for Option<Team>... Dunno what else to do :/

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm yes you are right about that. You can still do a manual implementation of PathDeserialize when Team does not implement Default. @schmidma I am a bit confused that PathDeserialize for Option<T> requires T: Default. Looking at the code It looks like a totally different value is deserialized in the None case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not manage to manually implement PathDeserialize for Option<Team>, since adding spl_network_messages, which defines Team, as a dependency to the path_serde crate, creates a cyclic dependency 🫠.
I now simply removed the requirement for the Default derive for Option<T> by just not deserializing in the None case. This should be fine, since the value is a None anyway, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Depends on what you mean by "fine". It changes the behavior.
If the previous value was none, we'd construct a default one and recurse with the deserialization.
That was a design decision we made at some point, though I'm not sure we depend on this behavior anywhere currently.

@ThagonDuarte ThagonDuarte force-pushed the kicking-team-detection branch 5 times, most recently from 3eb1e77 to 8788ae5 Compare March 7, 2025 10:46
.filter_map(|(player_number, penalty)| {
penalty.is_none().then_some(player_number)
})
.skip(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

what if the keeper is penalized? If 1 is penalized and rest of the team is not, 3 & 4 would be selected instead of 2 & 3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is intentional. The lowest non-penalized player number, in this case 2, is chosen as replacement keeper, which should not look for the referee, imo.

@ThagonDuarte ThagonDuarte force-pushed the kicking-team-detection branch 6 times, most recently from 123a2bb to dfe36ac Compare March 12, 2025 22:04
@ThagonDuarte ThagonDuarte force-pushed the kicking-team-detection branch from dfe36ac to 6fbfb8d Compare March 13, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GO25 rules:2025 Changes needed to comply to rule changes for the SPL 2025 Season.
Projects
Status: Request for Review
Development

Successfully merging this pull request may close these issues.

Rule Changes: Visual Referee
3 participants