nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
nros::ActionServer< A > Class Template Reference

#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.
 
ActionServeroperator= (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
 

Detailed Description

template<typename A>
class nros::ActionServer< A >

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:

using Fib = example_interfaces::action::Fibonacci;
NROS_TRY(node.create_action_server(srv, "/fibonacci"));
srv.set_goal_callback(
[](const uint8_t[16], const Fib::Goal& g) {
if (g.order > 46) return nros::GoalResponse::Reject;
});
Definition future.hpp:40
#define NROS_TRY(expr)
Definition result.hpp:90

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.

Member Typedef Documentation

◆ FeedbackType

template<typename A >
using nros::ActionServer< A >::FeedbackType = typename A::Feedback

◆ GoalType

template<typename A >
using nros::ActionServer< A >::GoalType = typename A::Goal

◆ ResultType

template<typename A >
using nros::ActionServer< A >::ResultType = typename A::Result

◆ TypedCancelFn

template<typename A >
using nros::ActionServer< A >::TypedCancelFn = CancelResponse (*)(const uint8_t uuid[16])

User-facing typed cancel callback signature.

◆ TypedCancelFnWithCtx

template<typename A >
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).

◆ TypedGoalFn

template<typename A >
using nros::ActionServer< A >::TypedGoalFn = GoalResponse (*)(const uint8_t uuid[16], const GoalType& goal)

User-facing typed goal callback signature.

◆ TypedGoalFnWithCtx

template<typename A >
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).

◆ TypedVisitorFn

template<typename A >
using nros::ActionServer< A >::TypedVisitorFn = void (*)(const uint8_t uuid[16], GoalStatus status)

User-facing visitor signature for for_each_active_goal.

Constructor & Destructor Documentation

◆ ~ActionServer()

template<typename A >
nros::ActionServer< A >::~ActionServer ( )
inline

Destructor — releases action server resources.

◆ ActionServer() [1/2]

template<typename A >
nros::ActionServer< A >::ActionServer ( ActionServer< A > &&  other)
inline

◆ ActionServer() [2/2]

template<typename A >
nros::ActionServer< A >::ActionServer ( )
inline

Default constructor — creates an uninitialized action server. Use Node::create_action_server() to initialize.

Member Function Documentation

◆ complete_goal()

template<typename A >
Result nros::ActionServer< A >::complete_goal ( const uint8_t  goal_id[16],
const ResultType result 
)
inline

Complete a goal with a result.

◆ for_each_active_goal()

template<typename A >
template<typename F >
Result nros::ActionServer< A >::for_each_active_goal ( F  f)
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).

◆ is_valid()

template<typename A >
bool nros::ActionServer< A >::is_valid ( ) const
inline

Check if the action server is initialized and valid.

◆ operator=()

template<typename A >
ActionServer & nros::ActionServer< A >::operator= ( ActionServer< A > &&  other)
inline

◆ publish_feedback()

template<typename A >
Result nros::ActionServer< A >::publish_feedback ( const uint8_t  goal_id[16],
const FeedbackType feedback 
)
inline

Publish feedback for an active goal.

Parameters
goal_id16-byte goal UUID from the goal callback.
feedbackFeedback to publish.
Returns
Result indicating success or failure.

◆ set_cancel_callback()

template<typename A >
template<typename F >
Result nros::ActionServer< A >::set_cancel_callback ( F  f)
inline

Register a cancel callback.

F must be a stateless callable convertible to TypedCancelFn.

◆ set_cancel_callback_with_ctx()

template<typename A >
Result nros::ActionServer< A >::set_cancel_callback_with_ctx ( TypedCancelFnWithCtx  f,
void ctx 
)
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().

◆ set_goal_callback()

template<typename A >
template<typename F >
Result nros::ActionServer< A >::set_goal_callback ( F  f)
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).

◆ set_goal_callback_with_ctx()

template<typename A >
Result nros::ActionServer< A >::set_goal_callback_with_ctx ( TypedGoalFnWithCtx  f,
void ctx 
)
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).

Friends And Related Symbol Documentation

◆ Node

template<typename A >
friend class Node
friend

The documentation for this class was generated from the following files: