rclcpp
master
C++ ROS Client Library API
|
#include <client.hpp>
Public Types | |
using | SharedRequest = typename ServiceT::Request::SharedPtr |
using | SharedResponse = typename ServiceT::Response::SharedPtr |
using | Promise = std::promise< SharedResponse > |
using | PromiseWithRequest = std::promise< std::pair< SharedRequest, SharedResponse > > |
using | SharedPromise = std::shared_ptr< Promise > |
using | SharedPromiseWithRequest = std::shared_ptr< PromiseWithRequest > |
using | SharedFuture = std::shared_future< SharedResponse > |
using | SharedFutureWithRequest = std::shared_future< std::pair< SharedRequest, SharedResponse > > |
using | CallbackType = std::function< void(SharedFuture)> |
using | CallbackWithRequestType = std::function< void(SharedFutureWithRequest)> |
Public Member Functions | |
Client (rclcpp::node_interfaces::NodeBaseInterface *node_base, rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph, const std::string &service_name, rcl_client_options_t &client_options) | |
Default constructor. More... | |
virtual | ~Client () |
bool | take_response (typename ServiceT::Response &response_out, rmw_request_id_t &request_header_out) |
Take the next response for this client. More... | |
std::shared_ptr< void > | create_response () override |
Create a shared pointer with the response type. More... | |
std::shared_ptr< rmw_request_id_t > | create_request_header () override |
Create a shared pointer with a rmw_request_id_t. More... | |
void | handle_response (std::shared_ptr< rmw_request_id_t > request_header, std::shared_ptr< void > response) override |
Handle a server response. More... | |
SharedFuture | async_send_request (SharedRequest request) |
template<typename CallbackT , typename std::enable_if< rclcpp::function_traits::same_arguments< CallbackT, CallbackType >::value >::type * = nullptr> | |
SharedFuture | async_send_request (SharedRequest request, CallbackT &&cb) |
template<typename CallbackT , typename std::enable_if< rclcpp::function_traits::same_arguments< CallbackT, CallbackWithRequestType >::value >::type * = nullptr> | |
SharedFutureWithRequest | async_send_request (SharedRequest request, CallbackT &&cb) |
Public Member Functions inherited from rclcpp::ClientBase | |
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_t > | get_client_handle () |
Return the rcl_client_t client handle in a std::shared_ptr. More... | |
std::shared_ptr< const rcl_client_t > | get_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... | |
bool | exchange_in_use_by_wait_set_state (bool in_use_state) |
Exchange the "in use by wait set" state for this client. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from rclcpp::ClientBase | |
bool | wait_for_service_nanoseconds (std::chrono::nanoseconds timeout) |
rcl_node_t * | get_rcl_node_handle () |
const rcl_node_t * | get_rcl_node_handle () const |
Protected Attributes inherited from rclcpp::ClientBase | |
rclcpp::node_interfaces::NodeGraphInterface::WeakPtr | node_graph_ |
std::shared_ptr< rcl_node_t > | node_handle_ |
std::shared_ptr< rclcpp::Context > | context_ |
std::shared_ptr< rcl_client_t > | client_handle_ |
std::atomic< bool > | in_use_by_wait_set_ {false} |
using rclcpp::Client< ServiceT >::SharedRequest = typename ServiceT::Request::SharedPtr |
using rclcpp::Client< ServiceT >::SharedResponse = typename ServiceT::Response::SharedPtr |
using rclcpp::Client< ServiceT >::Promise = std::promise<SharedResponse> |
using rclcpp::Client< ServiceT >::PromiseWithRequest = std::promise<std::pair<SharedRequest, SharedResponse> > |
using rclcpp::Client< ServiceT >::SharedPromise = std::shared_ptr<Promise> |
using rclcpp::Client< ServiceT >::SharedPromiseWithRequest = std::shared_ptr<PromiseWithRequest> |
using rclcpp::Client< ServiceT >::SharedFuture = std::shared_future<SharedResponse> |
using rclcpp::Client< ServiceT >::SharedFutureWithRequest = std::shared_future<std::pair<SharedRequest, SharedResponse> > |
using rclcpp::Client< ServiceT >::CallbackType = std::function<void (SharedFuture)> |
using rclcpp::Client< ServiceT >::CallbackWithRequestType = std::function<void (SharedFutureWithRequest)> |
|
inline |
Default constructor.
The constructor for a Client is almost never called directly. Instead, clients should be instantiated through the function rclcpp::create_client().
[in] | node_base | NodeBaseInterface pointer that is used in part of the setup. |
[in] | node_graph | The node graph interface of the corresponding node. |
[in] | service_name | Name of the topic to publish to. |
[in] | client_options | options for the subscription. |
|
inlinevirtual |
|
inline |
Take the next response for this client.
[out] | response_out | The reference to a Service Response into which the middleware will copy the response being taken. |
[out] | request_header_out | The request header to be filled by the middleware when taking, and which can be used to associte the response to a specific request. |
rclcpp::exceptions::RCLError | based exceptions if the underlying rcl function fail. |
|
inlineoverridevirtual |
Create a shared pointer with the response type.
Implements rclcpp::ClientBase.
|
inlineoverridevirtual |
Create a shared pointer with a rmw_request_id_t.
Implements rclcpp::ClientBase.
|
inlineoverridevirtual |
Handle a server response.
[in] | request_header | used to check if the secuence number is valid |
[in] | response | message with the server response |
Implements rclcpp::ClientBase.
|
inline |
|
inline |
|
inline |