From e3debf74d6b2b6c8d6dc3664e0b6e5ee320352f3 Mon Sep 17 00:00:00 2001 From: NicolaiO Date: Wed, 22 May 2024 13:13:42 +0000 Subject: [PATCH] Resolve "Add Integration Test checking for KickOff Situation" Closes #1961 See merge request main/Sumatra!1838 sumatra-commit: be484e6acc8b4edf78321eb477422b3702393fdd --- .../java/edu/tigers/sumatra/ids/EAiTeam.java | 27 ++++++++++++++++++- .../tigers/sumatra/wp/data/BallContact.java | 10 +++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/modules/common/src/main/java/edu/tigers/sumatra/ids/EAiTeam.java b/modules/common/src/main/java/edu/tigers/sumatra/ids/EAiTeam.java index 8b037603..3ba8d482 100644 --- a/modules/common/src/main/java/edu/tigers/sumatra/ids/EAiTeam.java +++ b/modules/common/src/main/java/edu/tigers/sumatra/ids/EAiTeam.java @@ -21,7 +21,7 @@ public enum EAiTeam ; - private ETeamColor teamColor; + private final ETeamColor teamColor; /** @@ -53,4 +53,29 @@ public boolean matchesColor(ETeamColor color) { return color == teamColor; } + + + /** + * @param color + * @return + */ + public static EAiTeam opposite(final EAiTeam color) + { + return switch (color) + { + case YELLOW -> BLUE; + case BLUE -> YELLOW; + }; + } + + + /** + * @return + */ + public EAiTeam opposite() + { + return opposite(this); + } + + } diff --git a/modules/moduli-wp/src/main/java/edu/tigers/sumatra/wp/data/BallContact.java b/modules/moduli-wp/src/main/java/edu/tigers/sumatra/wp/data/BallContact.java index d5ea4f0f..df57a5fd 100644 --- a/modules/moduli-wp/src/main/java/edu/tigers/sumatra/wp/data/BallContact.java +++ b/modules/moduli-wp/src/main/java/edu/tigers/sumatra/wp/data/BallContact.java @@ -126,4 +126,14 @@ public boolean hadContactFromVision(double horizon) { return (current - visionEnd) * 1e-9 < horizon; } + + + /** + * @return true, if the ball had contact within the last 0.2 seconds + */ + public boolean hadRecentContactFromVision() + { + return hadContactFromVision(recentContactHorizon); + } + }