Skip to main content

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

class moveit_pro::behaviors::CallTriggerService { ... }

Included Headers

#include <call_trigger_service.hpp>

Base class

classServiceClientBehaviorBase<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::PortsListprovidedPorts ()
static BT::KeyValueVectormetadata ()

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 NamePort TypeObject Type
service_nameinputstd::string
response_timeoutinputdouble
wait_for_server_available_timeoutinputdouble

Definition at line 28 of file call_trigger_service.hpp.

Public Constructors

CallTriggerService()

moveit_pro::behaviors::CallTriggerService::CallTriggerService (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources)
explicit

Declaration at line 31 of file call_trigger_service.hpp, definition at line 35 of file call_trigger_service.cpp.

CallTriggerService()

moveit_pro::behaviors::CallTriggerService::CallTriggerService (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources, std::unique_ptr< ClientInterfaceBase< Trigger > > client_interface)
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()

tl::expected< Trigger::Request, std::string > moveit_pro::behaviors::CallTriggerService::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()

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::CallTriggerService::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()

tl::expected< std::chrono::duration< double >, std::string > moveit_pro::behaviors::CallTriggerService::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()

tl::expected< std::string, std::string > moveit_pro::behaviors::CallTriggerService::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()

tl::expected< std::chrono::duration< double >, std::string > moveit_pro::behaviors::CallTriggerService::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()

tl::expected< bool, std::string > moveit_pro::behaviors::CallTriggerService::processResponse (const Trigger::Response & response)

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_

std::shared_future<tl::expected<bool, std::string> > moveit_pro::behaviors::CallTriggerService::future_

Holds the result of calling the service asynchronously.

Definition at line 70 of file call_trigger_service.hpp.

Public Static Functions

metadata()

BT::KeyValueVector moveit_pro::behaviors::CallTriggerService::metadata ()
static

Declaration at line 40 of file call_trigger_service.hpp, definition at line 58 of file call_trigger_service.cpp.

providedPorts()

BT::PortsList moveit_pro::behaviors::CallTriggerService::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.