Skip to content

Commit 056339b

Browse files
committed
added secondary state stuff to Behaviour
1 parent 574895f commit 056339b

5 files changed

Lines changed: 32 additions & 71 deletions

File tree

src/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/game_status_capsule.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ def __init__(self, node, blackboard=None):
2020
self.last_goal_time = -86400.0
2121
self.free_kick_kickoff_team: Optional[bool] = None
2222

23-
def get_gamestate(self) -> int:
24-
#Init, ready, set, playing, finished, standby
23+
def get_game_state(self) -> int:
24+
#Init, ready, set, playing, finished
2525
return self.gamestate.main_state
2626

27-
def get_gamePhase(self) -> int:
28-
#Timeout, Normal, Penaltyshoot
27+
def get_game_phase(self) -> int:
28+
#Timeout, Normal, Extratime, Penaltyshoot
2929
return self.gamestate.gamePhase
3030

31-
def get_setPlay(self) -> int:
32-
#None, Kick In, Goalkick, Cornerkick, Pushing Freekick, Penaltykick
31+
def get_set_play(self) -> int:
32+
#None, Direct Freekick, Indirect Freekick, Penalty, Throw in, Goalkick, Cornerkick,
3333
return self.gamestate.setPlay
3434

3535
def get_secondary_team(self) -> int:
@@ -39,6 +39,9 @@ def get_secondary_team(self) -> int:
3939
def has_kickoff(self) -> bool:
4040
#vegelcih mit eigener Teamnummer
4141
return self.gamestate.kickingTeam == self.team_id
42+
43+
def is_stopped(self) -> bool:
44+
return self.gamestate.stopped
4245

4346
def has_penalty_kick(self) -> bool:
4447
return(

src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/game_state_decider.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def perform(self, reevaluate=False):
1616
:return:
1717
"""
1818

19-
game_state_number = self.blackboard.gamestate.get_gamestate()
19+
game_state_number = self.blackboard.gamestate.get_game_state()
2020
# todo this is a temporary hack to make GUI work
2121
if game_state_number == GameState.STATE_INITIAL:
2222
return "INITIAL"
@@ -28,8 +28,6 @@ def perform(self, reevaluate=False):
2828
return "PLAYING"
2929
elif game_state_number == GameState.STATE_FINISHED:
3030
return "FINISHED"
31-
elif game_state_number == GameState.STATE_STANDBY:
32-
return "STANDBY"
3331

3432
def get_reevaluate(self):
3533
"""

src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/secondary_state_decider.py

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,28 @@ def __init__(self, blackboard, dsd, parameters):
1515
super().__init__(blackboard, dsd, parameters)
1616

1717
def perform(self, reevaluate=False):
18-
state_number = self.blackboard.gamestate.get_secondary_state()
18+
set_play_number = self.blackboard.gamestate.get_set_play()
19+
game_phase_number = self.blackboard.gamestate.get_game_phase
1920
# todo this is a temporary hack to make GUI work
20-
if state_number == GameState.STATE_NORMAL:
21+
if game_phase_number == GameState.GAME_PHASE_NORMAL and set_play_number == GameState.SET_PLAY_NONE:
2122
return "NORMAL"
22-
elif state_number == GameState.STATE_PENALTYSHOOT:
23+
elif game_phase_number == GameState.GAME_PHASE_PENALTY_SHOOT_OUT and set_play_number == GameState.SET_PLAY_NONE:
2324
return "PENALTYSHOOT"
24-
elif state_number == GameState.STATE_OVERTIME:
25+
elif game_phase_number == GameState.GAME_PHASE_EXTRA_TIME and set_play_number == GameState.SET_PLAY_NONE:
2526
return "OVERTIME"
26-
elif state_number == GameState.STATE_TIMEOUT:
27+
elif game_phase_number == GameState.GAME_PHASE_TIMEOUT and set_play_number == GameState.SET_PLAY_NONE:
2728
return "TIMEOUT"
28-
elif state_number == GameState.STATE_DIRECT_FREEKICK:
29+
elif set_play_number == GameState.SET_PLAY_DIRECT_FREE_KICK:
2930
return "DIRECT_FREEKICK"
30-
elif state_number == GameState.STATE_INDIRECT_FREEKICK:
31+
elif set_play_number == GameState.SET_PLAY_INDIRECT_FREE_KICK:
3132
return "INDIRECT_FREEKICK"
32-
elif state_number == GameState.STATE_PENALTYKICK:
33+
elif set_play_number == GameState.SET_PLAY_PENALTY_KICK:
3334
return "PENALTYKICK"
34-
elif state_number == GameState.STATE_CORNER_KICK:
35+
elif set_play_number == GameState.SET_PLAY_CORNER_KICK:
3536
return "CORNER_KICK"
36-
elif state_number == GameState.STATE_GOAL_KICK:
37+
elif set_play_number == GameState.SET_PLAY_GOAL_KICK:
3738
return "GOAL_KICK"
38-
elif state_number == GameState.STATE_THROW_IN:
39+
elif set_play_number == GameState.SET_PLAY_THROW_IN:
3940
return "THROW_IN"
4041

4142
def get_reevaluate(self):
@@ -57,9 +58,9 @@ def __init__(self, blackboard, dsd, parameters):
5758
self.team_id = self.blackboard.gamestate.get_team_id()
5859

5960
def perform(self, reevaluate=False):
60-
state_number = self.blackboard.gamestate.get_secondary_state()
61+
game_phase_number = self.blackboard.gamestate.get_game_phase()
6162
# we have to handle penalty shoot differently because the message is strange
62-
if state_number == GameState.STATE_PENALTYSHOOT:
63+
if game_phase_number == GameState.GAME_PHASE_PENALTY_SHOOT_OUT:
6364
if self.blackboard.gamestate.has_kickoff():
6465
return "OUR"
6566
return "OTHER"
@@ -73,26 +74,3 @@ def get_reevaluate(self):
7374
Secondary state Team can change during the game
7475
"""
7576
return True
76-
77-
78-
class SecondaryStateModeDecider(AbstractDecisionElement):
79-
"""
80-
Decides which mode in the secondary state we are.
81-
"""
82-
83-
blackboard: BodyBlackboard
84-
85-
def __init__(self, blackboard, dsd, parameters):
86-
super().__init__(blackboard, dsd, parameters)
87-
88-
def perform(self, reevaluate=False):
89-
state_mode = self.blackboard.gamestate.get_secondary_state_mode()
90-
if state_mode == GameState.MODE_PREPARATION:
91-
return "PREPARATION"
92-
elif state_mode == GameState.MODE_PLACING:
93-
return "PLACING"
94-
elif state_mode == GameState.MODE_END:
95-
return "END"
96-
97-
def get_reevaluate(self):
98-
return True

src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/main.dsd

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -104,31 +104,13 @@ $DoOnce
104104
OUR --> #SearchBall
105105
OTHER --> @AvoidBallActive, @LookAtFieldFeatures, @WalkInPlace + duration:2, @GoToRelativePosition + x:1 + y:0 + t:0, @Stand
106106
YES --> $SecondaryStateDecider
107-
CORNER_KICK --> $SecondaryStateTeamDecider
108-
OUR --> $RankToBallNoGoalie
109-
FIRST --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToCornerKickPosition + mode:striker
110-
SECOND --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToCornerKickPosition + mode:supporter
111-
THIRD --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition
112-
OTHER --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToCornerKickPosition + mode:others
113-
THROW_IN --> $SecondaryStateTeamDecider
114-
OUR --> $RankToBallNoGoalie
115-
FIRST --> $DoOnce
116-
NOT_DONE --> @ChangeAction + action:going_to_ball, @LookAtFieldFeatures, @AvoidBallActive, @GoToBall + target:gradient + distance:0.3 + blocking:false
117-
DONE --> $ReachedAndAlignedToPathPlanningGoalPosition + threshold:0.03 + latch:true
118-
NO --> @GoToBall + target:gradient + distance:0.3
119-
YES --> @LookForward, @ChangeAction + action:kicking, @Stand + duration:1.5 + r:false, @PlayAnimationDynup + direction:descend_no_arms, @PlayAnimationGrabBall + r:false, @PlayAnimationDynup + direction:rise_no_arms, @PlayAnimationThrow + r:false, @GetWalkready + r:false, @Stand
120-
SECOND --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToPassPreparePosition
121-
THIRD --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition
122-
OTHER --> $RankToBallNoGoalie
107+
CORNER_KICK --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToCornerKickPosition + mode:others
108+
THROW_IN --> $RankToBallNoGoalie
123109
FIRST --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition + mode:freekick_first
124110
SECOND --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition + mode:freekick_second
125111
THIRD --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition
126112
ELSE --> $SecondaryStateTeamDecider
127113
OUR --> $RankToBallNoGoalie
128-
FIRST --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToBall + target:gradient + distance:0.5
129-
SECOND --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToPassPreparePosition
130-
THIRD --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition
131-
OTHER --> $RankToBallNoGoalie
132114
FIRST --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition + mode:freekick_first
133115
SECOND --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition + mode:freekick_second
134116
THIRD --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition
@@ -181,9 +163,9 @@ $IsPenalized
181163
PLAYING --> $SecondaryStateDecider
182164
PENALTYSHOOT --> #PenaltyShootoutBehavior
183165
TIMEOUT --> #StandAndLook
184-
ELSE --> $SecondaryStateModeDecider
185-
ELSE --> #StandAndLook
186-
PLACING --> #Placing
166+
ELSE --> $SecondaryStateTeamDecider
167+
OWN --> #NormalBehavior //Nutzt immer normalBehaviour wenn wir die aktion ausführen, könnte man spezifischeres Verhalten definieren
168+
OTHER --> #Placing
187169
NORMAL --> #NormalBehavior
188170
OVERTIME --> #NormalBehavior
189171
STANDBY --> #StandAndLook

src/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/decisions/game_state.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def perform(self, reevaluate=False):
3232
:param reevaluate:
3333
:return:
3434
"""
35-
game_state_number = self.blackboard.gamestate.get_gamestate()
35+
game_state_number = self.blackboard.gamestate.get_game_state()
3636

3737
if game_state_number == GameState.GAMESTATE_INITIAL:
3838
return "INITIAL"
@@ -145,11 +145,11 @@ class InitialToReady(AbstractLocalizationDecisionElement):
145145

146146
def __init__(self, blackboard, dsd, parameters):
147147
super().__init__(blackboard, dsd, parameters)
148-
self.previous_game_state_number = self.blackboard.gamestate.get_gamestate()
148+
self.previous_game_state_number = self.blackboard.gamestate.get_game_state()
149149

150150
def perform(self, reevaluate=False):
151151
previous_game_state_number = self.previous_game_state_number
152-
game_state_number = self.blackboard.gamestate.get_gamestate()
152+
game_state_number = self.blackboard.gamestate.get_game_state()
153153
self.previous_game_state_number = game_state_number
154154

155155
self.publish_debug_data("Previous game state", previous_game_state_number)

0 commit comments

Comments
 (0)