Skip to content

Commit

Permalink
Added flag to not wait for action server (#68)
Browse files Browse the repository at this point in the history
I know this will soon be replaced with Actionables, but until that happens I would like the ability to not wait for the server as its needed to add some unit tests in the main repo.
  • Loading branch information
amessing-bdai authored Feb 8, 2024
1 parent 7899a0f commit d61832f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions bdai_ros2_wrappers/bdai_ros2_wrappers/action_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d61832f

Please sign in to comment.