1#ifndef MRS_LIB_SERVICE_CLIENT_HPP_
2#define MRS_LIB_SERVICE_CLIENT_HPP_
10#include <rclcpp/callback_group.hpp>
11#include <rclcpp/node_interfaces/node_base_interface.hpp>
12#include <rclcpp/node_interfaces/node_clock_interface.hpp>
13#include <rclcpp/node_interfaces/node_graph_interface.hpp>
14#include <rclcpp/node_interfaces/node_interfaces.hpp>
15#include <rclcpp/node_interfaces/node_logging_interface.hpp>
16#include <rclcpp/node_interfaces/node_services_interface.hpp>
17#include <rclcpp/qos.hpp>
19#include "mrs_lib/coro/task.hpp"
29 rclcpp::node_interfaces::NodeInterfaces<rclcpp::node_interfaces::NodeServicesInterface, rclcpp::node_interfaces::NodeGraphInterface,
30 rclcpp::node_interfaces::NodeBaseInterface, rclcpp::node_interfaces::NodeLoggingInterface,
31 rclcpp::node_interfaces::NodeClockInterface>;
42 rclcpp::QoS
qos = rclcpp::ServicesQoS();
56 template <
class ServiceType>
62 using Request = ServiceType::Request;
63 using Response = ServiceType::Response;
99 std::expected<std::future<std::shared_ptr<Response>>, std::string>
call_async(
const std::shared_ptr<Request>& request);
124 template <
typename RepT =
int64_t,
typename RatioT = std::milli>
125 [[nodiscard]]
bool wait_for_service(std::chrono::duration<RepT, RatioT> timeout);
152#ifndef MRS_LIB_SERVICE_CLIENT_IMPL_HPP_
153#include "mrs_lib/service_client.impl.hpp"
Owning pointer wrapper with move only value semantics. Usefull for implementing the pointer to implem...
Definition pimpl.hpp:39
size_t prune_pending_requests()
Remove all pending requests.
Definition service_client.impl.hpp:217
bool wait_for_service(std::chrono::duration< RepT, RatioT > timeout)
Wait for the service to become available.
Definition service_client.impl.hpp:205
std::string get_unresolved_service_name() const
Returns the unresolved name of the service handled by this service client.
Definition service_client.impl.hpp:198
std::string get_service_name() const
Returns the resolved (full) name of the service handled by this service client.
Definition service_client.impl.hpp:192
ServiceClient(const ServiceClientOptions &options, std::string_view service_name)
Construct the client with the specified options.
Definition service_client.impl.hpp:174
std::expected< std::future< std::shared_ptr< Response > >, std::string > call_async(const std::shared_ptr< Request > &request)
Async call of the service.
Definition service_client.impl.hpp:186
bool is_service_ready() const
Check if the service is available.
Definition service_client.impl.hpp:211
Task< std::expected< std::shared_ptr< Response >, std::string > > call(const std::shared_ptr< Request > &request)
Coroutine call of the service.
Definition service_client.impl.hpp:180
Task type for creating coroutines.
Definition task.hpp:230
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24
rclcpp::node_interfaces::NodeInterfaces< rclcpp::node_interfaces::NodeServicesInterface, rclcpp::node_interfaces::NodeGraphInterface, rclcpp::node_interfaces::NodeBaseInterface, rclcpp::node_interfaces::NodeLoggingInterface, rclcpp::node_interfaces::NodeClockInterface > ServiceClientNodeInterfaces
ROS node interfaces required by the ServiceClient.
Definition service_client.hpp:28
Options for configuring the ServiceClient.
Definition service_client.hpp:37
rclcpp::QoS qos
QOS settings for the service client.
Definition service_client.hpp:42
ServiceClientNodeInterfaces node_interfaces
ROS node interfaces used by the service client.
Definition service_client.hpp:39
std::shared_ptr< rclcpp::CallbackGroup > callback_group
ROS callback group used by the service client callbacks.
Definition service_client.hpp:44