rclcpp  master
C++ ROS Client Library API
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rclcpp::ClientBase Class Referenceabstract

#include <client.hpp>

Inheritance diagram for rclcpp::ClientBase:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::ClientBase:
Collaboration graph
[legend]

Public Member Functions

 ClientBase (rclcpp::node_interfaces::NodeBaseInterface *node_base, rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph)
 
virtual ~ClientBase ()
 
bool take_type_erased_response (void *response_out, rmw_request_id_t &request_header_out)
 Take the next response for this client as a type erased pointer. More...
 
const char * get_service_name () const
 Return the name of the service. More...
 
std::shared_ptr< rcl_client_tget_client_handle ()
 Return the rcl_client_t client handle in a std::shared_ptr. More...
 
std::shared_ptr< const rcl_client_tget_client_handle () const
 Return the rcl_client_t client handle in a std::shared_ptr. More...
 
bool service_is_ready () const
 Return if the service is ready. More...
 
template<typename RepT = int64_t, typename RatioT = std::milli>
bool wait_for_service (std::chrono::duration< RepT, RatioT > timeout=std::chrono::duration< RepT, RatioT >(-1))
 Wait for a service to be ready. More...
 
virtual std::shared_ptr< void > create_response ()=0
 
virtual std::shared_ptr< rmw_request_id_tcreate_request_header ()=0
 
virtual void handle_response (std::shared_ptr< rmw_request_id_t > request_header, std::shared_ptr< void > response)=0
 
bool exchange_in_use_by_wait_set_state (bool in_use_state)
 Exchange the "in use by wait set" state for this client. More...
 

Protected Member Functions

bool wait_for_service_nanoseconds (std::chrono::nanoseconds timeout)
 
rcl_node_tget_rcl_node_handle ()
 
const rcl_node_tget_rcl_node_handle () const
 

Protected Attributes

rclcpp::node_interfaces::NodeGraphInterface::WeakPtr node_graph_
 
std::shared_ptr< rcl_node_tnode_handle_
 
std::shared_ptr< rclcpp::Contextcontext_
 
std::shared_ptr< rcl_client_tclient_handle_
 
std::atomic< bool > in_use_by_wait_set_ {false}
 

Constructor & Destructor Documentation

◆ ClientBase()

rclcpp::ClientBase::ClientBase ( rclcpp::node_interfaces::NodeBaseInterface node_base,
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr  node_graph 
)

◆ ~ClientBase()

virtual rclcpp::ClientBase::~ClientBase ( )
virtual

Member Function Documentation

◆ take_type_erased_response()

bool rclcpp::ClientBase::take_type_erased_response ( void *  response_out,
rmw_request_id_t request_header_out 
)

Take the next response for this client as a type erased pointer.

The type erased pointer allows for this method to be used in a type agnostic way along with ClientBase::create_response(), ClientBase::create_request_header(), and ClientBase::handle_response(). The typed version of this can be used if the Service type is known,

See also
Client::take_response().
Parameters
[out]response_outThe type erased pointer to a Service Response into which the middleware will copy the response being taken.
[out]request_header_outThe request header to be filled by the middleware when taking, and which can be used to associte the response to a specific request.
Returns
true if the response was taken, otherwise false.
Exceptions
rclcpp::exceptions::RCLErrorbased exceptions if the underlying rcl function fail.

◆ get_service_name()

const char* rclcpp::ClientBase::get_service_name ( ) const

Return the name of the service.

Returns
The name of the service.

◆ get_client_handle() [1/2]

std::shared_ptr<rcl_client_t> rclcpp::ClientBase::get_client_handle ( )

Return the rcl_client_t client handle in a std::shared_ptr.

This handle remains valid after the Client is destroyed. The actual rcl client is not finalized until it is out of scope everywhere.

◆ get_client_handle() [2/2]

std::shared_ptr<const rcl_client_t> rclcpp::ClientBase::get_client_handle ( ) const

Return the rcl_client_t client handle in a std::shared_ptr.

This handle remains valid after the Client is destroyed. The actual rcl client is not finalized until it is out of scope everywhere.

◆ service_is_ready()

bool rclcpp::ClientBase::service_is_ready ( ) const

Return if the service is ready.

Returns
true if the service is ready, false otherwise

◆ wait_for_service()

template<typename RepT = int64_t, typename RatioT = std::milli>
bool rclcpp::ClientBase::wait_for_service ( std::chrono::duration< RepT, RatioT >  timeout = std::chrono::duration<RepT, RatioT>(-1))
inline

Wait for a service to be ready.

Parameters
timeoutmaximum time to wait
Returns
true if the service is ready and the timeout is not over, false otherwise

◆ create_response()

virtual std::shared_ptr<void> rclcpp::ClientBase::create_response ( )
pure virtual

◆ create_request_header()

virtual std::shared_ptr<rmw_request_id_t> rclcpp::ClientBase::create_request_header ( )
pure virtual

◆ handle_response()

virtual void rclcpp::ClientBase::handle_response ( std::shared_ptr< rmw_request_id_t request_header,
std::shared_ptr< void >  response 
)
pure virtual

◆ exchange_in_use_by_wait_set_state()

bool rclcpp::ClientBase::exchange_in_use_by_wait_set_state ( bool  in_use_state)

Exchange the "in use by wait set" state for this client.

This is used to ensure this client is not used by multiple wait sets at the same time.

Parameters
[in]in_use_statethe new state to exchange into the state, true indicates it is now in use by a wait set, and false is that it is no longer in use by a wait set.
Returns
the previous state.

◆ wait_for_service_nanoseconds()

bool rclcpp::ClientBase::wait_for_service_nanoseconds ( std::chrono::nanoseconds  timeout)
protected

◆ get_rcl_node_handle() [1/2]

rcl_node_t* rclcpp::ClientBase::get_rcl_node_handle ( )
protected

◆ get_rcl_node_handle() [2/2]

const rcl_node_t* rclcpp::ClientBase::get_rcl_node_handle ( ) const
protected

Member Data Documentation

◆ node_graph_

rclcpp::node_interfaces::NodeGraphInterface::WeakPtr rclcpp::ClientBase::node_graph_
protected

◆ node_handle_

std::shared_ptr<rcl_node_t> rclcpp::ClientBase::node_handle_
protected

◆ context_

std::shared_ptr<rclcpp::Context> rclcpp::ClientBase::context_
protected

◆ client_handle_

std::shared_ptr<rcl_client_t> rclcpp::ClientBase::client_handle_
protected

◆ in_use_by_wait_set_

std::atomic<bool> rclcpp::ClientBase::in_use_by_wait_set_ {false}
protected

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