Class GenericServiceClient
Defined in File generic_client_compat.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public rclcpp::ClientBase
Class Documentation
-
class GenericServiceClient : public rclcpp::ClientBase
Compatibility GenericClient for ROS 2 Humble. Replicates the subset of rclcpp::GenericClient API used by OperationManager:
wait_for_service(timeout)
remove_pending_request(request_id)
Implemented directly on top of rcl C APIs and dynamically loaded typesupport, which are available in all ROS 2 distros from Humble onward.
Public Types
-
using Request = void*
-
using Response = void*
-
using Promise = std::promise<SharedResponse>
-
using Future = std::future<SharedResponse>
Public Functions
Construct a GenericServiceClient.
- Parameters:
node_base – Node base interface (for rcl node handle)
node_graph – Node graph interface (for service availability checks)
service_name – Fully-qualified service name
service_type – Service type string, e.g. “std_srvs/srv/Trigger”
client_options – rcl client options
-
~GenericServiceClient() override = default
-
inline std::shared_ptr<void> create_response() override
Create a response message (allocated via introspection)
-
inline std::shared_ptr<rmw_request_id_t> create_request_header() override
Create a request header for associating responses.
Handle incoming response — dispatches to the pending promise.
-
inline FutureAndRequestId async_send_request(const Request request)
Send a request asynchronously. Returns a FutureAndRequestId.
- Parameters:
request – Pointer to the deserialized request message (void*)
-
inline bool remove_pending_request(int64_t request_id)
Remove a pending request (called on timeout to prevent resource leak)
-
struct FutureAndRequestId
FutureAndRequestId — wraps a std::future<SharedResponse> and associated request_id, mirroring rclcpp::GenericClient::FutureAndRequestId for API compatibility.
Public Functions
-
FutureAndRequestId(FutureAndRequestId &&other) noexcept = default
-
FutureAndRequestId &operator=(FutureAndRequestId &&other) noexcept = default
-
FutureAndRequestId(const FutureAndRequestId&) = delete
-
FutureAndRequestId &operator=(const FutureAndRequestId&) = delete
-
inline auto get()
-
inline bool valid() const noexcept
-
inline void wait() const
-
FutureAndRequestId(FutureAndRequestId &&other) noexcept = default