diff --git a/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/misc_capsule.py b/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/misc_capsule.py index 51f7eb197..ae3228a03 100644 --- a/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/misc_capsule.py +++ b/bitbots_behavior/bitbots_blackboard/bitbots_blackboard/capsules/misc_capsule.py @@ -1,6 +1,6 @@ from typing import Literal, Optional, TypeAlias -from bitbots_utils.utils import get_parameters_from_other_node +from bitbots_utils.utils import RobotNotConfiguredError, get_parameters_from_other_node from rclpy.duration import Duration from std_msgs.msg import Bool @@ -30,6 +30,14 @@ def __init__(self, node, blackboard): self._node, "parameter_blackboard", ["bot_id", "position_number"] ) + if any(param_val is None for param_val in gamestate_settings.values()): + error_text = """ +The robot is not configured properly or the parameter_blackboard is not found. +It is likely that the robot was not configured when you syncronised your clean code onto the robot. +Run the deploy_robots script with the -c option to configure the robot and set parameters like the robot id and its role.""" + self._node.get_logger().fatal(error_text) + raise RobotNotConfiguredError(error_text) + self.position_number: int = gamestate_settings["position_number"] self.bot_id: int = gamestate_settings["bot_id"] diff --git a/bitbots_misc/bitbots_utils/bitbots_utils/utils.py b/bitbots_misc/bitbots_utils/bitbots_utils/utils.py index 693a92ad0..1c3e89c57 100644 --- a/bitbots_misc/bitbots_utils/bitbots_utils/utils.py +++ b/bitbots_misc/bitbots_utils/bitbots_utils/utils.py @@ -16,6 +16,14 @@ nobeartype = beartype(conf=BeartypeConf(strategy=BeartypeStrategy.O0)) +class RobotNotConfiguredError(Exception): + """Exception raised when the robot is not configured properly.""" + + def __init__(self, message): + self.message = message + super().__init__(message) + + def read_urdf(robot_name: str) -> str: urdf = os.popen( f"xacro {get_package_share_directory(f'{robot_name}_description')}"