CallTriggerService Class
Call a service that accepts a std_srvs/srv/Trigger message. The name of the service is set through the "service_name" parameter. More...
Declaration
Included Headers
Base class
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
Public Constructors Index
| CallTriggerService (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources) | |
| CallTriggerService (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< ClientInterfaceBase< Trigger > > client_interface) | |
Private Member Functions Index
| tl::expected< std::string, std::string > | getServiceName () override |
|
User-provided function to get the name of the service when initializing the service client. More... | |
| tl::expected< std::chrono::duration< double >, std::string > | getResponseTimeout () override |
|
Optional user-provided function to set the timeout used when waiting for the service response. More... | |
| tl::expected< std::chrono::duration< double >, std::string > | getWaitForServerAvailableTimeout () override |
|
Optional user-provided function to set the timeout used when waiting for the service server to be available. More... | |
| tl::expected< Trigger::Request, std::string > | createRequest () override |
|
Creates a service request message. More... | |
| tl::expected< bool, std::string > | processResponse (const Trigger::Response &response) override |
|
Determines if the service request succeeded or failed based on the contents of the response message's success field. More... | |
| std::shared_future< tl::expected< bool, std::string > > & | getFuture () override |
|
Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member. More... | |
Private Member Attributes Index
| std::shared_future< tl::expected< bool, std::string > > | future_ |
|
Holds the result of calling the service asynchronously. More... | |
Public Static Functions Index
| static BT::PortsList | providedPorts () |
| static BT::KeyValueVector | metadata () |
Description
Call a service that accepts a std_srvs/srv/Trigger message. The name of the service is set through the "service_name" parameter.
| Data Port Name | Port Type | Object Type |
|---|---|---|
| service_name | input | std::string |
| response_timeout | input | double |
| wait_for_server_available_timeout | input | double |
Definition at line 28 of file call_trigger_service.hpp.
Public Constructors
CallTriggerService()
| explicit |
Declaration at line 31 of file call_trigger_service.hpp, definition at line 35 of file call_trigger_service.cpp.
CallTriggerService()
| explicit |
Declaration at line 34 of file call_trigger_service.hpp, definition at line 41 of file call_trigger_service.cpp.
Private Member Functions
createRequest()
| virtual |
Creates a service request message.
- Returns
Returns an instance of Trigger::Request. Since the request message is empty, this always succeeds.
Declaration at line 52 of file call_trigger_service.hpp, definition at line 101 of file call_trigger_service.cpp.
getFuture()
| inline virtual |
Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member.
Definition at line 62 of file call_trigger_service.hpp.
getResponseTimeout()
| virtual |
Optional user-provided function to set the timeout used when waiting for the service response.
If no user-defined implementation is provided, the default implementation returns a negative duration, which will cause the service client to wait for the response without timing out.
- Returns
Returns the service response timeout duration. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Declaration at line 45 of file call_trigger_service.hpp, definition at line 75 of file call_trigger_service.cpp.
getServiceName()
| virtual |
User-provided function to get the name of the service when initializing the service client.
- Returns
Returns the name of the service. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Declaration at line 43 of file call_trigger_service.hpp, definition at line 63 of file call_trigger_service.cpp.
getWaitForServerAvailableTimeout()
| virtual |
Optional user-provided function to set the timeout used when waiting for the service server to be available.
If no user-defined implementation is provided, the default implementation returns 3.0 seconds, which will be the timeout duration for waiting for the service server to become available.
- Returns
Returns the service server wait timeout duration. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Declaration at line 46 of file call_trigger_service.hpp, definition at line 88 of file call_trigger_service.cpp.
processResponse()
|
Determines if the service request succeeded or failed based on the contents of the response message's success field.
- Parameters
-
response Response message received from the service server.
- Returns
The return value matches the value of response.success.
Declaration at line 59 of file call_trigger_service.hpp, definition at line 107 of file call_trigger_service.cpp.
Private Member Attributes
future_
|
Holds the result of calling the service asynchronously.
Definition at line 70 of file call_trigger_service.hpp.
Public Static Functions
metadata()
| static |
Declaration at line 40 of file call_trigger_service.hpp, definition at line 58 of file call_trigger_service.cpp.
providedPorts()
| static |
Declaration at line 38 of file call_trigger_service.hpp, definition at line 48 of file call_trigger_service.cpp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.