Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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"]

Expand Down
8 changes: 8 additions & 0 deletions bitbots_misc/bitbots_utils/bitbots_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')}"
Expand Down
Loading