Skip to content

Commit

Permalink
defender checks if goalie is active and acts like goalie if needed (#608
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cleWu03 authored Nov 28, 2024
2 parents 89c7035 + 5b08123 commit 2f4e264
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@ def is_not_goalie(team_data: TeamData) -> bool:
# Count valid team data infos (aka robots with valid team data)
return sum(map(self.is_valid, team_data_infos))

def get_is_goalie_active(self) -> bool:
def is_a_goalie(team_data: TeamData) -> bool:
return team_data.strategy.role == Strategy.ROLE_GOALIE

# Get the team data infos for all robots (ignoring the robot id/name)
team_data_infos = self.team_data.values()

# Remove none goalie Data
team_data_infos = filter(is_a_goalie, team_data_infos)

# Count valid team data infos (aka robots with valid team data)
return sum(map(self.is_valid, team_data_infos)) == 1

def get_own_time_to_ball(self) -> float:
return self.own_time_to_ball

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from bitbots_blackboard.body_blackboard import BodyBlackboard
from dynamic_stack_decider.abstract_decision_element import AbstractDecisionElement


class GoalieActive(AbstractDecisionElement):
"""
Decides whether the goalie is on field or not
"""

blackboard: BodyBlackboard

def __init__(self, blackboard, dsd, parameters):
super().__init__(blackboard, dsd, parameters)

def perform(self, reevaluate=False):
if self.blackboard.team_data.get_is_goalie_active():
return "YES"
else:
return "NO"

def get_reevaluate(self):
return True
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ $GoalieHandlingBall
NO --> #KickWithAvoidance

#DefensePositioning
@LookAtFieldFeatures, @ChangeAction + action:positioning, @GoToDefensePosition
$GoalieActive
YES --> @LookAtFieldFeatures, @ChangeAction + action:positioning, @GoToDefensePosition
NO --> @LookAtFieldFeatures, @ChangeAction + action:positioning, @GoToBlockPosition

#SupporterRole
$PassStarted
Expand Down

0 comments on commit 2f4e264

Please sign in to comment.