Skip to main content

RclcppClientInterface Class Template

Implements ClientInterfaceBase for the rclcpp service client. More...

Declaration

template <typename ServiceT>
class moveit_pro::behaviors::RclcppClientInterface<ServiceT> { ... }

Included Headers

#include <service_client_interface.hpp>

Base class

classClientInterfaceBase<ServiceT>

Provides an interface to a service client that can send a single request at a time. WARNING - This class currently does not support calling syncSendRequest function asynchronously from multiple threads. More...

Public Constructors Index

template <typename ServiceT>
RclcppClientInterface (const std::shared_ptr< BehaviorContext > &behavior_context)

Constructor for this implementation. More...

Public Member Functions Index

template <typename ServiceT>
voidinitialize (const std::string &service_name, std::chrono::duration< double > wait_for_server_timeout, std::chrono::duration< double > result_timeout) override

Implementation of ClientInterfaceBase::initialize for an rclcpp service client. More...

template <typename ServiceT>
boolwaitForServiceServer () const override

Implementation of ClientInterfaceBase::waitForServiceServer for an rclcpp service client. More...

template <typename ServiceT>
auto syncSendRequest (const typename ServiceT::Request &request) override -> tl::expected< typename ServiceT::Response, std::string >

Implementation of ClientInterfaceBase::syncGetResult for an rclcpp service client. More...

template <typename ServiceT>
voidcancelRequest () override

Implementation of ClientInterfaceBase::cancelRequest for an rclcpp service client. More...

Private Member Attributes Index

template <typename ServiceT>
std::shared_ptr< rclcpp::Node >node_

Node to use when initializing the service client. More...

template <typename ServiceT>
std::shared_ptr< rclcpp::CallbackGroup >reentrant_callback_group_

Reentrant callback group used by the service client. More...

template <typename ServiceT>
std::shared_ptr< rclcpp::Client< ServiceT > >client_

Service client. More...

template <typename ServiceT>
std::chrono::duration< double >wait_for_server_timeout_

Duration to wait for the service server to be available before failing. More...

template <typename ServiceT>
std::chrono::duration< double >result_timeout_

Duration to wait for a result before failing. More...

template <typename ServiceT>
std::atomic_boolrequest_canceled_ { false }

Notifies the request waiting loop to exit early. More...

Public Static Attributes Index

template <typename ServiceT>
static constexpr std::chrono::millisecondskResponseBusyWaitPeriod { 100 }

Description

Implements ClientInterfaceBase for the rclcpp service client.

Definition at line 60 of file service_client_interface.hpp.

Public Constructors

RclcppClientInterface()

template <typename ServiceT>
moveit_pro::behaviors::RclcppClientInterface< ServiceT >::RclcppClientInterface (const std::shared_ptr< BehaviorContext > & behavior_context)
explicit

Constructor for this implementation.

Parameters
behavior_context

A shared_ptr to an instance of BehaviorContext. When this behavior is created using

Declaration at line 67 of file service_client_interface.hpp, definition at line 17 of file service_client_interface_impl.hpp.

Public Member Functions

cancelRequest()

template <typename ServiceT>
void moveit_pro::behaviors::RclcppClientInterface< ServiceT >::cancelRequest ()
virtual

Implementation of ClientInterfaceBase::cancelRequest for an rclcpp service client.

Aborts the busy-waiting request loop causing it to return (almost) immediately.

Declaration at line 93 of file service_client_interface.hpp, definition at line 78 of file service_client_interface_impl.hpp.

initialize()

template <typename ServiceT>
void moveit_pro::behaviors::RclcppClientInterface< ServiceT >::initialize (const std::string & service_name, std::chrono::duration< double > wait_for_server_timeout, std::chrono::duration< double > result_timeout)
virtual

Implementation of ClientInterfaceBase::initialize for an rclcpp service client.

Sets client_ to a new service client instance

Declaration at line 73 of file service_client_interface.hpp, definition at line 23 of file service_client_interface_impl.hpp.

syncSendRequest()

template <typename ServiceT>
tl::expected< typename ServiceT::Response, std::string > moveit_pro::behaviors::RclcppClientInterface< ServiceT >::syncSendRequest (const typename ServiceT::Request & request)
virtual

Implementation of ClientInterfaceBase::syncGetResult for an rclcpp service client.

Calls the service client's async_send_request function and blocks while waiting on the future which it returns.

Declaration at line 87 of file service_client_interface.hpp, definition at line 44 of file service_client_interface_impl.hpp.

waitForServiceServer()

template <typename ServiceT>
bool moveit_pro::behaviors::RclcppClientInterface< ServiceT >::waitForServiceServer ()
virtual

Implementation of ClientInterfaceBase::waitForServiceServer for an rclcpp service client.

Calls the service client's wait_for_service function.

Declaration at line 80 of file service_client_interface.hpp, definition at line 37 of file service_client_interface_impl.hpp.

Private Member Attributes

client_

template <typename ServiceT>
std::shared_ptr<rclcpp::Client<ServiceT> > moveit_pro::behaviors::RclcppClientInterface< ServiceT >::client_

Service client.

Definition at line 105 of file service_client_interface.hpp.

node_

template <typename ServiceT>
std::shared_ptr<rclcpp::Node> moveit_pro::behaviors::RclcppClientInterface< ServiceT >::node_

Node to use when initializing the service client.

Definition at line 99 of file service_client_interface.hpp.

reentrant_callback_group_

template <typename ServiceT>
std::shared_ptr<rclcpp::CallbackGroup> moveit_pro::behaviors::RclcppClientInterface< ServiceT >::reentrant_callback_group_

Reentrant callback group used by the service client.

Definition at line 102 of file service_client_interface.hpp.

request_canceled_

template <typename ServiceT>
std::atomic_bool moveit_pro::behaviors::RclcppClientInterface< ServiceT >::request_canceled_ { false }

Notifies the request waiting loop to exit early.

Definition at line 114 of file service_client_interface.hpp.

result_timeout_

template <typename ServiceT>
std::chrono::duration<double> moveit_pro::behaviors::RclcppClientInterface< ServiceT >::result_timeout_

Duration to wait for a result before failing.

Definition at line 111 of file service_client_interface.hpp.

wait_for_server_timeout_

template <typename ServiceT>
std::chrono::duration<double> moveit_pro::behaviors::RclcppClientInterface< ServiceT >::wait_for_server_timeout_

Duration to wait for the service server to be available before failing.

Definition at line 108 of file service_client_interface.hpp.

Public Static Attributes

kResponseBusyWaitPeriod

template <typename ServiceT>
constexpr std::chrono::milliseconds moveit_pro::behaviors::RclcppClientInterface< ServiceT >::kResponseBusyWaitPeriod { 100 }
constexpr static

Definition at line 95 of file service_client_interface.hpp.


The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.