10#ifndef NROS_RCLCPP_NODE_HPP
11#define NROS_RCLCPP_NODE_HPP
16#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
18#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
50#if defined(NROS_CPP_STD)
57#include "rclcpp/detail/nros_cpp_ffi.h"
59#include "rclcpp/detail/traits.hpp"
60#include "rclcpp/handle.hpp"
62#include "rclcpp/owned.hpp"
63#include "rclcpp/detail/hosted_block.hpp"
64#include "rclcpp/detail/nros_cpp_config_generated.h"
74#include "rclc/detail/entry_config.h"
79#include "rclcpp/options.hpp"
93#include "rclcpp/clock.hpp"
105#include "rclcpp/detail/declared_qos.hpp"
106#include "rclcpp/detail/declared_params.hpp"
112#include "rclcpp/node_parameters.hpp"
113#include "rclcpp/logging.hpp"
118#include "rclcpp/graph.hpp"
120#include "rclcpp/callback_group.hpp"
129#include "rclcpp/parameter.hpp"
134#include "rclcpp/detail/std_detect.hpp"
156#ifdef NROS_RMW_CYCLONEDDS
157extern "C" int32_t nros_rmw_cyclonedds_register(
void);
159#if defined(NROS_RMW_XRCE) || defined(NROS_RMW_XRCE_CFFI)
160extern "C" int32_t nros_rmw_xrce_register(
void);
162#ifdef NROS_RMW_ZENOH_CFFI
163extern "C" int32_t nros_rmw_zenoh_register(
void);
166extern "C" int32_t nros_rmw_uorb_register(
void);
172static_assert(NROS_CPP_RET_NOT_FOUND == -4 && NROS_CPP_RET_ALREADY_EXISTS == -5 &&
173 NROS_CPP_RET_FULL == -6 && NROS_CPP_RET_NOT_INIT == -7 &&
174 NROS_CPP_RET_TRY_AGAIN == -14 && NROS_CPP_RET_REENTRANT == -15 &&
175 NROS_CPP_RET_UNSUPPORTED == -16,
176 "nros_cpp_ret_t diverged from the shared numbering (issue #229)");
193template <
typename M>
class Publisher;
194template <
typename M>
class Subscription;
195template <
typename S>
class Service;
196template <
typename S>
class Client;
200template <
typename A>
class Server;
201template <
typename A>
class Client;
348 (
what !=
nullptr) ?
what :
"?",
static_cast<int>(code));
349#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
350 ::fprintf(
stderr,
"[nros] FATAL: node \"%s\" failed to construct at %s (code=%d)\n",
352 static_cast<int>(code));
370 NROS_ERROR(
"node \"%s\": topic \"%s\" DECLARED depth %d but the QoS "
371 "passed states %d. Depth multiplies the executor arena, so they must agree.",
374#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
376 "[nros] FATAL: node \"%s\": topic \"%s\" was DECLARED depth %d in "
377 "the contract sidecar (<stem>.contract.yaml) but the QoS passed to "
378 "create_subscription_in states depth %d. Depth multiplies the executor "
379 "arena (cost is (depth+1)*bound per subscription), so the two must agree. "
380 "Fix the contract row or the call site.\n",
398 int len,
const char*
list) {
406 NROS_ERROR(
"node \"%s\": created callback group \"%.*s\", not in CALLBACK_GROUPS \"%s\"",
409 NROS_ERROR(
"node \"%s\": CALLBACK_GROUPS \"%s\" declares \"%.*s\", never created",
node,
412#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
414 created ?
"[nros] FATAL: node \"%s\" created callback group \"%.*s\", which its "
415 "registration's CALLBACK_GROUPS \"%s\" does not declare.\n"
416 :
"[nros] FATAL: node \"%s\" never created callback group \"%.*s\", which "
417 "its registration's CALLBACK_GROUPS \"%s\" declares.\n",
420 " The tier derivation ranks the declared list and the executor binds what the "
421 "code creates, so the two must name the same groups (ONE declared group and none "
422 "created is node-level placement, and is allowed). Fix the "
423 "nano_ros_node_register(... CALLBACK_GROUPS ...) line or the create_callback_group "
441 NROS_ERROR(
"node \"%s\": topic \"%s\" DECLARED %s %s but the QoS passed states %s. An "
442 "incompatible-QoS match never delivers, so they must agree.",
445#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
447 "[nros] FATAL: node \"%s\": topic \"%s\" was DECLARED %s %s in the contract "
448 "sidecar (<stem>.contract.yaml) but the QoS passed to create_subscription_in "
449 "states %s. Fix the contract row or the call site.\n",
487 const char*
f = (
fqn !=
nullptr) ?
fqn :
"?";
491 NROS_ERROR(
"node \"%s\": parameter \"%s\" is not declared in its contract (%s).",
f,
p,
c);
493 NROS_ERROR(
"node \"%s\": parameter \"%s\" is declared %s in its contract (%s) but the "
494 "code declares it as %s.",
498#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
501 "[nros] FATAL: node \"%s\": parameter \"%s\" is not declared in its "
502 "contract (%s, `params:`). The parameter store is sized from that "
503 "declaration, so a parameter it does not name has no slot. Declare it "
504 "there with its type, or stop declaring it in the code.\n",
508 "[nros] FATAL: node \"%s\": parameter \"%s\" is declared `%s` in its "
509 "contract (%s) but the code declares it as `%s`. Fix the contract or "
510 "the code so they state one type.\n",
536inline Result init_in(
const char* locator =
nullptr, uint8_t domain_id = 0);
557inline Result init_in(
const char* locator, uint8_t domain_id,
const char* session_name);
577inline Result init_in(
const char* locator, uint8_t domain_id,
const char* session_name,
578 const char* node_namespace);
597inline Result init_with_rmw(
const char* rmw,
const char* locator =
nullptr, uint8_t domain_id = 0,
598 const char* session_name =
"node");
622inline Result init_in(
int argc,
char const*
const* argv,
const char* session_name =
nullptr);
737 executor_handle_ = Node::global_storage();
781 if (!handle.
valid()) {
782 this->
set_error(
"ctor (null executor handle)", -1);
872 static constexpr ::rclcpp::NodeOptions
kOptions{};
876#ifdef NROS_CPP_HAS_STD_STRING
878 explicit Node(const ::std::string& name) : Node(name.c_str(), nullptr) {}
885 Node(const ::std::string& name, const ::std::string& ns,
887 :
Node(name.c_str(), ns.c_str(), options) {}
933#ifdef NROS_CPP_HAS_STD_STRING
941 template <
typename M>
943 const ::rclcpp::QoS&
qos);
946 template <
typename M>
952 template <
typename M,
typename Cb>
953 typename ::rclcpp::Subscription<M>::SharedPtr
957 template <
typename M,
typename Cb>
959 ::size_t depth,
Cb cb);
971 template <
typename S>
976 template <
typename S,
typename F,
977 typename =
typename std::enable_if<std::is_convertible<
978 F,
void (*)(
const typename S::Request&,
typename S::Response&)>::value>::type>
979 typename ::rclcpp::Service<S>::SharedPtr
985 template <
typename S,
typename F,
986 typename =
typename std::enable_if<
988 !std::is_convertible<
F,
void (*)(
const typename S::Request&,
989 typename S::Response&)>::value>::type,
991 typename ::rclcpp::Service<S>::SharedPtr
1010 template <
typename S>
1015 template <
typename S,
typename F,
1016 typename =
typename std::enable_if<
1017 std::is_convertible<
F,
void (*)(
const typename S::Response&)>::value>::type>
1018 typename ::rclcpp::Client<S>::SharedPtr
1023 template <
typename S,
typename F,
1024 typename =
typename std::enable_if<
1026 !std::is_convertible<
F,
void (*)(
const typename S::Response&)>::value>::type,
1028 typename ::rclcpp::Client<S>::SharedPtr
1056 template <
typename M>
1057 typename ::rclcpp::Publisher<M>::SharedPtr
1062 template <
typename M>
1073 template <
typename M,
typename Cb>
1074 typename ::rclcpp::Subscription<M>::SharedPtr
1078 template <
typename M,
typename Cb>
1080 ::size_t depth,
Cb cb);
1084 template <
typename S>
1089 template <
typename S,
typename F,
1090 typename = typename ::rclcpp::tr::enable_if<::rclcpp::tr::is_convertible<
1091 F,
void (*)(
const typename S::Request&,
typename S::Response&)>::value>::type>
1092 typename ::rclcpp::Service<S>::SharedPtr
1098 template <
typename S,
typename F,
1099 typename = typename ::rclcpp::tr::enable_if<
1101 !::rclcpp::tr::is_convertible<
F,
void (*)(
const typename S::Request&,
1102 typename S::Response&)>::value>::type,
1104 typename ::rclcpp::Service<S>::SharedPtr
1109 template <
typename S>
1114 template <
typename S,
typename F,
1115 typename = typename ::rclcpp::tr::enable_if<::rclcpp::tr::is_convertible<
1116 F,
void (*)(
const typename S::Response&)>::value>::type>
1117 typename ::rclcpp::Client<S>::SharedPtr
1123 typename S,
typename F,
1124 typename = typename ::rclcpp::tr::enable_if<
1126 !::rclcpp::tr::is_convertible<
F,
void (*)(
const typename S::Response&)>::value>::type,
1128 typename ::rclcpp::Client<S>::SharedPtr
1190 template <
typename T>
1233 ::size_t
max_names, ::size_t& count)
const;
1259#ifdef NROS_CPP_HAS_STD_STRING
1263 template <typename T> T declare_parameter(const ::std::string& name, T default_value = T()) {
1266 template <
typename T>
bool get_parameter(const ::std::string&
name,
T&
out)
const {
1269 template <
typename T> T get_parameter(const ::std::string& name)
const {
1270 return this->
template get_parameter<T>(name.c_str());
1272 template <
typename T>
Result set_parameter(const ::std::string& name, T value) {
1273 return this->
template set_parameter<T>(name.c_str(), value);
1275 bool has_parameter(const ::std::string& name)
const {
1276 return this->has_parameter(name.c_str());
1278 Result undeclare_parameter(const ::std::string& name) {
1279 return this->undeclare_parameter(name.c_str());
1281 template <
typename T>
1282 T declare_parameter(const ::std::string& name, T default_value,
1283 const ParameterDescriptor& descriptor) {
1284 return this->
template declare_parameter<T>(name.c_str(), default_value, descriptor);
1286 template <
typename T>
1287 bool get_parameter_or(const ::std::string& name, T& out, T fallback)
const {
1288 return this->
template get_parameter_or<T>(name.c_str(), out, fallback);
1290 ParameterType get_parameter_type(const ::std::string& name)
const {
1291 return this->get_parameter_type(name.c_str());
1305 template <
typename T>
1306 Result declare_parameters(const ::std::string& prefix, const ::std::map<::std::string, T>& m) {
1307 for (typename ::std::map<::std::string, T>::const_iterator it = m.begin(); it != m.end();
1309 const ::std::string full = prefix.empty() ? it->first : (prefix +
"." + it->first);
1310 const ::nros_cpp_node_t* h = this->ffi_handle();
1311 Result r = ::rclcpp::detail::node_param_declare(h, full.c_str(), it->second);
1312 if (!r.ok() && r.raw() != RCLC_RET_ALREADY_EXISTS) {
1316 return Result(RCL_RET_OK);
1340 if (!
out.executor_handle_) {
1347 out.initialized_ =
true;
1354 if (!initialized_)
return "";
1360 if (!initialized_)
return "";
1401 if (!initialized_)
return nullptr;
1429 if (!initialized_) return ::rclcpp::Logger(
"",
nullptr);
1489 ::nros_cpp_node_set_qos_overrides(&handle_,
overrides, len);
1675 executor_handle_,
topic_name, &::rclcpp::detail::EndpointInfoTrampoline::thunk,
1699 executor_handle_,
topic_name, &::rclcpp::detail::EndpointInfoTrampoline::thunk,
1709 template <
typename M>
1725 template <
typename M>
1727 const ::rclcpp::QoS&
qos, const ::rclcpp::PublisherOptions&
options);
1740 template <
typename M>
1759 template <
typename M>
1761 const ::rclcpp::QoS&
qos,
1762 const ::rclcpp::SubscriptionOptions&
options);
1807 typename M,
typename F,
1808 typename =
typename std::enable_if<std::is_convertible<
F,
void (*)(
const M&)>::value>::type>
1811 const ::rclcpp::SubscriptionOptions&
options = {});
1824 template <
typename M,
typename F,
1825 typename =
typename std::enable_if<
1829 const ::rclcpp::SubscriptionOptions&
options = {});
1831#if defined(NROS_SAFETY_E2E)
1850 template <
typename M,
typename F,
1851 typename =
typename std::enable_if<std::is_convertible<
1852 F,
void (*)(
const M&, const ::nros_cpp_integrity_status_t&)>::value>::type>
1855 const ::rclcpp::SubscriptionOptions&
options = {});
1872 template <
typename S>
1889 template <
typename S,
typename F,
1890 typename =
typename std::enable_if<std::is_convertible<
1891 F,
void (*)(
const typename S::Request&,
typename S::Response&)>::value>::type>
1894 const ::rclcpp::ServiceOptions&
options = {});
1911 template <
typename S>
1926 template <
typename S,
typename F,
1927 typename =
typename std::enable_if<
1928 std::is_convertible<
F,
void (*)(
const typename S::Response&)>::value>::type>
1931 const ::rclcpp::ClientOptions&
options = {});
1943 template <
typename A>
1946 const ::rclcpp::ActionServerOptions&
options = {});
1954 template <
typename A>
1961 template <
typename A>
1966 template <
typename A>
1975 template <
typename M>
2005 size_t handle_id = 0;
2008 context, &handle_id);
2010 out.executor_ = executor_handle_;
2011 out.handle_id_ = handle_id;
2012 out.initialized_ =
true;
2030#ifdef NROS_CPP_HAS_STD_CHRONO
2034 template <typename Rep, typename Period, typename Cb>
2049 void* context =
nullptr) {
2051 size_t handle_id = 0;
2055 out.executor_ = executor_handle_;
2056 out.handle_id_ = handle_id;
2057 out.initialized_ =
true;
2080 template <
class C,
void (C::*Method)()>
2082 return this->create_wall_timer(
2092 template <
class C,
void (C::*Method)()>
2100 template <
class C,
void (C::*Method)()>
2103 return this->create_timer_in_group(
2116 void* context =
nullptr) {
2118 size_t handle_id = 0;
2120 context, &handle_id);
2122 out.executor_ = executor_handle_;
2123 out.handle_id_ = handle_id;
2124 out.initialized_ =
true;
2147 if (!::rclcpp::detail::admit_callback_group(
name)) {
2148 const ::rclcpp::detail::DeclaredCallbackGroups*
g =
2149 ::rclcpp::detail::declared_callback_groups_scope();
2150 const char*
list = (
g !=
nullptr) ?
g->list :
nullptr;
2152 while (
name[len] !=
'\0')
2156 this->set_error(
"create_callback_group: the group is not in this registration's "
2158 ::rclcpp::detail::DECLARED_CALLBACK_GROUP_MISMATCH);
2160 return ::rclcpp::CallbackGroup{
name};
2176 void* context =
nullptr) {
2178 size_t handle_id = 0;
2182 out.executor_ = executor_handle_;
2183 out.handle_id_ = handle_id;
2184 out.initialized_ =
true;
2209 typename M,
typename F,
2210 typename =
typename std::enable_if<std::is_convertible<
F,
void (*)(
const M&)>::value>::type>
2214 const ::rclcpp::SubscriptionOptions&
options = {});
2227 template <
typename M>
2242 void* context =
nullptr) {
2244 size_t handle_id = 0;
2246 out.storage_, &handle_id);
2248 out.initialized_ =
true;
2249 out.executor_ = executor_handle_;
2250 out.handle_id_ = handle_id;
2291 template <
typename M>
2298 this->set_error(
"create_publisher_in",
r.raw());
2316 template <
typename M,
class C,
void (C::*Method)(const M& msg)>
2322 template <
typename M,
class C,
void (C::*Method)(const M& msg)>
2357 "create_subscription_in: ::rclcpp::QoS depth disagrees with the depth declared for "
2358 "this topic in the contract sidecar. Depth multiplies the arena, so the "
2359 "declaration and the code must state one number, not two.",
2381 rel !=
static_cast<int>(
qos.reliability())) {
2383 this->get_name(),
topic,
"reliability",
2386 static_cast<int>(
qos.reliability())));
2387 this->set_error(
"create_subscription_in: ::rclcpp::QoS reliability disagrees with the "
2388 "reliability declared for this topic in the contract sidecar.",
2394 dur !=
static_cast<int>(
qos.durability())) {
2396 this->get_name(),
topic,
"durability",
2399 this->set_error(
"create_subscription_in: ::rclcpp::QoS durability disagrees with the "
2400 "durability declared for this topic in the contract sidecar.",
2426 const char*
ns = this->get_namespace();
2427 const char*
nn = this->get_name();
2428 if (
name ==
nullptr ||
nn ==
nullptr) {
2431 const ::rclcpp::declared_params::Node*
declaring =
2442 this->set_error(
"declare_parameter: the code does not declare this parameter the way "
2443 "its contract does (see the line above for the node, the parameter and "
2444 "the contract). The parameter store is sized from the contract's "
2445 "`params:`, so the two must state one name and one type.",
2481 initialized_ =
false;
2487 : handle_(
other.handle_), initialized_(
other.initialized_),
2488 executor_handle_(
other.executor_handle_), clock_(
other.clock_),
2492 has_error_(
other.has_error_), error_what_(
other.error_what_),
2493 error_code_(
other.error_code_) {
2494 other.initialized_ =
false;
2495 other.executor_handle_ =
nullptr;
2499 if (
this != &
other) {
2503 handle_ =
other.handle_;
2504 initialized_ =
other.initialized_;
2505 executor_handle_ =
other.executor_handle_;
2506 clock_ =
other.clock_;
2507 has_error_ =
other.has_error_;
2508 error_what_ =
other.error_what_;
2509 error_code_ =
other.error_code_;
2510 other.initialized_ =
false;
2511 other.executor_handle_ =
nullptr;
2518 Node& operator=(
const Node&) =
delete;
2522 void* executor_handle_;
2548 bool has_error_ =
false;
2549 const char* error_what_ =
nullptr;
2562 friend class ::rclcpp::Executor;
2563 friend class ::rclcpp::NodeBuilder;
2594 template <
int = 0>
struct GlobalStorageHolder {
2597 static uint8_t* global_storage() {
return GlobalStorageHolder<>::storage; }
2618 static bool global_initialized() {
2619 return nros_cpp_context_is_live(GlobalStorageHolder<>::storage);
2627alignas(8) uint8_t Node::GlobalStorageHolder<N>::storage[NROS_CPP_EXECUTOR_STORAGE_SIZE] = {};
2661#ifndef NROS_COMPONENT_MAX_TIMERS
2662#define NROS_COMPONENT_MAX_TIMERS 8
2671#if NROS_COMPONENT_MAX_TIMERS < 1
2672#error "NROS_COMPONENT_MAX_TIMERS must be >= 1: it sizes a C array (issue 1015)"
2694template <::
size_t MaxTimers = NROS_COMPONENT_MAX_TIMERS>
2697 "NodeWithTimers<0> has no pool -- derive ::rclcpp::Node directly, or use "
2698 "the out-ref create_wall_timer(Timer&, ...) family");
2701 using ::rclcpp::Node::Node;
2710 Timer*
slot = this->next_timer_slot(
"create_wall_timer_in");
2711 if (
slot ==
nullptr)
return;
2713 static_cast<C*
>(
this));
2715 this->set_error(
"create_wall_timer_in",
r.raw());
2723 void* context =
nullptr) {
2724 Timer*
slot = this->next_timer_slot(
"create_wall_timer_in");
2725 if (
slot ==
nullptr)
return;
2728 this->set_error(
"create_wall_timer_in",
r.raw());
2736 template <
class C,
void (C::*Method)()>
2738 Timer*
slot = this->next_timer_slot(
"create_timer_in_group");
2739 if (
slot ==
nullptr)
return;
2741 static_cast<C*
>(
this));
2743 this->set_error(
"create_timer_in_group",
r.raw());
2752 Timer*
slot = this->next_timer_slot(
"create_timer_in_group");
2753 if (
slot ==
nullptr)
return;
2756 this->set_error(
"create_timer_in_group",
r.raw());
2765 using ::rclcpp::Node::create_timer_in_group;
2766 using ::rclcpp::Node::create_wall_timer;
2771 Timer* next_timer_slot(
const char*
what) {
2773 this->set_error(
what, -1);
2776 return &timers_[timer_count_];
2779 Timer timers_[MaxTimers];
2780 ::size_t timer_count_ = 0;
2793 return init_in(locator, domain_id,
"node");
2812#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
2832#ifdef NROS_ENTRY_LOCATOR
2833 if (locator ==
nullptr) {
2837#ifdef NROS_ENTRY_DOMAIN_ID
2841 if (domain_id == 0) {
2872#ifdef NROS_ENTRY_RMW
2875 const char* rmw =
nullptr;
2894 sizeof(::rclcpp::Node::GlobalStorageHolder<>::storage));
2900 ::rclcpp::Node::global_storage());
2913#ifdef NROS_ENTRY_LOCATOR
2914 if (locator ==
nullptr) {
2918#ifdef NROS_ENTRY_DOMAIN_ID
2919 if (domain_id == 0) {
2933 sizeof(::rclcpp::Node::GlobalStorageHolder<>::storage));
2939 ::rclcpp::Node::global_storage());
2946 if (!::rclcpp::Node::global_initialized()) {
2947 return Result::success();
2955 if (!::rclcpp::Node::global_initialized())
return nullptr;
2956 return ::rclcpp::Node::global_storage();
2964inline int32_t apply_ros_args(
void* executor,
int argc,
char const*
const* argv) {
2967 bool scoped =
false;
2968 for (
int i = 0; argv !=
nullptr && i < argc && !scoped; ++i) {
2969 const char* a = argv[i];
2970 const char* want =
"--ros-args";
2971 while (a !=
nullptr && *a !=
'\0' && *a == *want) {
2975 scoped = a !=
nullptr && *a ==
'\0' && *want ==
'\0';
2980 char why[256] = {0};
2981 const int32_t rc = nros_cpp_install_argv_remaps(executor, argc, argv, why,
sizeof(why));
2988 RCLC_LOG_ERROR(::rclcpp::detail::log_handle(
nullptr),
"rclcpp::init: refused: %.120s",
2989 why[0] !=
'\0' ? why :
"invalid executor handle or argv");
2990 NROS_RCLCPP_SAY_REFUSED(NROS_RCLCPP_REFUSE_INIT_ARGV);
2998inline Result init_honouring_ros_args(
int argc,
char const*
const* argv,
const char* name) {
2999 const int32_t checked = apply_ros_args(
nullptr, argc, argv);
3008 if (installed != 0) {
3010 return Result(installed);
3023 return detail::init_honouring_ros_args(
argc,
argv,
name);
3032 return ::rclcpp::Node::global_initialized() && !::nros_cpp_termination_requested();
3044 if (!::rclcpp::Node::global_initialized()) {
3045 return Result(ErrorCode::NotInitialized);
3047 out.executor_handle_ = ::rclcpp::Node::global_storage();
3048 return ::rclcpp::Node::create(
out,
name,
ns);
3064 const char*
ns =
nullptr) {
3065 if (executor_handle ==
nullptr) {
3066 return Result(ErrorCode::NotInitialized);
3068 out.executor_handle_ = executor_handle;
3069 return ::rclcpp::Node::create(
out,
name,
ns);
3085 if (!initialized_)
return Result(ErrorCode::NotInitialized);
3086 out.executor_handle_ = storage_;
3087 return ::rclcpp::Node::create(
out,
name,
ns);
3110 : executor_handle_(executor_handle), name_(
name),
3132 options_.domain_id_override =
id;
3149 options_.sched_context_id =
sc_id;
3155 if (!executor_handle_)
return Result(ErrorCode::NotInitialized);
3156 out.executor_handle_ = executor_handle_;
3160 out.initialized_ =
true;
3168 if (
src !=
nullptr) {
3169 while (
src[
n] !=
'\0' &&
n <
cap) {
3175 for (
size_t i = n; i < cap; ++i) {
3181 void* executor_handle_;
3183 nros_cpp_node_options_t options_;
3198 const char*
missing =
nullptr;
3201 report_callback_group_mismatch(
node.get_name(),
"declared",
missing, len,
groups.list);
3202 node.set_error(
"a CALLBACK_GROUPS group was never created",
Definition client.hpp:129
Definition guard_condition.hpp:50
NodeBuilder & locator(const char *loc)
Definition node.hpp:3124
NodeBuilder & sched(uint8_t sc_id)
Definition node.hpp:3148
Result build(::rclcpp::Node &out) const
Materialize the Node.
Definition node.hpp:3154
NodeBuilder(void *executor_handle, const char *name)
Definition node.hpp:3109
NodeBuilder & rmw(const char *name)
Definition node.hpp:3117
NodeBuilder & domain_id(uint32_t id)
Definition node.hpp:3131
NodeBuilder & namespace_(const char *ns)
Definition node.hpp:3141
void create_timer_in_group(const CallbackGroup &group, uint64_t period_ms)
Definition node.hpp:2737
void create_timer_in_group(const CallbackGroup &group, uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
The plain C callback + ctx form, in a group, parked in the pool.
Definition node.hpp:2750
void create_wall_timer_in(uint64_t period_ms)
Definition node.hpp:2709
void create_wall_timer_in(uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
The plain C callback + ctx escape hatch, parked in the pool.
Definition node.hpp:2722
Node & operator=(Node &&other)
Definition node.hpp:2498
bool check_declared_depth(const char *type_name, const char *topic, const ::rclcpp::QoS &qos)
Definition node.hpp:2342
Result create_subscription(::rclcpp::PollSubscription< M > &out, const char *topic, const ::rclcpp::QoS &qos, const ::rclcpp::SubscriptionOptions &options)
Result create_client(::rclcpp::PollClient< S > &out, const char *service_name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
void create_subscription_in(const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
Result create_timer(Timer &out, const Clock &clock, uint64_t period_ms, C *self)
Definition node.hpp:2093
Result create_subscription_in_group(const ::rclcpp::CallbackGroup &group, ::rclcpp::Subscription< M > &out, const char *topic, const ::rclcpp::QoS &qos, F callback, const ::rclcpp::SubscriptionOptions &options={})
const nros_cpp_node_t * ffi_handle() const
Definition node.hpp:1475
Result count_subscribers(const char *topic_name, size_t *out_count) const
Definition node.hpp:1584
SharedPtr shared_from_this()
Definition node.hpp:918
Result create_timer(Timer &out, const Clock &clock, uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
Definition node.hpp:2002
Time now() const
Definition node.hpp:1455
Result create_subscription(::rclcpp::PollSubscription< M > &out, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
Result create_service(::rclcpp::Service< S > &out, const char *service_name, F callback, const ::rclcpp::QoS &qos=::rclcpp::QoS::services(), const ::rclcpp::ServiceOptions &options={})
const char * error_what() const
Definition node.hpp:823
Result get_parameter_types(const char *const *names, ::size_t count, ParameterType *out) const
Definition rclcpp.hpp:1338
Result create_publisher(::rclcpp::Publisher< M > &out, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
typename::rclcpp::Service< S >::SharedPtr create_service(const char *, F, const ::rclcpp::QoS &=::rclcpp::QoS::services())
Result create_polling_action_client(::rclcpp::PollingActionClient< A > &out, const char *action_name)
Phase 122.3.d.b — Create an L1 polling-mode action client.
typename::rclcpp::Subscription< M >::SharedPtr create_subscription(const char *topic, ::size_t depth, Cb cb)
create_subscription<M>(topic, depth, callback).
::rclcpp::Handle< const Node > ConstSharedPtr
rclcpp::Node::ConstSharedPtr.
Definition node.hpp:905
Result create_timer_in_group(const ::rclcpp::CallbackGroup &group, Timer &out, uint64_t period_ms, C *self)
Definition node.hpp:2101
Node(const char *name, const char *ns, const ::rclcpp::NodeOptions &options)
Definition node.hpp:864
Result create_client(::rclcpp::Client< S > &out, const char *service_name, F callback, const ::rclcpp::QoS &qos=::rclcpp::QoS::services(), const ::rclcpp::ClientOptions &options={})
::rclcpp::Logger get_logger() const
Definition node.hpp:1428
Result create_service(::rclcpp::PollService< S > &out, const char *service_name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
Result create_subscription(::rclcpp::Subscription< M > &out, const char *topic, const ::rclcpp::QoS &qos, F callback, const ::rclcpp::SubscriptionOptions &options={})
::rclcpp::Owned<::rclcpp::PollService< S > > create_service(const char *name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
Result create_subscription_with_info(::rclcpp::Subscription< M > &out, const char *topic, const ::rclcpp::QoS &qos, F callback, const ::rclcpp::SubscriptionOptions &options={})
bool get_parameter(const char *name, T &out) const
Definition rclcpp.hpp:1257
typename::rclcpp::Subscription< M >::SharedPtr create_subscription(const char *topic, const ::rclcpp::QoS &qos, Cb cb)
Result create_wall_timer(Timer &out, uint64_t period_ms, C *self)
Definition node.hpp:2081
Result get_node_names(nros_cpp_node_visit_fn visit, void *ctx) const
Definition node.hpp:1544
Result init(const char *name, const char *ns=nullptr)
Definition node.hpp:734
typename::rclcpp::Publisher< M >::SharedPtr create_publisher(const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
create_publisher<M>(topic, qos) — available on every target.
::rclcpp::TimerHandle create_wall_timer(::rclcpp::Duration period, Cb cb)
bool check_declared_param(const char *name, int passed_type)
Definition node.hpp:2425
Result describe_parameter(const char *name, ParameterDescriptor &out, char *text, ::size_t text_len) const
Definition rclcpp.hpp:1349
T declare_parameter(const char *name, T default_value=T())
rclcpp::Node::declare_parameter<T>(name, default).
Definition rclcpp.hpp:1234
const char * serialization_format() const
Definition node.hpp:1400
~Node()
Definition node.hpp:2478
static Result create(Node &out, const char *name, const char *ns=nullptr)
Definition node.hpp:1339
bool get_parameter_or(const char *name, T &out, T fallback) const
Definition rclcpp.hpp:1318
ParameterType get_parameter_type(const char *name) const
Definition rclcpp.hpp:1330
bool ok() const
Definition node.hpp:819
bool has_parameter(const char *name) const
rclcpp::Node::has_parameter(name).
Definition rclcpp.hpp:1289
void * executor_handle() const
Definition node.hpp:1499
Result list_parameters(const char *prefix, char *out_names, ::size_t name_stride, ::size_t max_names, ::size_t &count) const
Definition rclcpp.hpp:1387
::rclcpp::Publisher< M > create_publisher_in(const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
Definition node.hpp:2293
Result get_publishers_info_by_topic(const char *topic_name, ::rclcpp::TopicEndpointInfoVisitFn visit, void *ctx) const
Definition node.hpp:1670
::rclcpp::Handle< Node > SharedPtr
Definition node.hpp:903
typename::rclcpp::Service< S >::SharedPtr create_service(const char *name, F callback, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
Callback-style service server (void(const S::Request&, S::Response&)).
Node(Node &&other)
Definition node.hpp:2486
Node(const char *name, const ::rclcpp::NodeOptions &options)
Definition node.hpp:857
Result create_guard_condition(::rclcpp::GuardCondition &out, nros_cpp_guard_callback_t callback, void *context=nullptr)
Definition node.hpp:2241
const char * get_namespace() const
Get the node namespace.
Definition node.hpp:1359
bool initialized() const
Definition node.hpp:925
void set_error(const char *what, int32_t code)
Definition node.hpp:2457
Node & nros_node()
Definition node.hpp:929
Result get_client_names_and_types_by_node(const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) const
Definition node.hpp:1633
Result count_publishers(const char *topic_name, size_t *out_count) const
Definition node.hpp:1577
Result start_parameter_services()
Definition node.hpp:1507
int32_t error_code() const
The raw error code of the first latched failure, or 0.
Definition node.hpp:830
const char * get_name() const
Get the node name.
Definition node.hpp:1353
bool is_valid() const
Check if the node is initialized and valid.
Definition node.hpp:1458
Result create_wall_timer(Timer &out, uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
Definition node.hpp:2048
Result remove_on_set_parameters_callback(ParameterCallbackHandle handle)
rclcpp::Node::remove_on_set_parameters_callback(handle).
Definition rclcpp.hpp:1404
Result create_timer_in_group(const ::rclcpp::CallbackGroup &group, Timer &out, uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
Definition node.hpp:2174
::rclcpp::CallbackGroup create_callback_group(const char *name)
Definition node.hpp:2146
Node(::rclcpp::NodeHandle handle, const char *name, const char *ns=nullptr)
Definition node.hpp:779
Node(const char *name, const char *ns=nullptr)
Definition node.hpp:724
Result set_parameters_atomically(const ParameterWrite *writes, ::size_t count)
Definition rclcpp.hpp:1393
::rclcpp::Owned<::rclcpp::PollClient< S > > create_client(const char *name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
typename::rclcpp::Publisher< M >::SharedPtr create_publisher(const char *topic, ::size_t depth)
create_publisher<M>(topic, depth) — the integer-depth spelling.
Result get_subscription_names_and_types_by_node(const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) const
Definition node.hpp:1610
bool check_declared_qos(const char *type_name, const char *topic, const ::rclcpp::QoS &qos)
Definition node.hpp:2375
Result create_timer_oneshot(Timer &out, uint64_t delay_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
Definition node.hpp:2115
Result get_service_names_and_types(nros_cpp_names_and_types_visit_fn visit, void *ctx) const
Definition node.hpp:1564
Result get_topic_names_and_types(nros_cpp_names_and_types_visit_fn visit, void *ctx) const
Definition node.hpp:1556
Result set_parameter(const char *name, T value)
Definition rclcpp.hpp:1281
const Clock * get_clock() const
Const overload of get_clock().
Definition node.hpp:1446
Result get_fully_qualified_name(char *buf, size_t buf_len, size_t *out_len=nullptr) const
Definition node.hpp:1378
Result get_subscriptions_info_by_topic(const char *topic_name, ::rclcpp::TopicEndpointInfoVisitFn visit, void *ctx) const
Definition node.hpp:1693
typename::rclcpp::Client< S >::SharedPtr create_client(const char *, F, const ::rclcpp::QoS &=::rclcpp::QoS::services())
REFUSED — upstream's shared_ptr handler shape.
Result create_polling_action_server(::rclcpp::PollingActionServer< A > &out, const char *action_name)
Clock * get_clock()
Definition node.hpp:1444
const Node & nros_node() const
Const overload of [nros_node].
Definition node.hpp:931
Result get_publisher_names_and_types_by_node(const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) const
Definition node.hpp:1592
Result get_publishers_info_by_topic(const char *topic_name, nros_cpp_endpoint_info_visit_fn visit, void *ctx) const
Definition node.hpp:1655
void create_subscription_in_group(const ::rclcpp::CallbackGroup &group, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
Node()
Definition node.hpp:707
Result create_publisher_in_group(const ::rclcpp::CallbackGroup &, ::rclcpp::Publisher< M > &out, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
Definition node.hpp:2228
Result undeclare_parameter(const char *name)
Definition rclcpp.hpp:1326
const ::rclcpp::NodeOptions & get_node_options() const
Definition node.hpp:871
Result create_publisher(::rclcpp::Publisher< M > &out, const char *topic, const ::rclcpp::QoS &qos, const ::rclcpp::PublisherOptions &options)
Result create_polling_subscription(::rclcpp::PollingSubscription< M > &out, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
ConstSharedPtr shared_from_this() const
Const overload of [shared_from_this].
Definition node.hpp:920
void set_qos_overrides(const nros_cpp_qos_override_t *overrides, size_t len)
Definition node.hpp:1487
Result add_on_set_parameters_callback(OnSetParametersCallbackType callback, void *context, ParameterCallbackHandle &out_handle)
Definition rclcpp.hpp:1397
Result init_on(void *executor_handle, const char *name, const char *ns=nullptr)
Definition node.hpp:745
Result get_subscriptions_info_by_topic(const char *topic_name, nros_cpp_endpoint_info_visit_fn visit, void *ctx) const
Definition node.hpp:1683
Result get_service_names_and_types_by_node(const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) const
Definition node.hpp:1622
typename::rclcpp::Client< S >::SharedPtr create_client(const char *name, F callback, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
Callback-style service client (void(const S::Response&)).
static constexpr QoS services()
Services profile: RELIABLE + VOLATILE + KEEP_LAST(10).
Definition qos.hpp:720
static constexpr QoS default_profile()
Default profile: RELIABLE + VOLATILE + KEEP_LAST(10).
Definition qos.hpp:714
Definition result.hpp:216
int32_t raw() const
Get the raw integer code (for FFI interop).
Definition result.hpp:235
Definition result.hpp:331
Definition server.hpp:340
rclcpp::Executor — drives transport I/O and dispatches callbacks.
int nros_cpp_ret_t
Definition future.hpp:21
rclcpp::GuardCondition — cross-thread wake source.
void report_declared_depth_mismatch(const char *node_name, const char *topic, int declared, int passed)
Definition node.hpp:368
const char * declared_reliability_spelling(int ordinal)
The contract spelling of a reliability ordinal, for the report above.
Definition node.hpp:462
void report_declared_policy_mismatch(const char *node_name, const char *topic, const char *policy, const char *declared, const char *passed)
Definition node.hpp:438
void report_component_failure(const char *node_name, const char *what, int32_t code)
Definition node.hpp:339
constexpr int32_t DECLARED_PARAM_MISMATCH
Definition node.hpp:479
const char * declared_durability_spelling(int ordinal)
The contract spelling of a durability ordinal, for the report above.
Definition node.hpp:470
constexpr int32_t DECLARED_DEPTH_MISMATCH
Definition node.hpp:363
void report_callback_group_mismatch(const char *node_name, const char *how, const char *name, int len, const char *list)
Definition node.hpp:397
void report_declared_param_mismatch(const char *fqn, const char *param, const char *contract, int declared, int passed)
Definition node.hpp:485
constexpr int32_t DECLARED_QOS_MISMATCH
Definition node.hpp:433
constexpr uint8_t kDomainIdExplicitZero
Definition node.hpp:325
Result shutdown_in()
Definition node.hpp:2945
inline ::rclcpp::TimerHandle create_timer(NodeT &&node, ::rclcpp::Clock *clock, ::rclcpp::Duration period, CallbackT &&callback)
Definition rclcpp.hpp:1156
Result create_node(::rclcpp::Node &out, const char *name, const char *ns)
Definition node.hpp:3043
Result init_in(const char *locator=nullptr, uint8_t domain_id=0)
Definition node.hpp:2785
ResultOf< void > Result
Definition result.hpp:246
Result spin_once(int32_t timeout_ms=10)
Definition rclcpp.hpp:97
void init()
rclcpp::init() — the zero-argument form. ADOPT.
Definition rclcpp.hpp:400
bool ok()
Definition node.hpp:3031
Result spin_in()
Definition rclcpp.hpp:192
Result create_node_on(::rclcpp::Node &out, void *executor_handle, const char *name, const char *ns)
Definition node.hpp:3063
ResultOf<::rclcpp::Node > make_node(const char *name, const char *ns=nullptr)
Definition node.hpp:3075
void * global_handle()
Definition node.hpp:2954
@ AlreadyExists
Already exists (duplicate declare/register).
Result init_with_rmw(const char *rmw, const char *locator=nullptr, uint8_t domain_id=0, const char *session_name="node")
Definition node.hpp:2906
rclcpp::QoS — full DDS-shaped QoS settings (Phase 108.B.7).
rclcpp::Result, rclcpp::ErrorCode, and the RCLCPP_TRY macro.
constexpr const char * resolve_namespace(const char *fallback) const
The launch namespace if one was declared, else fallback.
Definition node.hpp:307
constexpr bool valid() const
Definition node.hpp:299
constexpr NodeHandle()
Definition node.hpp:281
const char * launch_name
Definition node.hpp:264
void * executor
Definition node.hpp:260
constexpr NodeHandle(void *exec)
Definition node.hpp:284
const char * launch_namespace
Launch-declared namespace, same contract.
Definition node.hpp:266
const nros_cpp_qos_override_t * qos_overrides
Definition node.hpp:277
constexpr const char * resolve_name(const char *fallback) const
Definition node.hpp:303
constexpr NodeHandle(void *exec, const char *name, const char *ns, const nros_cpp_qos_override_t *overrides, size_t override_count)
Definition node.hpp:295
constexpr NodeHandle(void *exec, const char *name, const char *ns)
Definition node.hpp:289
size_t qos_override_count
Entries in qos_overrides; 0 = none.
Definition node.hpp:279
rclcpp::Timer — periodic callback driven by the executor.