|
nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
|
#include <action_server.hpp>
Public Types | |
| using | FeedbackType = typename A::Feedback |
| using | GoalType = typename A::Goal |
| using | ResultType = typename A::Result |
| using | TypedCancelFn = CancelResponse(*)(const uint8_t uuid[16]) |
| User-facing typed cancel callback signature. | |
| using | TypedCancelFnWithCtx = CancelResponse(*)(const uint8_t uuid[16], void *ctx) |
| User-facing typed cancel callback signature with user context (Phase 84.G9). | |
| using | TypedGoalFn = GoalResponse(*)(const uint8_t uuid[16], const GoalType &goal) |
| User-facing typed goal callback signature. | |
| using | TypedGoalFnWithCtx = GoalResponse(*)(const uint8_t uuid[16], const GoalType &goal, void *ctx) |
| User-facing typed goal callback signature with user context (Phase 84.G9). | |
| using | TypedVisitorFn = void(*)(const uint8_t uuid[16], GoalStatus status) |
User-facing visitor signature for for_each_active_goal. | |
Public Member Functions | |
| ActionServer () | |
| ActionServer (ActionServer &&other) | |
| Result | complete_goal (const uint8_t goal_id[16], const ResultType &result) |
| Complete a goal with a result. | |
| template<typename F > | |
| Result | for_each_active_goal (F f) |
| bool | is_valid () const |
| Check if the action server is initialized and valid. | |
| ActionServer & | operator= (ActionServer &&other) |
| Result | publish_feedback (const uint8_t goal_id[16], const FeedbackType &feedback) |
| template<typename F > | |
| Result | set_cancel_callback (F f) |
| Result | set_cancel_callback_with_ctx (TypedCancelFnWithCtx f, void *ctx) |
| template<typename F > | |
| Result | set_goal_callback (F f) |
| Result | set_goal_callback_with_ctx (TypedGoalFnWithCtx f, void *ctx) |
| ~ActionServer () | |
| Destructor — releases action server resources. | |
Friends | |
| class | Node |
Typed action server for a ROS 2 action.
Mirrors rclcpp_action::Server<A> with a callback-based API. The action type A must provide nested Goal, Result, and Feedback types with TYPE_NAME, TYPE_HASH, SERIALIZED_SIZE_MAX, ffi_serialize(), and ffi_deserialize().
Usage:
Callbacks must be stateless (empty-capture lambdas or plain function pointers). This is a freestanding C++14 library without std::function, so per-instance closure storage is not available.
| using nros::ActionServer< A >::TypedCancelFn = CancelResponse (*)(const uint8_t uuid[16]) |
User-facing typed cancel callback signature.
| using nros::ActionServer< A >::TypedCancelFnWithCtx = CancelResponse (*)(const uint8_t uuid[16], void* ctx) |
User-facing typed cancel callback signature with user context (Phase 84.G9).
| using nros::ActionServer< A >::TypedGoalFn = GoalResponse (*)(const uint8_t uuid[16], const GoalType& goal) |
User-facing typed goal callback signature.
| using nros::ActionServer< A >::TypedGoalFnWithCtx = GoalResponse (*)(const uint8_t uuid[16], const GoalType& goal, void* ctx) |
User-facing typed goal callback signature with user context (Phase 84.G9).
| using nros::ActionServer< A >::TypedVisitorFn = void (*)(const uint8_t uuid[16], GoalStatus status) |
User-facing visitor signature for for_each_active_goal.
|
inline |
Destructor — releases action server resources.
|
inline |
|
inline |
Default constructor — creates an uninitialized action server. Use Node::create_action_server() to initialize.
|
inline |
Complete a goal with a result.
|
inline |
Iterate over every currently live goal and invoke f(uuid, status).
F must be a stateless callable convertible to void (*)(const uint8_t uuid[16], GoalStatus status). The arena never stores the original goal CDR payload, so only identity + status are forwarded — if you need the goal bytes, stash them in a {uuid → state} table from inside set_goal_callback. F must be a stateless callable convertible to void(*)(const uint8_t[16], GoalStatus).
|
inline |
Check if the action server is initialized and valid.
|
inline |
|
inline |
Publish feedback for an active goal.
| goal_id | 16-byte goal UUID from the goal callback. |
| feedback | Feedback to publish. |
|
inline |
Register a cancel callback.
F must be a stateless callable convertible to TypedCancelFn.
|
inline |
Register a cancel callback with a user context pointer.
Mirrors set_goal_callback_with_ctx — the bare function pointer receives a void* alongside each UUID so stateful cancel policies don't need captured lambdas or global state. Mutually exclusive with set_cancel_callback().
|
inline |
Register a typed goal callback.
F must be a stateless callable that decays to TypedGoalFn (empty-capture lambda or plain function pointer). F must be a stateless callable convertible to TypedGoalFn (empty-capture lambda or plain function pointer).
|
inline |
Register a typed goal callback with a user context pointer.
The bare function pointer is stored alongside a void* that is forwarded to every invocation — lets callers reach stateful objects without capturing lambdas or file-scope globals. Overrides and is overridden by set_goal_callback() (the two modes are mutually exclusive).