From b6ca74ea52acf13d4d8feda6f080a0c5f2a49279 Mon Sep 17 00:00:00 2001 From: Florian Vahl <7vahl@informatik.uni-hamburg.de> Date: Tue, 16 Jan 2024 16:27:48 +0100 Subject: [PATCH] Fix sim gamestate script --- game_controller_hl/scripts/sim_gamestate.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/game_controller_hl/scripts/sim_gamestate.py b/game_controller_hl/scripts/sim_gamestate.py index dbaf9cc..66a597a 100755 --- a/game_controller_hl/scripts/sim_gamestate.py +++ b/game_controller_hl/scripts/sim_gamestate.py @@ -13,8 +13,9 @@ import rclpy from rclpy.node import Node from rclpy.qos import QoSProfile, DurabilityPolicy -from bitbots_msgs.msg import GameState as GameStateMsg -from bitbots_utils.utils import get_parameters_from_other_node + +from game_controller_hl_interfaces.msg import GameState +from game_controller_hl.utils import get_parameters_from_other_node class SimGamestate(Node): @@ -57,19 +58,25 @@ def __init__(self): super().__init__("sim_gamestate") self.logger = self.get_logger() - self.team_id = get_parameters_from_other_node(self, "parameter_blackboard", ["team_id"])["team_id"] + # Try fetching team id from parameter blackboard or ask user for input + try: + self.team_id = get_parameters_from_other_node(self, "parameter_blackboard", ["team_id"])["team_id"] + except KeyError: + self.logger.error("No team id found in parameter blackboard") + self.team_id = int(input("Please enter team id: ")) + self.has_kick_off = True self.settings = termios.tcgetattr(sys.stdin) self.publisher = self.create_publisher( - GameStateMsg, + GameState, "gamestate", QoSProfile(durability=DurabilityPolicy.TRANSIENT_LOCAL, depth=1), ) def loop(self): - game_state_msg = GameStateMsg() + game_state_msg = GameState() game_state_msg.header.stamp = self.get_clock().now().to_msg() # Init secondary state team to our teamID