From d8532a473d152a1fe72b6a94f75e15af6a77c2a3 Mon Sep 17 00:00:00 2001 From: Alexsandro Santos Date: Sun, 10 Oct 2021 20:57:43 -0300 Subject: [PATCH 1/2] Advance when Penalty --- entities/coach/larc2021.py | 8 ++++++++ entities/plays/larc2021/__init__.py | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/entities/coach/larc2021.py b/entities/coach/larc2021.py index c547e52f..ee3fd632 100644 --- a/entities/coach/larc2021.py +++ b/entities/coach/larc2021.py @@ -16,14 +16,19 @@ def __init__(self, match): penalty_play = plays.larc2021.PenaltyPlay(self) goalkick_play = plays.larc2021.GoalKickPlay(self) + defend_penalty_play = plays.larc2021.DefendPenaltyPlay(self) + penalty_trigger = plays.OnPenaltyKick(self.match.game.referee, self.match.team_color) seven_seconds_trigger = plays.WaitForTrigger(7) goalkick_trigger = plays.OnGoalKick(self.match.game.referee, self.match.team_color) + + defend_penalty_trigger = plays.OnPenaltyKick(self.match.game.referee, self.match.opposite_team_color) self.playbook.add_play(main_play) self.playbook.add_play(penalty_play) self.playbook.add_play(goalkick_play) + self.playbook.add_play(defend_penalty_play) main_play.add_transition(penalty_trigger, penalty_play) penalty_play.add_transition(seven_seconds_trigger, main_play) @@ -31,6 +36,9 @@ def __init__(self, match): main_play.add_transition(goalkick_trigger, goalkick_play) goalkick_play.add_transition(seven_seconds_trigger, main_play) + main_play.add_transition(defend_penalty_trigger, goalkick_play) + goalkick_play.add_transition(seven_seconds_trigger, main_play) + self.playbook.set_play(main_play) def _get_positions(self, foul, team_color, foul_color, quadrant): diff --git a/entities/plays/larc2021/__init__.py b/entities/plays/larc2021/__init__.py index e9c6a99c..065fa854 100644 --- a/entities/plays/larc2021/__init__.py +++ b/entities/plays/larc2021/__init__.py @@ -1,3 +1,5 @@ from entities.plays.larc2021.mainPlay import MainPlay from entities.plays.larc2021.penaltyPlay import PenaltyPlay -from entities.plays.larc2021.goalKickPlay import GoalKickPlay \ No newline at end of file +from entities.plays.larc2021.goalKickPlay import GoalKickPlay + +from entities.plays.larc2021.defendPenaltyPlay import DefendPenaltyPlay \ No newline at end of file From b782bcdefccf155834c80e7fa66df69fcaf27c45 Mon Sep 17 00:00:00 2001 From: Alexsandro Santos Date: Sun, 10 Oct 2021 21:26:36 -0300 Subject: [PATCH 2/2] Create a waitfor trigger for each transition on Playbook --- entities/coach/larc2021.py | 12 +++++++----- entities/plays/larc2021/goalKickPlay.py | 4 ++-- main.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/entities/coach/larc2021.py b/entities/coach/larc2021.py index ee3fd632..eaffaa0f 100644 --- a/entities/coach/larc2021.py +++ b/entities/coach/larc2021.py @@ -19,7 +19,9 @@ def __init__(self, match): defend_penalty_play = plays.larc2021.DefendPenaltyPlay(self) penalty_trigger = plays.OnPenaltyKick(self.match.game.referee, self.match.team_color) - seven_seconds_trigger = plays.WaitForTrigger(7) + penalty_seconds_trigger = plays.WaitForTrigger(12) + goalkick_seconds_trigger = plays.WaitForTrigger(9) + defendpenalty_seconds_trigger = plays.WaitForTrigger(9) goalkick_trigger = plays.OnGoalKick(self.match.game.referee, self.match.team_color) @@ -31,13 +33,13 @@ def __init__(self, match): self.playbook.add_play(defend_penalty_play) main_play.add_transition(penalty_trigger, penalty_play) - penalty_play.add_transition(seven_seconds_trigger, main_play) + penalty_play.add_transition(penalty_seconds_trigger, main_play) main_play.add_transition(goalkick_trigger, goalkick_play) - goalkick_play.add_transition(seven_seconds_trigger, main_play) + goalkick_play.add_transition(goalkick_seconds_trigger, main_play) - main_play.add_transition(defend_penalty_trigger, goalkick_play) - goalkick_play.add_transition(seven_seconds_trigger, main_play) + main_play.add_transition(defend_penalty_trigger, defend_penalty_play) + defend_penalty_play.add_transition(defendpenalty_seconds_trigger, main_play) self.playbook.set_play(main_play) diff --git a/entities/plays/larc2021/goalKickPlay.py b/entities/plays/larc2021/goalKickPlay.py index 4a09866d..ddf14ea0 100644 --- a/entities/plays/larc2021/goalKickPlay.py +++ b/entities/plays/larc2021/goalKickPlay.py @@ -32,9 +32,9 @@ def get_positions(self, foul, team_color, foul_color, quadrant): replacements.append( { "robot_id": 0, - "x": -field_size[0]/2 + 0.05, + "x": -field_size[0]/2 + 0.1, "y": 0.2, - "orientation": 45 + "orientation": 60 } ) else: diff --git a/main.py b/main.py index 42f78403..aa38465d 100644 --- a/main.py +++ b/main.py @@ -59,7 +59,7 @@ def update(self): } for r in commands ] self.comm.send(commands) - + if self.referee.get_foul() != "STOP" and self.referee.get_foul() != 7 and self.referee.get_foul() != None: if self.match.coach.get_positions( self.referee.get_foul(), self.match.team_color.upper(), self.referee.get_color(), self.referee.get_quadrant() ): self.referee.send_replacement(