|
nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
|
#include <client.hpp>
Public Types | |
| using | RequestType = typename S::Request |
| using | ResponseType = typename S::Response |
| using | TypedResponseFn = void(*)(const ResponseType &response) |
| using | TypedResponseFnWithCtx = void(*)(const ResponseType &response, void *ctx) |
Public Member Functions | |
| Result | async_send_request (const RequestType &req) |
| Result | call (const RequestType &req, ResponseType &resp, uint32_t timeout_ms=5000) |
| Client () | |
| Client (Client &&other) | |
| size_t | handle_id () const |
| bool | is_valid () const |
| Check if the client is initialized and valid. | |
| Client & | operator= (Client &&other) |
| Future< ResponseType > | send_request (const RequestType &req) |
| int | server_available () const |
| ~Client () | |
Friends | |
| class | Node |
Typed service client for a ROS 2 service.
Mirrors rclcpp::Client<S>. The service type S must provide nested Request and Response types with TYPE_NAME, TYPE_HASH, SERIALIZED_SIZE_MAX, ffi_serialize(), and ffi_deserialize().
Usage (async – preferred):
| using nros::Client< S >::TypedResponseFn = void (*)(const ResponseType& response) |
Phase 189.M3.3.f — typed response-handler signatures for the callback-style client (rclcpp async dispatch). The handler runs during spin_once when a reply arrives for a request sent via async_send_request.
| using nros::Client< S >::TypedResponseFnWithCtx = void (*)(const ResponseType& response, void* ctx) |
|
inline |
Destructor – releases service client resources.
Future-style clients own an RmwServiceClient in storage_; callback-style clients (M3.3.f) are owned by the executor arena, so the dtor must NOT touch storage_ for them.
|
inline |
Default constructor – creates an uninitialized service client. Use Node::create_client() to initialize.
|
inline |
Phase 189.M3.3.f — callback-style async send. Only valid on a callback-style client (created via the create_client(out, name, callback,
...) overload); the reply is delivered to the registered response handler during spin_once (no Future). Returns immediately after sending.
|
inline |
Send a request and block until a reply is received.
Spins the executor internally (like the runtime's Promise::wait). Never calls zpico_get — all I/O is driven by spin_once.
| req | Request to send. |
| resp | Output response struct (filled on success). |
| timeout_ms | Maximum wait time (default 5000ms). |
|
inline |
Executor handle for the callback-style client (Phase 189.M3.3.f); SIZE_MAX for future-style / uninitialized.
|
inline |
Check if the client is initialized and valid.
|
inline |
Send a request and return a Future for the response (non-blocking).
Call wait() on the returned future to block until the response arrives, or poll with is_ready() / try_take().
| req | Request to send. |
|
inline |
Phase 124.C.3 — graph-aware "is the matching server up?" probe.
Returns the count from the RMW backend's matched-server view:
1 — at least one matching server is currently visible.0 — no matching server discovered yet.-1 — backend cannot answer (e.g. XRCE without participant enumeration); caller must fall back to a timed wait_for_service or assume reachability.Never spins the executor — synchronous, safe to call from inside callbacks. Mirrors rclcpp::ClientBase::service_is_ready but with a tri-state result instead of collapsing "don't know" and "no" into the same false.