11from typing import Optional
22
33from bitbots_utils .utils import get_parameters_from_other_node
4- from game_controller_hl_interfaces .msg import GameState
4+ from game_controller_hsl_interfaces .msg import GameState
55from std_msgs .msg import Bool
66
77from bitbots_blackboard .capsules import AbstractBlackboardCapsule
@@ -21,42 +21,37 @@ def __init__(self, node, blackboard=None):
2121 self .last_goal_from_us_time = - 86400.0
2222 self .last_goal_time = - 86400.0
2323 self .free_kick_kickoff_team : Optional [bool ] = None
24- self .game_controller_stop : Bool = False
25- #publish stopped msg for hcm
26- self .stop_pub = self . node .create_publisher (Bool , "game_controller/stop_msg" , 1 )
24+ self .game_controller_stop : bool = False
25+ # publish stopped msg for hcm
26+ self .stop_pub = node .create_publisher (Bool , "game_controller/stop_msg" , 1 )
2727
2828 def get_game_state (self ) -> int :
29- #Init, ready, set, playing, finished
29+ # Init, ready, set, playing, finished
3030 return self .gamestate .main_state
3131
3232 def get_game_phase (self ) -> int :
33- #Timeout, Normal, Extratime, Penaltyshoot
34- return self .gamestate .gamePhase
33+ # Timeout, Normal, Extratime, Penaltyshoot
34+ return self .gamestate .game_phase
3535
3636 def get_set_play (self ) -> int :
37- #None, Direct Freekick, Indirect Freekick, Penalty, Throw in, Goalkick, Cornerkick,
38- return self .gamestate .setPlay
37+ # None, Direct Freekick, Indirect Freekick, Penalty, Throw in, Goalkick, Cornerkick,
38+ return self .gamestate .set_play
3939
4040 def get_secondary_team (self ) -> int :
41- #Team ID, wer in set Play den Baall hat
42- return self .gamestate .kickingTeam
43- #Team ID, wer in set Play den Baall hat
44- return self .gamestate .kickingTeam
41+ # Team ID, wer in set Play den Ball hat
42+ return self .gamestate .kicking_team
4543
4644 def has_kickoff (self ) -> bool :
47- #vegelcih mit eigener Teamnummer
48- return self .gamestate .kickingTeam == self .team_id
49-
45+ # vegelcih mit eigener Teamnummer
46+ return self .gamestate .kicking_team == self .team_id
47+
5048 def is_stopped (self ) -> bool :
5149 return self .gamestate .stopped
5250
5351 def has_penalty_kick (self ) -> bool :
54- return (
55- self .gamestate .set_play == GameState .SET_PLAY_PENALTY_KICK
56- and self .gamestate .kickingTeam == self .team_id )
57- return (
58- self .gamestate .set_play == GameState .SET_PLAY_PENALTY_KICK
59- and self .gamestate .kickingTeam == self .team_id )
52+ return (
53+ self .gamestate .set_play == GameState .SET_PLAY_PENALTY_KICK and self .gamestate .kicking_team == self .team_id
54+ )
6055
6156 def get_our_goals (self ) -> int :
6257 return self .gamestate .own_score
@@ -80,14 +75,12 @@ def get_secondary_seconds_remaining(self) -> float:
8075 """Seconds remaining for things like kickoff"""
8176 # Time from the message minus time passed since receiving it
8277 return max (
83- self .gamestate .secondary_time
84- - (self ._node .get_clock ().now ().nanoseconds / 1e9 - self .last_update ),
78+ self .gamestate .secondary_time - (self ._node .get_clock ().now ().nanoseconds / 1e9 - self .last_update ),
8579 0.0 ,
8680 )
8781
8882 def get_seconds_since_unpenalized (self ) -> float :
89- return self ._node .get_clock ().now ().nanoseconds / 1e9 - self .seconds_till_unpenalized
90- return self ._node .get_clock ().now ().nanoseconds / 1e9 - self .seconds_till_unpenalized
83+ return self ._node .get_clock ().now ().nanoseconds / 1e9 - self .unpenalized_time
9184
9285 def get_is_penalized (self ) -> bool :
9386 return self .gamestate .penalized
@@ -111,9 +104,9 @@ def gamestate_callback(self, gamestate_msg: GameState) -> None:
111104
112105 self .game_controller_stop = gamestate_msg .stopped
113106
114- self .stop_pub .publish (self .game_controller_stop )
107+ self .stop_pub .publish (Bool ( data = self .game_controller_stop ) )
115108
116- ''' Anstoß im Falle von Overtime jetzt erstmal nicht genauer geregelt
109+ """ Anstoß im Falle von Overtime jetzt erstmal nicht genauer geregelt
117110 if (
118111 gamestate_msg.main_state == GameState.STATE_SET
119112 and self.gamestate.setPlay != 2
@@ -125,20 +118,20 @@ def gamestate_callback(self, gamestate_msg: GameState) -> None:
125118 # secondary action is now executed but we will not see this in the new messages.
126119 # it will look like a normal kick off, but we need to remember that this is some sort of free kick
127120 # we set the kickoff value accordingly, then we will not be allowed to move if it is a kick for the others
128- self.free_kick_kickoff_team = gamestate_msg.kickingTeam
129-
130-
131- if gamestate_msg.setPlay != 2 and gamestate_msg.secondaryTime == 0:
132- self.free_kick_kickoff_team = gamestate_msg.kickingTeam
133-
134-
135- if gamestate_msg.setPlay != 2 and gamestate_msg.secondaryTime == 0:
121+ self.free_kick_kickoff_team = gamestate_msg.kicking_team
122+
123+
124+ if gamestate_msg.set_play != 2 and gamestate_msg.secondary_time == 0:
125+ self.free_kick_kickoff_team = gamestate_msg.kicking_team
126+
127+
128+ if gamestate_msg.set_play != 2 and gamestate_msg.secondary_time == 0:
136129 self.free_kick_kickoff_team = None
137-
138-
130+
131+
139132
140133 if self.free_kick_kickoff_team is not None:
141134 gamestate_msg.has_kick_off = self.free_kick_kickoff_team == self.team_id
142- '''
135+ """
143136 self .last_update = self ._node .get_clock ().now ().nanoseconds / 1e9
144137 self .gamestate = gamestate_msg
0 commit comments