|
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) |
| Service () | |
| Service (Service &&other) | |
| Result | try_recv_request (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 >::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 |
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 |
Send a typed reply to a previously received request.
| seq_id | Sequence number from try_recv_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. |