|
nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
|
#include <service.hpp>
Public Types | |
| using | RequestType = typename S::Request |
| using | ResponseType = typename S::Response |
| using | TypedServiceFn = void(*)(const RequestType &request, ResponseType &response) |
| using | TypedServiceFnWithCtx = void(*)(const RequestType &request, ResponseType &response, void *ctx) |
Public Member Functions | |
| size_t | handle_id () const |
| bool | is_valid () const |
| Check if the service is initialized and valid. | |
| Service & | operator= (Service &&other) |
| Result | send_reply (int64_t seq_id, const ResponseType &resp) |
| Result | send_response (int64_t seq_id, const ResponseType &resp) |
| Service () | |
| Service (Service &&other) | |
| Result | take_request (RequestType &req, int64_t &seq_id) |
| Result | try_recv_request (RequestType &req, int64_t &seq_id) |
| template<size_t Cap> | |
| Result | try_recv_request_sized (RequestType &req, int64_t &seq_id) |
| ~Service () | |
Friends | |
| class | Node |
Typed service server for a ROS 2 service.
Mirrors rclcpp::Service<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:
| using nros::Service< S >::RequestType = typename S::Request |
| using nros::Service< S >::ResponseType = typename S::Response |
| using nros::Service< S >::TypedServiceFn = void (*)(const RequestType& request, ResponseType& response) |
Phase 189.M3.3.e — typed request-handler signatures for the callback-style service (rclcpp dispatch model). The handler fills response from request; the executor sends the reply during spin.
| using nros::Service< S >::TypedServiceFnWithCtx = void (*)(const RequestType& request, ResponseType& response, void* ctx) |
|
inline |
Destructor — releases service server resources.
Poll-style services own an RmwServiceServer in storage_ and free it here. Callback-style services (Phase 189.M3.3.e) are owned by the executor arena (freed when the executor drops), so the dtor must NOT touch storage_ for them.
|
inline |
|
inline |
Default constructor — creates an uninitialized service server. Use Node::create_service() to initialize.
|
inline |
Executor handle for the callback-style service (Phase 189.M3.3.e); SIZE_MAX for poll-style / uninitialized.
|
inline |
Check if the service is initialized and valid.
|
inline |
|
inline |
Phase-379 W5: rcl, rclcpp and rclrs all say send_response, and our own C already used that word. Kept as a forwarder so an out-of-tree node on the old spelling still compiles and is told what to move to.
|
inline |
Send a typed reply to a previously received request.
| seq_id | Sequence number from take_request(). |
| resp | Response to send. |
|
inline |
Try to receive a typed request (non-blocking).
| req | Output request struct (filled on success). |
| seq_id | Output sequence number for reply matching. |
|
inline |
take_request(RequestType&, int64_t&).phase-379 W6 decision 1 (2026-09-03): take -> take. rcl (rcl_take_request), rclcpp (Service::take_request) and our own RMW vtable (take_request) already said take; only this layer said take. Header-only forwarder, no ABI cost. Scheduled for removal.
|
inline |
take_request with the receive buffer sized by the CALLER.
This IS a receive buffer — issue 0964's survey listed the service request under "transmit", which is true of Client<S>'s request and false here: the server deserializes out of it, so an under-estimate truncates. See Subscription::take_sized.
|
friend |