|
| GenericClient (rclcpp::node_interfaces::NodeBaseInterface *node_base, rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph, const std::string &service_name, const std::string &service_type, rcl_client_options_t &client_options) |
|
RCLCPP_PUBLIC SharedResponse | create_response () override |
|
RCLCPP_PUBLIC std::shared_ptr< rmw_request_id_t > | create_request_header () override |
|
RCLCPP_PUBLIC void | handle_response (std::shared_ptr< rmw_request_id_t > request_header, std::shared_ptr< void > response) override |
|
RCLCPP_PUBLIC FutureAndRequestId | async_send_request (const Request request) |
| Send a request to the service server. More...
|
|
template<typename AllocatorT = std::allocator<int64_t>> |
size_t | prune_requests_older_than (std::chrono::time_point< std::chrono::system_clock > time_point, std::vector< int64_t, AllocatorT > *pruned_requests=nullptr) |
| Clean all pending requests older than a time_point. More...
|
|
RCLCPP_PUBLIC size_t | prune_pending_requests () |
|
RCLCPP_PUBLIC bool | remove_pending_request (int64_t request_id) |
|
RCLCPP_PUBLIC bool | take_response (Response response_out, rmw_request_id_t &request_header_out) |
| Take the next response for this client. More...
|
|
RCLCPP_PUBLIC | ClientBase (rclcpp::node_interfaces::NodeBaseInterface *node_base, rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph) |
|
RCLCPP_PUBLIC 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...
|
|
RCLCPP_PUBLIC const char * | get_service_name () const |
| Return the name of the service. More...
|
|
RCLCPP_PUBLIC std::shared_ptr< rcl_client_t > | get_client_handle () |
| Return the rcl_client_t client handle in a std::shared_ptr. More...
|
|
RCLCPP_PUBLIC std::shared_ptr< const rcl_client_t > | get_client_handle () const |
| Return the rcl_client_t client handle in a std::shared_ptr. More...
|
|
RCLCPP_PUBLIC 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...
|
|
RCLCPP_PUBLIC bool | exchange_in_use_by_wait_set_state (bool in_use_state) |
| Exchange the "in use by wait set" state for this client. More...
|
|
RCLCPP_PUBLIC rclcpp::QoS | get_request_publisher_actual_qos () const |
| Get the actual request publsher QoS settings, after the defaults have been determined. More...
|
|
RCLCPP_PUBLIC rclcpp::QoS | get_response_subscription_actual_qos () const |
| Get the actual response subscription QoS settings, after the defaults have been determined. More...
|
|
void | set_on_new_response_callback (std::function< void(size_t)> callback) |
| Set a callback to be called when each new response is received. More...
|
|
void | clear_on_new_response_callback () |
| Unset the callback registered for new responses, if any.
|
|
|
int64_t | async_send_request_impl (const Request request, CallbackInfoVariant value) |
|
std::optional< CallbackInfoVariant > | get_and_erase_pending_request (int64_t request_number) |
|
RCLCPP_PUBLIC bool | wait_for_service_nanoseconds (std::chrono::nanoseconds timeout) |
|
RCLCPP_PUBLIC rcl_node_t * | get_rcl_node_handle () |
|
RCLCPP_PUBLIC const rcl_node_t * | get_rcl_node_handle () const |
|
RCLCPP_PUBLIC void | set_on_new_response_callback (rcl_event_callback_t callback, const void *user_data) |
|
Definition at line 35 of file generic_client.hpp.
Send a request to the service server.
This method returns a FutureAndRequestId
instance that can be passed to Executor::spin_until_future_complete() to wait until it has been completed.
If the future never completes, e.g. the call to Executor::spin_until_future_complete() times out, GenericClient::remove_pending_request() must be called to clean the client internal state. Not doing so will make the Client
instance to use more memory each time a response is not received from the service server.
auto future = client->async_send_request(my_request);
if (
rclcpp::FutureReturnCode::TIMEOUT ==
executor->spin_until_future_complete(future, timeout))
{
client->remove_pending_request(future);
} else {
handle_response(future.get());
}
- Parameters
-
[in] | request | request to be send. |
- Returns
- a FutureAndRequestId instance.
Definition at line 139 of file generic_client.cpp.