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::State
class.- 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, std::set<std::string> outcomes, int timeout = -1.0)
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.
timeout – Maximum time to wait for the service to become available, in seconds. Default is -1 (wait indefinitely).
-
inline ServiceState(std::string srv_name, CreateRequestHandler create_request_handler, std::set<std::string> outcomes, ResponseHandler response_handler, int timeout = -1.0)
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 – Function to handle the service response.
timeout – Maximum time to wait for the service to become available, in seconds. Default is -1 (wait indefinitely).
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 – Function to handle the service response.
timeout – Maximum time to wait for the service to become available, in seconds. Default is -1 (wait indefinitely).
- 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.