10#ifndef NROS_CPP_ACTION_CLIENT_HPP
11#define NROS_CPP_ACTION_CLIENT_HPP
29#include "nros_cpp_ffi.h"
33 const uint8_t goal_id[16],
36 const uint8_t* data,
size_t len,
39 const uint8_t* data,
size_t len,
83 if (!out || len < 17)
return -1;
84 for (
int i = 0; i < 16; ++i)
102 uint8_t buf[GoalType::SERIALIZED_SIZE_MAX];
104 if (GoalType::ffi_serialize(&goal, buf,
sizeof(buf), &len) != 0) {
107 return Result(nros_cpp_action_client_send_goal(storage_, buf, len,
108 reinterpret_cast<uint8_t(*)[16]
>(goal_id)));
122 uint8_t buf[ResultType::SERIALIZED_SIZE_MAX];
125 storage_, executor_,
reinterpret_cast<const uint8_t(*)[16]
>(goal_id), buf,
sizeof(buf),
127 if (ret != 0)
return Result(ret);
129 if (ResultType::ffi_deserialize(buf, len, &result) != 0) {
160 if (GoalType::ffi_serialize(&
goal,
buf,
sizeof(
buf), &len) != 0) {
166 storage_,
buf, len,
reinterpret_cast<uint8_t(*)[16]
>(goal_id));
194 storage_,
reinterpret_cast<const uint8_t(*)[16]
>(goal_id));
213 uint8_t buf[FeedbackType::SERIALIZED_SIZE_MAX];
219 if (FeedbackType::ffi_deserialize(
buf, len, &feedback) != 0) {
246 if (initialized_ && !feedback_stream_.
is_valid()) {
249 return feedback_stream_;
291 if (GoalType::ffi_serialize(&
goal,
buf,
sizeof(
buf), &len) != 0) {
295 storage_,
buf, len,
reinterpret_cast<uint8_t(*)[16]
>(goal_id)));
308 storage_,
reinterpret_cast<const uint8_t(*)[16]
>(goal_id)));
328 if (!initialized_)
return;
339 initialized_ =
false;
348 : executor_(
other.executor_), initialized_(
other.initialized_) {
349 if (
other.initialized_) {
351 other.initialized_ =
false;
357 if (
this != &
other) {
362 executor_ =
other.executor_;
363 initialized_ =
other.initialized_;
364 if (
other.initialized_) {
366 other.initialized_ =
false;
388 char action_name_[256] = {};
409 ffi_qos.liveliness_lease_ms =
qos.liveliness_lease_ms();
410 ffi_qos.avoid_ros_namespace_conventions =
qos.avoid_ros_namespace_conventions() ? 1 : 0;
421 out.executor_ = executor_handle_;
422 out.initialized_ =
true;
nros_cpp_ret_t nros_cpp_action_client_set_callbacks(void *handle, nros_cpp_action_client_goal_response_callback_t goal_response, nros_cpp_action_client_feedback_callback_t feedback, nros_cpp_action_client_result_callback_t result, void *context)
void(* nros_cpp_action_client_goal_response_callback_t)(bool accepted, const uint8_t goal_id[16], void *ctx)
Definition action_client.hpp:32
void(* nros_cpp_action_client_feedback_callback_t)(const uint8_t goal_id[16], const uint8_t *data, size_t len, void *ctx)
Definition action_client.hpp:35
void(* nros_cpp_action_client_result_callback_t)(const uint8_t goal_id[16], int32_t status, const uint8_t *data, size_t len, void *ctx)
Definition action_client.hpp:38
Definition action_client.hpp:67
Result get_result(const uint8_t goal_id[16], ResultType &result)
Definition action_client.hpp:119
Future< GoalAccept > send_goal_future(const GoalType &goal)
Definition action_client.hpp:155
Future< ResultType > get_result_future(const uint8_t goal_id[16])
Definition action_client.hpp:190
Result get_result_async(const uint8_t goal_id[16])
Definition action_client.hpp:305
ActionClient()
Definition action_client.hpp:375
ActionClient & operator=(ActionClient &&other)
Definition action_client.hpp:356
bool is_valid() const
Check if the action client is initialized and valid.
Definition action_client.hpp:333
const Stream< FeedbackType > & feedback_stream() const
Definition action_client.hpp:252
Stream< FeedbackType > & feedback_stream()
Definition action_client.hpp:245
typename A::Result ResultType
Definition action_client.hpp:70
Result try_recv_feedback(FeedbackType &feedback)
Definition action_client.hpp:210
typename A::Goal GoalType
Definition action_client.hpp:69
Result send_goal_async(const GoalType &goal, uint8_t goal_id[16])
Definition action_client.hpp:286
~ActionClient()
Destructor — releases action client resources.
Definition action_client.hpp:336
Result set_callbacks(const SendGoalOptions &options)
Definition action_client.hpp:316
ActionClient(ActionClient &&other)
Definition action_client.hpp:347
Result send_goal(const GoalType &goal, uint8_t goal_id[16])
Definition action_client.hpp:99
typename A::Feedback FeedbackType
Definition action_client.hpp:71
void poll()
Definition action_client.hpp:327
Result create_action_client(ActionClient< A > &out, const char *action_name, const QoS &qos=QoS::services())
Definition action_client.hpp:399
static constexpr Result success()
Named constructors.
Definition result.hpp:74
bool is_valid() const
Check if the stream is connected to a valid source.
Definition stream.hpp:105
Inline storage-size macros for opaque entity buffers.
nros::Future<T> — single-shot deferred result.
int nros_cpp_ret_t
Definition future.hpp:20
@ Error
Generic failure not covered by a more specific code.
@ TryAgain
Transient — no data ready yet (non-blocking take). Retry later.
nros::Node and global session helpers.
nros_cpp_qos_history_t
Definition qos.hpp:31
nros_cpp_qos_liveliness_t
Definition qos.hpp:35
nros_cpp_qos_durability_t
Definition qos.hpp:27
nros_cpp_qos_reliability_t
Definition qos.hpp:23
nros::Result, nros::ErrorCode, and the NROS_TRY macro.
nros::Stream<T> — multi-shot message receiver.
Definition action_client.hpp:77
static const size_t SERIALIZED_SIZE_MAX
Definition action_client.hpp:81
bool accepted
Definition action_client.hpp:79
uint8_t goal_id[16]
Definition action_client.hpp:78
static int ffi_deserialize(const uint8_t *data, size_t len, GoalAccept *out)
Definition action_client.hpp:82
Definition action_client.hpp:263
void * context
User context pointer passed to all callbacks.
Definition action_client.hpp:272
void(* goal_response)(bool accepted, const uint8_t goal_id[16], void *ctx)
Called when the server accepts or rejects the goal.
Definition action_client.hpp:265
SendGoalOptions()
Definition action_client.hpp:274
void(* result)(const uint8_t goal_id[16], int32_t status, const uint8_t *data, size_t len, void *ctx)
Called when the result is received.
Definition action_client.hpp:269
void(* feedback)(const uint8_t goal_id[16], const uint8_t *data, size_t len, void *ctx)
Called when feedback is received for the goal.
Definition action_client.hpp:267