CallEmptyService Class
Calls a std_srvs/Empty service and succeeds when it responds. 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
| CallEmptyService (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources) | |
| CallEmptyService (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< ClientInterfaceBase< Empty > > 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< Empty::Request, std::string > | createRequest () override |
|
Creates a service request message. More... | |
| tl::expected< bool, std::string > | processResponse (const Empty::Response &response) override |
|
Treats any response as success, since Empty::Response carries no fields. 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
Calls a std_srvs/Empty service and succeeds when it responds.
| 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 27 of file call_empty_service.hpp.
Public Constructors
CallEmptyService()
| explicit |
Declaration at line 30 of file call_empty_service.hpp, definition at line 25 of file call_empty_service.cpp.
CallEmptyService()
| explicit |
Declaration at line 33 of file call_empty_service.hpp, definition at line 31 of file call_empty_service.cpp.
Private Member Functions
createRequest()
| virtual |
Creates a service request message.
- Returns
Returns an instance of Empty::Request. Since the request message is empty, this always succeeds.
Declaration at line 51 of file call_empty_service.hpp, definition at line 91 of file call_empty_service.cpp.
getFuture()
| inline virtual |
Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member.
Definition at line 61 of file call_empty_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 44 of file call_empty_service.hpp, definition at line 65 of file call_empty_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 42 of file call_empty_service.hpp, definition at line 53 of file call_empty_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 45 of file call_empty_service.hpp, definition at line 78 of file call_empty_service.cpp.
processResponse()
|
Treats any response as success, since Empty::Response carries no fields.
- Parameters
-
response Response message received from the service server.
- Returns
Always true.
Declaration at line 58 of file call_empty_service.hpp, definition at line 97 of file call_empty_service.cpp.
Private Member Attributes
future_
|
Holds the result of calling the service asynchronously.
Definition at line 69 of file call_empty_service.hpp.
Public Static Functions
metadata()
| static |
Declaration at line 39 of file call_empty_service.hpp, definition at line 48 of file call_empty_service.cpp.
providedPorts()
| static |
Declaration at line 37 of file call_empty_service.hpp, definition at line 38 of file call_empty_service.cpp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.