mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
mrs_lib::ServiceClientHandler< ServiceType >::Impl< ServiceType > Class Template Reference

implementation of the service client handler More...

#include <service_client_handler.hpp>

Public Member Functions

 Impl (rclcpp::Node::SharedPtr &node, const std::string &address, const rclcpp::QoS &qos, const rclcpp::CallbackGroup::SharedPtr &callback_group)
 constructor
 
std::optional< std::shared_ptr< typename ServiceType::Response > > callSync (const std::shared_ptr< typename ServiceType::Request > &request)
 "classic" synchronous service call
 
std::optional< std::shared_future< std::shared_ptr< typename ServiceType::Response > > > callAsync (const std::shared_ptr< typename ServiceType::Request > &request)
 asynchronous service call
 
internal::ServiceAwaitable< ServiceType > callAwaitable (const std::shared_ptr< typename ServiceType::Request > &request)
 
std::string getServiceName () const
 Returns the name of the service this client connects to.
 
template<typename RepT = int64_t, typename RatioT = std::milli>
bool waitForService (std::chrono::duration< RepT, RatioT > timeout)
 Waits for the service to be available.
 
bool isServiceReady () const
 Checks if the service is available.
 

Detailed Description

template<class ServiceType>
template<class ServiceType>
class mrs_lib::ServiceClientHandler< ServiceType >::Impl< ServiceType >

implementation of the service client handler

Constructor & Destructor Documentation

◆ Impl()

template<class ServiceType >
template<class ServiceType >
mrs_lib::ServiceClientHandler< ServiceType >::Impl< ServiceType >::Impl ( rclcpp::Node::SharedPtr &  node,
const std::string &  address,
const rclcpp::QoS &  qos,
const rclcpp::CallbackGroup::SharedPtr &  callback_group 
)
inline

constructor

Parameters
nodeROS node handler
addressservice address
qosQOS
callback_groupcallback group

Member Function Documentation

◆ callAsync()

template<class ServiceType >
template<class ServiceType >
std::optional< std::shared_future< std::shared_ptr< typename ServiceType::Response > > > mrs_lib::ServiceClientHandler< ServiceType >::Impl< ServiceType >::callAsync ( const std::shared_ptr< typename ServiceType::Request > &  request)
inline

asynchronous service call

Parameters
requestrequest
Returns
optional shared future to the result

◆ callSync()

template<class ServiceType >
template<class ServiceType >
std::optional< std::shared_ptr< typename ServiceType::Response > > mrs_lib::ServiceClientHandler< ServiceType >::Impl< ServiceType >::callSync ( const std::shared_ptr< typename ServiceType::Request > &  request)
inline

"classic" synchronous service call

Parameters
requestrequest
Returns
optional shared pointer to the response

◆ getServiceName()

template<class ServiceType >
template<class ServiceType >
std::string mrs_lib::ServiceClientHandler< ServiceType >::Impl< ServiceType >::getServiceName ( ) const
inline

Returns the name of the service this client connects to.

Returns
service name

◆ isServiceReady()

template<class ServiceType >
template<class ServiceType >
bool mrs_lib::ServiceClientHandler< ServiceType >::Impl< ServiceType >::isServiceReady ( ) const
inline

Checks if the service is available.

Returns
true if the service is available, false otherwise

◆ waitForService()

template<class ServiceType >
template<class ServiceType >
template<typename RepT = int64_t, typename RatioT = std::milli>
bool mrs_lib::ServiceClientHandler< ServiceType >::Impl< ServiceType >::waitForService ( std::chrono::duration< RepT, RatioT >  timeout)
inline

Waits for the service to be available.

Parameters
timeoutmaximum time to wait for the service
Returns
true if the service is available, false otherwise

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