|
| Callable[[Blackboard], Any] | _create_request_handler = create_request_handler |
| | Function to create service requests.
|
| |
| Callable[[Blackboard, Any], str] | _response_handler = response_handler |
| | Function to handle service responses.
|
| |
| float | _wait_timeout = wait_timeout |
| | Maximum wait time for service availability.
|
| |
| float | _response_timeout = response_timeout |
| | Timeout for the service response.
|
| |
| Node | _node = node |
| | The ROS 2 node used to communicate with the service.
|
| |
| str | _srv_name = srv_name |
| | Name of the service.
|
| |
| Client | _service_client |
| | Shared pointer to the service client.
|
| |
| Any | _response = None |
| | The response received from the service.
|
| |
| int | _maximum_retry = maximum_retry |
| | Maximum number of retries.
|
| |
| Event | _response_received_event = Event() |
| | Event to signal when the service response is received.
|
| |
A state class that interacts with a ROS 2 service.
This class manages communication with a specified ROS 2 service,
allowing it to send requests and handle responses. It extends
the base State class.
Attributes:
_node (Node): The ROS 2 node used to communicate with the service.
_srv_name (str): The name of the service to call.
_service_client (Client): The client used to call the service.
_create_request_handler (Callable[[Blackboard], Any]): Function to create service requests.
_response (Any): The response received from the service.
_response_handler (Callable[[Blackboard, Any], str]): Function to handle service responses.
_wait_timeout (float): Maximum wait time for service availability.
_response_timeout (float): Timeout for the service response.
_maximum_retry (int): Maximum number of retries.
_response_received_event (Event): Event to signal when the service response is received.
| None yasmin_ros.service_state.ServiceState.__init__ |
( |
| self, |
|
|
Type | srv_type, |
|
|
str | srv_name, |
|
|
Callable | create_request_handler, |
|
|
Set[str] | outcomes = None, |
|
|
Callable | response_handler = None, |
|
|
CallbackGroup | callback_group = None, |
|
|
Node | node = None, |
|
|
float | wait_timeout = None, |
|
|
float | response_timeout = None, |
|
|
int | maximum_retry = 3 ) |
Initializes the ServiceState with the provided parameters.
Args:
srv_type (Type): The type of the service.
srv_name (str): The name of the service to call.
create_request_handler (Callable[[Blackboard], Any]): Function to create a service request.
outcomes (Set[str], optional): A set of possible outcomes for this state.
response_handler (Callable[[Blackboard, Any], str], optional): Function to handle the service response.
callback_group (CallbackGroup, optional): The callback group for the service client.
node (Node, optional): A ROS 2 node instance; if None, a default instance is used.
wait_timeout (float, optional): Maximum time to wait for the service to become available. Default is None (wait indefinitely).
response_timeout (float, optional): Maximum time to wait for the service response. Default is None (wait indefinitely).
maximum_retry (int, optional): Maximum retries of the service if it returns timeout. Default is 3.
Raises:
ValueError: If the create_request_handler is not provided.
| str yasmin_ros.service_state.ServiceState.execute |
( |
| self, |
|
|
Blackboard | blackboard ) |
Execute the service call and handle the response.
This method creates a request based on the blackboard data, waits for the
service to become available, sends the request asynchronously, and waits for
the response using a threading Event.
Args:
blackboard (Blackboard): A shared pointer to the blackboard containing data for
request creation.
Returns:
str: The outcome of the service call, which can be SUCCEED, ABORT, or TIMEOUT.