10#ifndef NROS_RCLCPP_ACTION_CLIENT_HPP
11#define NROS_RCLCPP_ACTION_CLIENT_HPP
18#include "rclcpp/detail/entity_name.hpp"
19#include "rclcpp/logging.hpp"
21#include "rclcpp/size_bound.hpp"
37#include "rclcpp/detail/nros_cpp_ffi.h"
41 const uint8_t goal_id[16],
44 const uint8_t* data,
size_t len,
47 const uint8_t* data,
size_t len,
152 return ::rclcpp::Result(
176 if (!initialized_)
return false;
178 const_cast<void*
>(
static_cast<const void*
>(storage_)));
205 uint8_t buf[::rclcpp::detail::buffer_bounds<GoalType>::tx];
207 if (GoalType::ffi_serialize(&
goal,
buf,
sizeof(
buf), &len) != 0) {
211 storage_,
buf, len,
reinterpret_cast<uint8_t(*)[16]
>(goal_id)));
240 template <
size_t Cap>
247 storage_, executor_,
reinterpret_cast<const uint8_t(*)[16]
>(goal_id),
buf,
sizeof(
buf),
249 if (
ret != 0) return ::rclcpp::Result(
ret);
251 if (ResultType::ffi_deserialize(
buf, len, &result) != 0) {
254 return ::rclcpp::Result::success();
278 if (!initialized_) return ::rclcpp::Future<GoalAccept>();
280 uint8_t buf[::rclcpp::detail::buffer_bounds<GoalType>::tx];
282 if (GoalType::ffi_serialize(&
goal,
buf,
sizeof(
buf), &len) != 0) {
283 return ::rclcpp::Future<GoalAccept>();
288 storage_,
buf, len,
reinterpret_cast<uint8_t(*)[16]
>(goal_id));
289 if (
ret != 0) return ::rclcpp::Future<GoalAccept>();
291 return ::rclcpp::Future<GoalAccept>(storage_,
328 template <
size_t Cap>
331 if (!initialized_)
return Fut();
334 storage_,
reinterpret_cast<const uint8_t(*)[16]
>(goal_id));
335 if (
ret != 0)
return Fut();
363 if (
ret != 0) return ::rclcpp::Result(
ret);
365 if (FeedbackType::ffi_deserialize(
buf, len, &feedback) != 0) {
368 return ::rclcpp::Result::success();
392 if (initialized_ && !feedback_stream_.
is_valid()) {
395 return feedback_stream_;
398 const ::rclcpp::Stream<FeedbackType>&
feedback_stream()
const {
return feedback_stream_; }
436 uint8_t buf[::rclcpp::detail::buffer_bounds<GoalType>::tx];
438 if (GoalType::ffi_serialize(&
goal,
buf,
sizeof(
buf), &len) != 0) {
442 storage_,
buf, len,
reinterpret_cast<uint8_t(*)[16]
>(goal_id)));
468 storage_,
reinterpret_cast<const uint8_t(*)[16]
>(goal_id)));
485 if (
ret != 0) return ::rclcpp::Result(
ret);
487 return ::rclcpp::Result::success();
500 storage_,
reinterpret_cast<const uint8_t(*)[16]
>(goal_id)));
532 if (!initialized_)
return;
552 initialized_ =
false;
563 : executor_(
other.executor_), initialized_(
other.initialized_), action_name_{} {
564 ::memcpy(action_name_,
other.action_name_,
sizeof(action_name_));
565 if (
other.initialized_) {
567 other.initialized_ =
false;
573 if (
this != &
other) {
578 executor_ =
other.executor_;
579 initialized_ =
other.initialized_;
580 ::memcpy(action_name_,
other.action_name_,
sizeof(action_name_));
581 if (
other.initialized_) {
583 other.initialized_ =
false;
598 friend class ::rclcpp::Node;
621 const ::rclcpp::QoS&
qos) {
628 out.executor_ = executor_handle_;
631 ::rclcpp::detail::assign_entity_name(
out.action_name_,
action_name);
632 out.initialized_ =
true;
Definition client.hpp:129
Result create_action_client(::rclcpp_action::Client< A > &out, const char *action_name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
Definition client.hpp:620
Definition result.hpp:216
bool is_valid() const
Check if the stream is connected to a valid source.
Definition stream.hpp:138
::rclcpp::Result send_goal(const GoalType &goal, uint8_t goal_id[16])
Definition client.hpp:202
bool is_valid() const
Check if the action client is initialized and valid.
Definition client.hpp:537
::rclcpp::Stream< FeedbackType > & feedback_stream()
Definition client.hpp:391
::rclcpp::Result send_goal_async(const GoalType &goal, uint8_t goal_id[16])
Definition client.hpp:433
void poll()
Definition client.hpp:531
::rclcpp::Result wait_for_action_server(uint32_t timeout_ms)
Definition client.hpp:150
typename A::Result ResultType
Definition client.hpp:98
::rclcpp::Result get_result_async(const uint8_t goal_id[16])
Definition client.hpp:497
Client()
Definition client.hpp:592
::rclcpp::Result send_goal(const GoalType &goal, ::rclcpp_action::GoalUUID &goal_id)
Definition client.hpp:216
::rclcpp::Result get_result_async(const ::rclcpp_action::GoalUUID &goal_id)
get_result_async taking a GoalUUID value (phase-417 W4.b).
Definition client.hpp:504
Client & operator=(Client &&other)
Definition client.hpp:572
Client(Client &&other)
Definition client.hpp:562
::rclcpp::Result try_recv_cancel_response(::rclcpp_action::CancelReturnCode &out)
Definition client.hpp:481
typename A::Feedback FeedbackType
Definition client.hpp:99
bool action_server_is_ready() const
Definition client.hpp:175
::rclcpp::Result try_recv_feedback(FeedbackType &feedback)
Definition client.hpp:350
::rclcpp::Result get_result(const uint8_t goal_id[16], ResultType &result)
Definition client.hpp:228
::rclcpp::Future< ResultType > get_result_future(const uint8_t goal_id[16])
Definition client.hpp:313
::rclcpp::Result cancel_goal(const ::rclcpp_action::GoalUUID &goal_id)
cancel_goal taking a GoalUUID value (phase-417 W4.b).
Definition client.hpp:472
::rclcpp::Result wait_for_action_server()
REFUSED — wait_for_action_server() with no budget.
Definition client.hpp:157
::rclcpp::Future< GoalAccept > send_goal_future(const GoalType &goal)
Definition client.hpp:277
::rclcpp::Result get_result(const ::rclcpp_action::GoalUUID &goal_id, ResultType &result)
get_result taking a GoalUUID value (phase-417 W4.b).
Definition client.hpp:233
::rclcpp::Result set_callbacks(const SendGoalOptions &options)
Definition client.hpp:520
::rclcpp::Result try_recv_feedback_sized(FeedbackType &feedback)
Definition client.hpp:356
const ::rclcpp::Stream< FeedbackType > & feedback_stream() const
Definition client.hpp:398
::rclcpp::Result send_goal_async(const GoalType &goal, ::rclcpp_action::GoalUUID &goal_id)
Definition client.hpp:447
~Client()
Definition client.hpp:549
const char * get_action_name() const
Definition client.hpp:187
::rclcpp::Result get_result_sized(const uint8_t goal_id[16], ResultType &result)
Definition client.hpp:241
typename A::Goal GoalType
Definition client.hpp:97
::rclcpp::Future< ResultType, Cap > get_result_future_sized(const uint8_t goal_id[16])
Definition client.hpp:329
::rclcpp::Future< ResultType > get_result_future(const ::rclcpp_action::GoalUUID &goal_id)
get_result_future taking a GoalUUID value (phase-417 W4.b).
Definition client.hpp:318
::rclcpp::Result cancel_goal(const uint8_t goal_id[16])
Definition client.hpp:465
Inline storage-size macros for opaque entity buffers.
rclcpp::Future<T> — single-shot deferred result.
int nros_cpp_ret_t
Definition future.hpp:21
static const size_t ACTION_NAME_MAX
Definition server.hpp:189
CancelReturnCode
Definition server.hpp:253
ResultOf< void > Result
Definition result.hpp:246
@ Error
Generic failure not covered by a more specific code.
@ Unsupported
Operation not implemented by the active backend.
@ TryAgain
Transient — no data ready yet (non-blocking take). Retry later.
rclcpp::Node and global session helpers.
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 client.hpp:40
void(* nros_cpp_action_client_feedback_callback_t)(const uint8_t goal_id[16], const uint8_t *data, size_t len, void *ctx)
Definition client.hpp:43
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 client.hpp:46
rclcpp::Result, rclcpp::ErrorCode, and the RCLCPP_TRY macro.
rclcpp::Stream<T> — multi-shot message receiver.
Definition client.hpp:105
static int ffi_deserialize(const uint8_t *data, size_t len, GoalAccept *out)
Definition client.hpp:119
static const size_t SERIALIZED_SIZE_MAX
Definition client.hpp:114
uint8_t goal_id[16]
Definition client.hpp:109
bool accepted
Definition client.hpp:110
Definition client.hpp:410
SendGoalOptions()
Definition client.hpp:421
void * context
User context pointer passed to all callbacks.
Definition client.hpp:419
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 client.hpp:416
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 client.hpp:414
void(* goal_response)(bool accepted, const uint8_t goal_id[16], void *ctx)
Called when the server accepts or rejects the goal.
Definition client.hpp:412
Definition server.hpp:124
uint8_t * data()
Pointer to the 16 bytes — what the raw-array overloads and the FFI take.
Definition server.hpp:142