Skip to content

Commit 04457bf

Browse files
committed
update dsd for whistle detection and decision
1 parent 1a3eef4 commit 04457bf

4 files changed

Lines changed: 28 additions & 26 deletions

File tree

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ def gamestate_callback(self, gamestate_msg: GameState) -> None:
121121
self.last_update = self._node.get_clock().now().nanoseconds / 1e9
122122
self.gamestate = gamestate_msg
123123

124-
def whistle_detected(self) -> bool:
125-
return self.whistle_detected
126-
127-
128124
def whistle_detection_callback(self, msg) -> None: # MSG type is assumed to be bool for now, prototyping
129-
self.whistle_detected = msg.data
125+
self.whistle_detected = msg.data # This stays true after the first whistle detection which is incorrect
130126

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@ class WhistleDetected(AbstractDecisionElement):
77

88
def __init__(self, blackboard, dsd, parameters):
99
super().__init__(blackboard, dsd, parameters)
10+
self.bb = blackboard
11+
self.bb.game_state_capsule.whistle_detected = False
1012

1113
def perform(self, reevaluate=False):
12-
"""
13-
Determines whether we are confident regarding the ball's position.
14-
:param reevaluate:
15-
:return:
16-
"""
17-
if self.blackboard.world_model.ball_has_been_seen(): # TODO
14+
if self.bb.game_state_capsule.whistle_detected:
1815
return "YES"
1916
return "NO"
2017

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

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ $BallSeen
162162
SECOND --> #SupporterRole
163163
THIRD --> #DefensePositioning
164164

165+
#PlayingBehavior
166+
$SecondaryStateDecider
167+
PENALTYSHOOT --> #PenaltyShootoutBehavior
168+
TIMEOUT --> #StandAndLook
169+
ELSE --> $SecondaryStateModeDecider
170+
ELSE --> #StandAndLook
171+
PLACING --> #Placing
172+
NORMAL --> #NormalBehavior
173+
OVERTIME --> #NormalBehavior
174+
165175
-->BodyBehavior
166176
$IsPenalized
167177
YES --> #DoNothing
@@ -175,21 +185,18 @@ $IsPenalized
175185
NO --> $DoOnce
176186
NOT_DONE --> @ChangeAction + action:waiting + r:false, @LookAtFieldFeatures + r:false, @Stand + duration:2
177187
DONE --> #PositioningReady
178-
SET --> $SecondaryStateDecider
179-
PENALTYSHOOT --> $SecondaryStateTeamDecider
180-
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
181-
OTHER --> $BallSeen
182-
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
183-
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
184-
ELSE --> #StandAndLook
188+
SET --> $WhistleDetected
189+
YES --> #PlayingBehavior
190+
NO --> $SecondaryStateDecider
191+
PENALTYSHOOT --> $SecondaryStateTeamDecider
192+
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
193+
OTHER --> $BallSeen
194+
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
195+
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
196+
ELSE --> #StandAndLook
185197
FINISHED --> $CurrentScore
186198
AHEAD --> @Stand + duration:0.5 + r:false, @PlaySound + file:fanfare.wav, @PlayAnimationCheering + r:false, @GetWalkready + r:false, @LookForward, @Stand
187199
ELSE --> #Init
188-
PLAYING --> $SecondaryStateDecider
189-
PENALTYSHOOT --> #PenaltyShootoutBehavior
190-
TIMEOUT --> #StandAndLook
191-
ELSE --> $SecondaryStateModeDecider
192-
ELSE --> #StandAndLook
193-
PLACING --> #Placing
194-
NORMAL --> #NormalBehavior
195-
OVERTIME --> #NormalBehavior
200+
PLAYING --> #PlayingBehavior
201+
202+

src/bitbots_world_model/bitbots_whistle_detector/setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
packages=[package_name],
1313
data_files=[
1414
("share/" + package_name, ["package.xml"]),
15+
("share/" + package_name + "/launch", glob.glob("launch/*.launch")),
1516
],
1617
install_requires=[
1718
"launch",
1819
"setuptools",
1920
],
21+
2022
tests_require=["pytest"],
2123
zip_safe=True,
2224
keywords=["ROS"],

0 commit comments

Comments
 (0)