Template Class ServiceState
- Defined in File service_state.hpp 
Inheritance Relationships
Base Type
- public yasmin::State
Class Documentation
- 
template<typename ServiceT>
 class ServiceState : public yasmin::State
- 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 - yasmin::Stateclass.- Template Parameters:
- ServiceT – The type of the ROS 2 service this state interacts with. 
 - Public Functions - 
inline ServiceState(std::string srv_name, CreateRequestHandler create_request_handler, int wait_timeout = -1, int response_timeout = -1, int maximum_retry = 3)
- Construct a ServiceState with a request handler and outcomes. - Parameters:
- srv_name – The name of the service to call. 
- create_request_handler – Function to create a service request. 
- wait_timeout – Maximum time to wait for the service to become available, in seconds. Default is -1 (wait indefinitely). 
- response_timeout – Maximum time to wait for the service response, in seconds. Default is -1 (wait indefinitely). 
- maximum_retry – (Optional) Maximum retries of the service if it returns timeout. Default is 3. 
 
 
 - 
inline ServiceState(std::string srv_name, CreateRequestHandler create_request_handler, std::set<std::string> outcomes, int wait_timeout = -1, int response_timeout = -1, int maximum_retry = 3)
- Construct a ServiceState with a request handler and outcomes. - Parameters:
- srv_name – The name of the service to call. 
- create_request_handler – Function to create a service request. 
- outcomes – A set of possible outcomes for this state. 
- wait_timeout – Maximum time to wait for the service to become available, in seconds. Default is -1 (wait indefinitely). 
- response_timeout – Maximum time to wait for the service response, in seconds. Default is -1 (wait indefinitely). 
- maximum_retry – (Optional) Maximum retries of the service if it returns timeout. Default is 3. 
 
 
 - Construct a ServiceState with a request handler and outcomes. - Parameters:
- srv_name – The name of the service to call. 
- create_request_handler – Function to create a service request. 
- outcomes – A set of possible outcomes for this state. 
- callback_group – (Optional) The callback group for the subscription. 
- wait_timeout – Maximum time to wait for the service to become available, in seconds. Default is -1 (wait indefinitely). 
- response_timeout – Maximum time to wait for the service response, in seconds. Default is -1 (wait indefinitely). 
- maximum_retry – (Optional) Maximum retries of the service if it returns timeout. Default is 3. 
 
 
 - 
inline ServiceState(std::string srv_name, CreateRequestHandler create_request_handler, std::set<std::string> outcomes, ResponseHandler response_handler, int wait_timeout = -1, int response_timeout = -1, int maximum_retry = 3)
- Construct a ServiceState with a request handler and response handler. - Parameters:
- srv_name – The name of the service to call. 
- create_request_handler – Function to create a service request. 
- outcomes – A set of possible outcomes for this state. 
- response_handler – (Optional) Function to handle the service response. 
- wait_timeout – Maximum time to wait for the service to become available, in seconds. Default is -1 (wait indefinitely). 
- response_timeout – Maximum time to wait for the service response, in seconds. Default is -1 (wait indefinitely). 
- maximum_retry – (Optional) Maximum retries of the service if it returns timeout. Default is 3. 
 
 
 - Construct a ServiceState with a ROS 2 node and handlers. - Parameters:
- node – A shared pointer to the ROS 2 node. 
- srv_name – The name of the service to call. 
- create_request_handler – Function to create a service request. 
- outcomes – A set of possible outcomes for this state. 
- response_handler – (Optional) Function to handle the service response. 
- callback_group – (Optional) The callback group for the subscription. 
- wait_timeout – Maximum time to wait for the service to become available, in seconds. Default is -1 (wait indefinitely). 
- response_timeout – Maximum time to wait for the service response, in seconds. Default is -1 (wait indefinitely). 
- maximum_retry – (Optional) Maximum retries of the service if it returns timeout. Default is 3. 
 
- Throws:
- std::invalid_argument – if the create_request_handler is nullptr. 
 
 - Execute the service call and handle the response. - This function creates a request based on the blackboard data, waits for the service to become available, sends the request, and processes the response. - Parameters:
- blackboard – A shared pointer to the blackboard containing data for request creation. 
- Returns:
- std::string The outcome of the service call, which can be SUCCEED, ABORT, or TIMEOUT. 
 
 - Protected Attributes - 
rclcpp::Node::SharedPtr node_
- Shared pointer to the ROS 2 node.