diff --git a/bdai_ros2_wrappers/bdai_ros2_wrappers/action_client.py b/bdai_ros2_wrappers/bdai_ros2_wrappers/action_client.py index 68b6d41..4b1f292 100644 --- a/bdai_ros2_wrappers/bdai_ros2_wrappers/action_client.py +++ b/bdai_ros2_wrappers/bdai_ros2_wrappers/action_client.py @@ -12,22 +12,30 @@ class ActionClientWrapper(rclpy.action.ActionClient): """A wrapper for ros2's ActionClient for extra functionality""" - def __init__(self, action_type: Type[Action], action_name: str, node: Optional[Node] = None) -> None: + def __init__( + self, + action_type: Type[Action], + action_name: str, + node: Optional[Node] = None, + wait_for_server: bool = True, + ) -> None: """Constructor Args: action_type (Type[Action]): The type of the action action_name (str): The name of the action (for logging purposes) node (Optional[Node]): optional node for action client, defaults to the current process node + wait_for_server (bool): Whether to wait for the server """ node = node or scope.node() if node is None: raise ValueError("no ROS 2 node available (did you use bdai_ros2_wrapper.process.main?)") self._node = node super().__init__(self._node, action_type, action_name) - self._node.get_logger().info(f"Waiting for action server for {action_name}") - self.wait_for_server() - self._node.get_logger().info("Found server") + if wait_for_server: + self._node.get_logger().info(f"Waiting for action server for {action_name}") + self.wait_for_server() + self._node.get_logger().info("Found server") def send_goal_and_wait( self,