From 0796ae2a33cdb774fb0617e433c4d0afc310949d Mon Sep 17 00:00:00 2001 From: texhnolyze Date: Sat, 14 Mar 2026 13:03:06 +0100 Subject: [PATCH] fix(behavior): do not go to ball when opponent has kickoff --- .../decisions/secondary_state_decider.py | 7 +++++++ .../bitbots_body_behavior/behavior_dsd/main.dsd | 16 +++++++++------- .../launch/simulator_teamplayer.launch | 2 +- .../localization_dsd/decisions/game_state.py | 8 ++++++++ .../localization_dsd/localization.dsd | 2 +- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/secondary_state_decider.py b/src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/secondary_state_decider.py index 62e170fe3..adecbc4aa 100644 --- a/src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/secondary_state_decider.py +++ b/src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/decisions/secondary_state_decider.py @@ -73,6 +73,13 @@ def perform(self, reevaluate=False): else: if self.blackboard.gamestate.get_secondary_team() == self.team_id: return "OUR" + # @TODO: handle this better and potentially adapt KickOffTimeUp + elif ( + self.blackboard.gamestate.get_secondary_team() == 255 + or self.blackboard.gamestate.get_secondary_team() == 0 + ): + return "NONE" + return "OTHER" def get_reevaluate(self): diff --git a/src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/main.dsd b/src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/main.dsd index 60f838420..24e988bdb 100644 --- a/src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/main.dsd +++ b/src/bitbots_behavior/bitbots_body_behavior/bitbots_body_behavior/behavior_dsd/main.dsd @@ -53,7 +53,7 @@ $AvoidBall $GoalScoreRecently YES --> $ConfigRole GOALIE --> $RobotInOwnPercentOfField + p:40 - YES -->@Stand + duration:1.0 + r:false, @PlayAnimationCheering + r:false, @GetWalkready + r:false + YES --> @Stand + duration:1.0 + r:false, @PlayAnimationCheering + r:false, @GetWalkready + r:false NO --> @ChangeAction + action:positioning, @PlaySound + file:ole.wav, @LookAtFieldFeatures, @Stand + duration:%ready_wait_time, @AvoidBallActive, @GoToRolePosition ELSE --> @ChangeAction + action:positioning, @PlaySound + file:ole.wav, @LookAtFieldFeatures, @Stand + duration:%ready_wait_time, @AvoidBallActive, @GoToRolePosition NO --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @Stand + duration:%ready_wait_time, @AvoidBallActive, @GoToRolePosition @@ -85,7 +85,7 @@ $PassStarted #PenaltyShootoutBehavior $SecondaryStateTeamDecider OUR --> @StandAndWaitRandom + min:10 + max:30, @KickBallDynamic + r:true + type:penalty, @Stand - OTHER --> $BallDangerous + radius:1.3 + ELSE --> $BallDangerous + radius:1.3 LEFT --> @PlayAnimationGoalieFallLeft, @Stand RIGHT --> @PlayAnimationGoalieFallRight, @Stand CENTER --> @PlayAnimationGoalieFallCenter, @Stand @@ -93,7 +93,6 @@ $SecondaryStateTeamDecider YES --> @TrackBall, @Stand NO --> @LookAtFieldFeatures, @Stand - #Placing $DoOnce NOT_DONE --> @ForgetBall, @LookAtFieldFeatures @@ -102,7 +101,7 @@ $DoOnce ELSE --> $BallSeen NO --> $SecondaryStateTeamDecider OUR --> #SearchBall - OTHER --> @AvoidBallActive, @LookAtFieldFeatures, @WalkInPlace + duration:2, @GoToRelativePosition + x:1 + y:0 + t:0, @Stand + ELSE --> @AvoidBallActive, @LookAtFieldFeatures, @WalkInPlace + duration:2, @GoToRelativePosition + x:1 + y:0 + t:0, @Stand YES --> $RankToBallNoGoalie FIRST --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition + mode:freekick_first SECOND --> @ChangeAction + action:positioning, @LookAtFieldFeatures, @AvoidBallActive, @GoToDefensePosition + mode:freekick_second @@ -136,7 +135,7 @@ $SecondaryStateDecider TIMEOUT --> #StandAndLook ELSE --> $SecondaryStateTeamDecider OUR --> #NormalBehavior - OTHER --> #Placing + ELSE --> #Placing NORMAL --> #NormalBehavior OVERTIME --> #NormalBehavior @@ -154,11 +153,14 @@ $IsPenalized NOT_DONE --> @ChangeAction + action:waiting + r:false, @LookAtFieldFeatures + r:false, @Stand + duration:2 DONE --> #PositioningReady SET --> $WhistleDetected - DETECTED --> #PlayingBehavior + DETECTED --> $SecondaryStateTeamDecider + OUR --> #PlayingBehavior + OTHER --> #StandAndLook + ELSE --> #PlayingBehavior NOT_DETECTED --> $SecondaryStateDecider PENALTYSHOOT --> $SecondaryStateTeamDecider OUR --> @Stand + duration:0.1 + r:false, @DeactivateHCM + r:false, @LookForward + r:false, @PlayAnimationInitInSim + r:false, @GetWalkready + r:false, @Stand // we need to also see the goalie - OTHER --> $BallSeen + ELSE --> $BallSeen YES --> @Stand + duration:0.1 + r:false, @DeactivateHCM + r:false, @LookForward + r:false, @PlayAnimationInitInSim + r:false, @GetWalkready + r:false, @TrackBall + r:false, @PlayAnimationGoalieArms + r:false, @Stand // goalie only needs to care about the ball NO --> @Stand + duration:0.1 + r:false, @DeactivateHCM + r:false, @LookForward + r:false, @PlayAnimationInitInSim + r:false, @GetWalkready + r:false, @LookAtFieldFeatures + r:false, @PlayAnimationGoalieArms + r:false, @Stand ELSE --> #StandAndLook diff --git a/src/bitbots_misc/bitbots_bringup/launch/simulator_teamplayer.launch b/src/bitbots_misc/bitbots_bringup/launch/simulator_teamplayer.launch index 83d8292d3..a21f62553 100644 --- a/src/bitbots_misc/bitbots_bringup/launch/simulator_teamplayer.launch +++ b/src/bitbots_misc/bitbots_bringup/launch/simulator_teamplayer.launch @@ -1,6 +1,6 @@ - + diff --git a/src/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/decisions/game_state.py b/src/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/decisions/game_state.py index ae2eba984..c93236e9a 100644 --- a/src/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/decisions/game_state.py +++ b/src/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/decisions/game_state.py @@ -118,10 +118,18 @@ def perform(self, reevaluate=False): if game_phase_number == GameState.GAME_PHASE_PENALTY_SHOOT_OUT: if self.blackboard.gamestate.has_kickoff(): return "OUR" + return "OTHER" else: if self.blackboard.gamestate.get_secondary_team() == self.team_id: return "OUR" + # @TODO: handle this better and potentially adapt KickOffTimeUp + elif ( + self.blackboard.gamestate.get_secondary_team() == 255 + or self.blackboard.gamestate.get_secondary_team() == 0 + ): + return "NONE" + return "OTHER" def get_reevaluate(self): diff --git a/src/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/localization.dsd b/src/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/localization.dsd index bc6584f7a..0a57d1e43 100644 --- a/src/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/localization.dsd +++ b/src/bitbots_navigation/bitbots_localization_handler/bitbots_localization_handler/localization_dsd/localization.dsd @@ -1,8 +1,8 @@ #InitSet $SecondaryStateDecider PENALTYSHOOT --> $SecondaryStateTeamDecider - OTHER --> @InitGoal, @DoNothing // Init as kicker OUR --> @InitPenaltyKick, @DoNothing // Init as goalie + ELSE --> @InitGoal, @DoNothing // Init as kicker ELSE --> $CheckPickup UP --> @WaitForPickupEnd + r:false, @InitSide, @DoNothing ELSE --> @DoNothing