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"
116#include "rclcpp/parameter_value.hpp"
117#include "rclcpp/logging.hpp"
122#include "rclcpp/graph.hpp"
124#include "rclcpp/callback_group.hpp"
133#include "rclcpp/parameter.hpp"
138#include "rclcpp/detail/std_detect.hpp"
143struct rmw_request_id_t;
173static_assert(NROS_CPP_RET_NOT_FOUND == -4 && NROS_CPP_RET_ALREADY_EXISTS == -5 &&
174 NROS_CPP_RET_FULL == -6 && NROS_CPP_RET_NOT_INIT == -7 &&
175 NROS_CPP_RET_TRY_AGAIN == -14 && NROS_CPP_RET_REENTRANT == -15 &&
176 NROS_CPP_RET_UNSUPPORTED == -16,
177 "nros_cpp_ret_t diverged from the shared numbering (issue #229)");
196template <
typename S>
class Service;
198class GenericPublisher;
199class GenericSubscription;
204template <
typename A>
class Server;
205template <
typename A>
class Client;
248 explicit operator bool()
const {
return node_ !=
nullptr; }
286class NodeParametersInterface {
288 using SharedPtr = NodeParametersInterface;
289 NodeParametersInterface() : node_(nullptr) {}
290 explicit NodeParametersInterface(
Node* node) : node_(node) {}
291 NodeParametersInterface* operator->() {
return this; }
292 const NodeParametersInterface* operator->()
const {
return this; }
293 explicit operator bool()
const {
return node_ !=
nullptr; }
294 Node* node()
const {
return node_; }
296 inline bool has_parameter(const ::std::string& name)
const;
297 inline ParameterValue declare_parameter(const ::std::string& name,
298 const ParameterValue& default_value);
299 template <
typename D>
300 inline ParameterValue declare_parameter(const ::std::string& name,
301 const ParameterValue& default_value,
302 const D& descriptor);
303 inline bool get_parameter(const ::std::string& name, Parameter& out)
const;
304 inline Parameter get_parameter(const ::std::string& name)
const;
305 inline const ::std::map<::std::string, ParameterValue>& get_parameter_overrides()
const;
320struct OnSetParametersCallbackHandle {
321 using SharedPtr = ::std::shared_ptr<OnSetParametersCallbackHandle>;
322 using WeakPtr = ::std::weak_ptr<OnSetParametersCallbackHandle>;
326 using OnParametersSetCallbackType = ::std::function<bool(const ::std::vector<Parameter>&)>;
328 OnSetParametersCallbackHandle() : node(nullptr), token(0), registered(false) {}
329 OnSetParametersCallbackHandle(
const OnSetParametersCallbackHandle&) =
delete;
330 OnSetParametersCallbackHandle&
operator=(
const OnSetParametersCallbackHandle&) =
delete;
331 ~OnSetParametersCallbackHandle() { unregister(); }
336 (void)::rclcpp::detail::node_param_remove_on_set_callback(node, token);
342 static bool trampoline(
const ParameterWrite* write,
void* context) {
343 auto* self =
static_cast<OnSetParametersCallbackHandle*
>(context);
344 if (write ==
nullptr || self ==
nullptr || !self->callback) {
347 ::std::vector<Parameter> params;
348 params.push_back(Parameter::from_write(*write));
349 return self->callback(params);
352 OnParametersSetCallbackType callback;
353 const nros_cpp_node_t* node;
354 OnSetParametersCallbackToken token;
430 constexpr NodeHandle(
void* exec,
const char* name,
const char* ns)
436 constexpr NodeHandle(
void* exec,
const char* name,
const char* ns,
437 const nros_cpp_qos_override_t* overrides,
size_t override_count)
488 NROS_ERROR(
"node \"%s\": FAILED at %s (code=%d)", (node_name !=
nullptr) ? node_name :
"?",
489 (what !=
nullptr) ? what :
"?",
static_cast<int>(code));
490#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
491 ::fprintf(stderr,
"[nros] FATAL: node \"%s\" failed to construct at %s (code=%d)\n",
492 (node_name !=
nullptr) ? node_name :
"?", (what !=
nullptr) ? what :
"?",
493 static_cast<int>(code));
511 NROS_ERROR(
"node \"%s\": topic \"%s\" DECLARED depth %d but the QoS "
512 "passed states %d. Depth multiplies the executor arena, so they must agree.",
513 (node_name !=
nullptr) ? node_name :
"?", (topic !=
nullptr) ? topic :
"?", declared,
515#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
517 "[nros] FATAL: node \"%s\": topic \"%s\" was DECLARED depth %d in "
518 "the contract sidecar (<stem>.contract.yaml) but the QoS passed to "
519 "create_subscription_in states depth %d. Depth multiplies the executor "
520 "arena (cost is (depth+1)*bound per subscription), so the two must agree. "
521 "Fix the contract row or the call site.\n",
522 (node_name !=
nullptr) ? node_name :
"?", (topic !=
nullptr) ? topic :
"?", declared,
539 int len,
const char* list) {
540 const char* node = (node_name !=
nullptr) ? node_name :
"?";
541 const char* group = (name !=
nullptr) ? name :
"?";
542 const char* declared = (list !=
nullptr) ? list :
"";
545 const bool created = (how !=
nullptr && how[0] ==
'c');
547 NROS_ERROR(
"node \"%s\": created callback group \"%.*s\", not in CALLBACK_GROUPS \"%s\"",
548 node, len, group, declared);
550 NROS_ERROR(
"node \"%s\": CALLBACK_GROUPS \"%s\" declares \"%.*s\", never created", node,
551 declared, len, group);
553#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
555 created ?
"[nros] FATAL: node \"%s\" created callback group \"%.*s\", which its "
556 "registration's CALLBACK_GROUPS \"%s\" does not declare.\n"
557 :
"[nros] FATAL: node \"%s\" never created callback group \"%.*s\", which "
558 "its registration's CALLBACK_GROUPS \"%s\" declares.\n",
559 node, len, group, declared);
561 " The tier derivation ranks the declared list and the executor binds what the "
562 "code creates, so the two must name the same groups (ONE declared group and none "
563 "created is node-level placement, and is allowed). Fix the "
564 "nano_ros_node_register(... CALLBACK_GROUPS ...) line or the create_callback_group "
580 const char* policy,
const char* declared,
581 const char* passed) {
582 NROS_ERROR(
"node \"%s\": topic \"%s\" DECLARED %s %s but the QoS passed states %s. An "
583 "incompatible-QoS match never delivers, so they must agree.",
584 (node_name !=
nullptr) ? node_name :
"?", (topic !=
nullptr) ? topic :
"?", policy,
586#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
588 "[nros] FATAL: node \"%s\": topic \"%s\" was DECLARED %s %s in the contract "
589 "sidecar (<stem>.contract.yaml) but the QoS passed to create_subscription_in "
590 "states %s. Fix the contract row or the call site.\n",
591 (node_name !=
nullptr) ? node_name :
"?", (topic !=
nullptr) ? topic :
"?", policy,
627 int declared,
int passed) {
628 const char* f = (fqn !=
nullptr) ? fqn :
"?";
629 const char* p = (param !=
nullptr) ? param :
"?";
630 const char* c = (contract !=
nullptr) ? contract :
"?";
631 if (declared == ::rclcpp::DECLARED_PARAM_UNDECLARED) {
632 NROS_ERROR(
"node \"%s\": parameter \"%s\" is not declared in its contract (%s).", f, p, c);
634 NROS_ERROR(
"node \"%s\": parameter \"%s\" is declared %s in its contract (%s) but the "
635 "code declares it as %s.",
636 f, p, ::rclcpp::declared_param_type_name(declared), c,
637 ::rclcpp::declared_param_type_name(passed));
639#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
640 if (declared == ::rclcpp::DECLARED_PARAM_UNDECLARED) {
642 "[nros] FATAL: node \"%s\": parameter \"%s\" is not declared in its "
643 "contract (%s, `params:`). The parameter store is sized from that "
644 "declaration, so a parameter it does not name has no slot. Declare it "
645 "there with its type, or stop declaring it in the code.\n",
649 "[nros] FATAL: node \"%s\": parameter \"%s\" is declared `%s` in its "
650 "contract (%s) but the code declares it as `%s`. Fix the contract or "
651 "the code so they state one type.\n",
652 f, p, ::rclcpp::declared_param_type_name(declared), c,
653 ::rclcpp::declared_param_type_name(passed));
678inline Result init_in(
const char* locator =
nullptr, uint8_t domain_id = 0);
699inline Result init_in(
const char* locator, uint8_t domain_id,
const char* session_name);
719inline Result init_in(
const char* locator, uint8_t domain_id,
const char* session_name,
720 const char* node_namespace);
739inline Result init_with_rmw(
const char* rmw,
const char* locator =
nullptr, uint8_t domain_id = 0,
740 const char* session_name =
"node");
764inline Result init_in(
int argc,
char const*
const* argv,
const char* session_name =
nullptr);
769inline Result shutdown_in();
779inline Result create_node(
::rclcpp::Node& out,
const char* name,
const char* ns);
780inline Result create_node_on(
::rclcpp::Node& out,
void* executor_handle,
const char* name,
782inline Result spin_once(int32_t timeout_ms);
783inline Result spin_in();
784inline Result spin_in(uint32_t duration_ms, int32_t poll_ms);
785inline void* global_handle();
849 Node() : handle_(), initialized_(false), executor_handle_(nullptr), clock_(RCL_ROS_TIME) {}
866 explicit Node(
const char* name,
const char* ns =
nullptr)
867 : handle_(), initialized_(false), executor_handle_(nullptr), clock_(RCL_ROS_TIME) {
868 (void)this->
init(name, ns);
869#if defined(NROS_AMENT_START_PARAMETER_SERVICES)
887 executor_handle_ = Node::global_storage();
930 : handle_(), initialized_(false), executor_handle_(nullptr), clock_(RCL_ROS_TIME) {
932 this->set_error(
"ctor (null executor handle)", -1);
936 this->init_on(
handle.executor,
handle.resolve_name(name),
handle.resolve_namespace(ns));
938 this->set_error(
"node create", r.raw());
945 if (
handle.qos_overrides !=
nullptr &&
handle.qos_override_count != 0) {
946 nros_cpp_ret_t qrc = ::nros_cpp_node_set_qos_overrides(&handle_, handle.qos_overrides,
947 handle.qos_override_count);
948 if (qrc != NROS_CPP_RET_OK) {
949 this->set_error(
"set_qos_overrides", static_cast<int32_t>(qrc));
969 bool ok()
const {
return initialized_ && !__atomic_load_n(&has_error_, __ATOMIC_ACQUIRE); }
976 (void)__atomic_load_n(&has_error_, __ATOMIC_ACQUIRE);
981 (void)__atomic_load_n(&has_error_, __ATOMIC_ACQUIRE);
1008 Node(
const char* name, const ::rclcpp::NodeOptions& options) :
Node(name, nullptr) {
1009 apply_options_(options);
1015 Node(
const char* name,
const char* ns, const ::rclcpp::NodeOptions& options) :
Node(name, ns) {
1016 apply_options_(options);
1024#ifdef NROS_CPP_HAS_STD_STRING
1026 explicit Node(const ::std::string& name) : Node(name.c_str(), nullptr) {}
1029 Node(const ::std::string& name, const ::rclcpp::NodeOptions& options)
1030 :
Node(name.c_str(), options) {}
1033 Node(const ::std::string& name, const ::std::string& ns,
1034 const ::rclcpp::NodeOptions& options = ::rclcpp::NodeOptions())
1035 : Node(name.c_str(), ns.c_str(), options) {}
1080 return ::rclcpp::node_interfaces::NodeBaseInterface(
this);
1084 return ::rclcpp::node_interfaces::NodeClockInterface(
this);
1088 return ::rclcpp::node_interfaces::NodeGraphInterface(
this);
1092 return ::rclcpp::node_interfaces::NodeLoggingInterface(
this);
1096 return ::rclcpp::node_interfaces::NodeWaitablesInterface(
this);
1099#if defined(NROS_CPP_HAS_SHARED_PTR)
1114 template <typename... Args> static ::std::shared_ptr<Node> make_shared(Args&&... args) {
1115 return ::std::make_shared<Node>(
static_cast<Args&&
>(args)...);
1119 template <
typename... Args> static ::std::unique_ptr<Node> make_unique(Args&&... args) {
1120 return ::std::unique_ptr<Node>(
new Node(
static_cast<Args&&
>(args)...));
1135#ifdef NROS_CPP_HAS_STD_STRING
1143 template <
typename M>
1144 typename ::rclcpp::Publisher<M>::SharedPtr
create_publisher(const ::std::string& topic,
1145 const ::rclcpp::QoS& qos);
1148 template <
typename M>
1149 typename ::rclcpp::Publisher<M>::SharedPtr
create_publisher(const ::std::string& topic,
1154 template <
typename M,
typename Cb>
1155 typename ::rclcpp::Subscription<M>::SharedPtr
1156 create_subscription(const ::std::string& topic, const ::rclcpp::QoS& qos, Cb cb);
1159 template <
typename M,
typename Cb>
1160 typename ::rclcpp::Subscription<M>::SharedPtr create_subscription(const ::std::string& topic,
1161 ::size_t depth, Cb cb);
1164 template <
typename M,
typename Cb>
1165 typename ::rclcpp::Subscription<M>::SharedPtr
1166 create_subscription(const ::std::string& topic, const ::rclcpp::QoS& qos, Cb cb,
1167 const ::rclcpp::SubscriptionOptions& options) {
1168 return this->create_subscription<M>(topic.c_str(), qos, ::rclcpp::tr::forward_rvalue(cb),
1173 template <
typename M,
typename Cb>
1174 typename ::rclcpp::Subscription<M>::SharedPtr
1175 create_subscription(const ::std::string& topic, ::size_t depth, Cb cb,
1176 const ::rclcpp::SubscriptionOptions& options) {
1177 return this->create_subscription<M>(topic.c_str(), depth, ::rclcpp::tr::forward_rvalue(cb),
1191 template <
typename S>
1192 ::rclcpp::Owned<::rclcpp::PollService<S>>
1196 template <
typename S,
typename F,
1197 typename =
typename std::enable_if<std::is_convertible<
1198 F, void (*)(
const typename S::Request&,
typename S::Response&)>::value>::type>
1199 typename ::rclcpp::Service<S>::SharedPtr
1200 create_service(const ::std::string& name, F callback,
1208 template <
typename S,
typename F,
1209 typename =
typename std::enable_if<
1211 !std::is_convertible<F, void (*)(
const typename S::Request&,
1212 typename S::Response&)>::value>::type,
1214 typename ::rclcpp::Service<S>::SharedPtr
1218 template <
typename S,
typename F>
1219 typename ::rclcpp::Service<S>::SharedPtr create_service(const ::std::string& name, F callback,
1220 const ::rclcpp::QoS& qos,
1221 const ::rclcpp::CallbackGroup* group) {
1222 return this->
template create_service<S>(name.c_str(),
1223 ::rclcpp::tr::forward_rvalue(callback), qos, group);
1242 template <
typename S>
1243 ::rclcpp::Owned<::rclcpp::PollClient<S>>
1247 template <
typename S,
typename F,
1248 typename =
typename std::enable_if<
1249 std::is_convertible<F, void (*)(
const typename S::Response&)>::value>::type>
1250 typename ::rclcpp::Client<S>::SharedPtr
1251 create_client(const ::std::string& name, F callback,
1255 template <
typename S,
typename F,
1256 typename =
typename std::enable_if<
1258 !std::is_convertible<F, void (*)(
const typename S::Response&)>::value>::type,
1260 typename ::rclcpp::Client<S>::SharedPtr
1288 template <
typename M>
1289 typename ::rclcpp::Publisher<M>::SharedPtr
1294 template <
typename M>
1295 typename ::rclcpp::Publisher<M>::SharedPtr
create_publisher(
const char* topic, ::size_t depth);
1305 template <
typename M,
typename Cb>
1306 typename ::rclcpp::Subscription<M>::SharedPtr
1310 template <
typename M,
typename Cb>
1312 ::size_t depth, Cb cb);
1320 template <
typename M,
typename Cb>
1321 typename ::rclcpp::Subscription<M>::SharedPtr
1323 const ::rclcpp::SubscriptionOptions& options);
1326 template <
typename M,
typename Cb>
1327 typename ::rclcpp::Subscription<M>::SharedPtr
1329 const ::rclcpp::SubscriptionOptions& options);
1340 ::rclcpp::Owned<::rclcpp::GenericPublisher>
1347 template <
typename Cb>
1350 const ::rclcpp::QoS& qos, Cb callback);
1354 template <
typename A,
typename B,
typename... R>
1360 static_assert(::rclcpp::detail::refuse<A>::value, NROS_RCLCPP_REFUSE_GENERIC_BY_NAME);
1365 template <
typename A,
typename B,
typename Cb,
typename... R>
1367 Cb&& callback,
const R&...) {
1372 static_assert(::rclcpp::detail::refuse<A>::value, NROS_RCLCPP_REFUSE_GENERIC_BY_NAME);
1377 template <
typename S>
1378 ::rclcpp::Owned<::rclcpp::PollService<S>>
1382 template <
typename S,
typename F,
1383 typename = typename ::rclcpp::tr::enable_if<::rclcpp::tr::is_convertible<
1384 F, void (*)(
const typename S::Request&,
typename S::Response&)>::value>::type>
1385 typename ::rclcpp::Service<S>::SharedPtr
1394 template <
typename S,
typename F,
1395 typename = typename ::rclcpp::tr::enable_if<
1397 !::rclcpp::tr::is_convertible<F, void (*)(
const typename S::Request&,
1398 typename S::Response&)>::value>::type,
1400 typename ::rclcpp::Service<S>::SharedPtr
1409 template <
typename S,
typename F>
1410 typename ::rclcpp::Service<S>::SharedPtr
create_service(
const char* name, F callback,
1411 const ::rclcpp::QoS& qos,
1412 const ::rclcpp::CallbackGroup* group);
1416 template <
typename S>
1417 ::rclcpp::Owned<::rclcpp::PollClient<S>>
1421 template <
typename S,
typename F,
1422 typename = typename ::rclcpp::tr::enable_if<::rclcpp::tr::is_convertible<
1423 F, void (*)(
const typename S::Response&)>::value>::type>
1424 typename ::rclcpp::Client<S>::SharedPtr
1430 typename S,
typename F,
1431 typename = typename ::rclcpp::tr::enable_if<
1433 !::rclcpp::tr::is_convertible<F, void (*)(
const typename S::Response&)>::value>::type,
1435 typename ::rclcpp::Client<S>::SharedPtr
1467 template <
typename T> T
declare_parameter(
const char* name, T default_value = T());
1470 template <
typename T>
bool get_parameter(
const char* name, T& out)
const;
1472 template <
typename T> T
get_parameter(
const char* name)
const;
1497 template <
typename T>
1498 T
declare_parameter(
const char* name, T default_value,
const ParameterDescriptor& descriptor);
1503 template <
typename T>
bool get_parameter_or(
const char* name, T& out, T fallback)
const;
1530 ::size_t text_len)
const;
1540 ::size_t max_names, ::size_t& count)
const;
1561 OnSetParametersCallbackToken& out_handle);
1578 ParameterValue
declare_parameter(
const char* name,
const ParameterValue& default_value);
1580 ParameterValue
declare_parameter(
const char* name,
const ParameterValue& default_value,
1581 const ParameterDescriptor& descriptor);
1586 template <
typename D,
typename = decltype(&D::
floating_po
int_range)>
1587 ParameterValue
declare_parameter(
const char* name,
const ParameterValue& default_value,
1588 const D& descriptor);
1590 template <
typename T,
typename D,
typename = decltype(&D::
floating_po
int_range)>
1593 const ParameterValue& default_value) {
1596 ParameterValue declare_parameter(const ::std::string& name,
const ParameterValue& default_value,
1597 const ParameterDescriptor& descriptor) {
1598 return this->declare_parameter(name.c_str(), default_value, descriptor);
1600 template <
typename D,
typename = decltype(&D::
floating_po
int_range)>
1601 ParameterValue declare_parameter(const ::std::string& name,
const ParameterValue& default_value,
1602 const D& descriptor) {
1603 return this->declare_parameter(name.c_str(), default_value, descriptor);
1605 template <
typename T,
typename D,
typename = decltype(&D::
floating_po
int_range)>
1606 T declare_parameter(const ::std::string& name, T default_value,
const D& descriptor) {
1607 return this->declare_parameter(name.c_str(), default_value, descriptor);
1612 Parameter get_parameter(const ::std::string& name)
const;
1614 bool get_parameter(
const char* name, Parameter& out)
const;
1615 bool get_parameter(const ::std::string& name, Parameter& out)
const {
1616 return this->get_parameter(name.c_str(), out);
1619 ::std::vector<Parameter> get_parameters(const ::std::vector<::std::string>& names)
const;
1625 struct SetParametersOutcome {
1627 ::std::string reason;
1631 SetParametersOutcome set_parameter(
const Parameter& parameter);
1633 ::std::vector<SetParametersOutcome> set_parameters(const ::std::vector<Parameter>& parameters);
1643 template <
typename F>
1644 node_interfaces::OnSetParametersCallbackHandle::SharedPtr
1645 add_on_set_parameters_callback(F callback);
1648 remove_on_set_parameters_callback(
const node_interfaces::OnSetParametersCallbackHandle*
handle);
1652 node_interfaces::NodeParametersInterface::SharedPtr get_node_parameters_interface() {
1653 return node_interfaces::NodeParametersInterface(
this);
1657#ifdef NROS_CPP_HAS_STD_STRING
1661 template <typename T> T declare_parameter(const ::std::string& name, T default_value = T()) {
1662 return this->
template declare_parameter<T>(name.c_str(), default_value);
1664 template <
typename T>
bool get_parameter(const ::std::string& name, T& out)
const {
1665 return this->
template get_parameter<T>(name.c_str(), out);
1667 template <
typename T> T get_parameter(const ::std::string& name)
const {
1668 return this->
template get_parameter<T>(name.c_str());
1670 template <
typename T>
Result set_parameter(const ::std::string& name, T value) {
1671 return this->
template set_parameter<T>(name.c_str(), value);
1673 bool has_parameter(const ::std::string& name)
const {
1674 return this->has_parameter(name.c_str());
1676 Result undeclare_parameter(const ::std::string& name) {
1677 return this->undeclare_parameter(name.c_str());
1679 template <
typename T>
1680 T declare_parameter(const ::std::string& name, T default_value,
1681 const ParameterDescriptor& descriptor) {
1682 return this->
template declare_parameter<T>(name.c_str(), default_value, descriptor);
1684 template <
typename T>
1685 bool get_parameter_or(const ::std::string& name, T& out, T fallback)
const {
1686 return this->
template get_parameter_or<T>(name.c_str(), out, fallback);
1688 ParameterType get_parameter_type(const ::std::string& name)
const {
1689 return this->get_parameter_type(name.c_str());
1703 template <
typename T>
1704 Result declare_parameters(const ::std::string& prefix, const ::std::map<::std::string, T>& m) {
1705 for (typename ::std::map<::std::string, T>::const_iterator it = m.begin(); it != m.end();
1707 const ::std::string full = prefix.empty() ? it->first : (prefix +
"." + it->first);
1708 const ::nros_cpp_node_t* h = this->ffi_handle();
1709 Result r = ::rclcpp::detail::node_param_declare(h, full.c_str(), it->second);
1710 if (!r.ok() && r.raw() != RCLC_RET_ALREADY_EXISTS) {
1714 return Result(RCL_RET_OK);
1738 if (!out.executor_handle_) {
1742 nros_cpp_ret_t ret = nros_cpp_node_create(out.executor_handle_, name, ns, &out.handle_);
1745 out.initialized_ =
true;
1752 if (!initialized_)
return "";
1753 return nros_cpp_node_get_name(&handle_);
1758 if (!initialized_)
return "";
1759 return nros_cpp_node_get_namespace(&handle_);
1778 return Result(nros_cpp_node_get_fully_qualified_name(&handle_, buf, buf_len, out_len));
1799 if (!initialized_)
return nullptr;
1800 return nros_cpp_node_get_serialization_format(&handle_);
1816 if (!initialized_)
return nullptr;
1817 return nros_cpp_node_get_rmw_implementation_identifier(&handle_);
1844 if (!initialized_) return ::rclcpp::Logger(
"",
nullptr);
1845 return ::rclcpp::Logger(nros_cpp_node_get_name(&handle_),
1846 nros_cpp_node_get_logger(&handle_));
1870 Time
now()
const {
return clock_.now(); }
1887 const nros_cpp_node_t*
ffi_handle()
const {
return initialized_ ? &handle_ :
nullptr; }
1901 ::nros_cpp_node_set_qos_overrides(&handle_, overrides, len);
1958 return Result(nros_cpp_executor_get_node_names(executor_handle_, visit, ctx));
1970 return Result(nros_cpp_executor_get_topic_names_and_types(executor_handle_, visit, ctx));
1978 return Result(nros_cpp_executor_get_service_names_and_types(executor_handle_, visit, ctx));
1991 return Result(nros_cpp_executor_count_publishers(executor_handle_, topic_name, out_count));
1998 return Result(nros_cpp_executor_count_subscribers(executor_handle_, topic_name, out_count));
2007 return Result(nros_cpp_executor_count_clients(executor_handle_, service_name, out_count));
2014 return Result(nros_cpp_executor_count_services(executor_handle_, service_name, out_count));
2021 nros_cpp_names_and_types_visit_fn visit,
2024 return Result(nros_cpp_executor_get_publisher_names_and_types_by_node(
2025 executor_handle_, node_name, node_namespace, visit, ctx));
2039 const char* node_namespace,
2040 nros_cpp_names_and_types_visit_fn visit,
2043 return Result(nros_cpp_executor_get_subscription_names_and_types_by_node(
2044 executor_handle_, node_name, node_namespace, visit, ctx));
2051 nros_cpp_names_and_types_visit_fn visit,
2054 return Result(nros_cpp_executor_get_service_names_and_types_by_node(
2055 executor_handle_, node_name, node_namespace, visit, ctx));
2062 nros_cpp_names_and_types_visit_fn visit,
2065 return Result(nros_cpp_executor_get_client_names_and_types_by_node(
2066 executor_handle_, node_name, node_namespace, visit, ctx));
2084 nros_cpp_endpoint_info_visit_fn visit,
void* ctx)
const {
2086 return Result(nros_cpp_executor_get_publishers_info_by_topic(executor_handle_, topic_name,
2099 ::rclcpp::TopicEndpointInfoVisitFn visit,
void* ctx)
const {
2101 ::rclcpp::detail::EndpointInfoTrampoline tramp{visit, ctx};
2102 return Result(nros_cpp_executor_get_publishers_info_by_topic(
2103 executor_handle_, topic_name, &::rclcpp::detail::EndpointInfoTrampoline::thunk,
2112 nros_cpp_endpoint_info_visit_fn visit,
void* ctx)
const {
2114 return Result(nros_cpp_executor_get_subscriptions_info_by_topic(executor_handle_,
2115 topic_name, visit, ctx));
2122 ::rclcpp::TopicEndpointInfoVisitFn visit,
2125 ::rclcpp::detail::EndpointInfoTrampoline tramp{visit, ctx};
2126 return Result(nros_cpp_executor_get_subscriptions_info_by_topic(
2127 executor_handle_, topic_name, &::rclcpp::detail::EndpointInfoTrampoline::thunk,
2137 template <
typename M>
2153 template <
typename M>
2155 const ::rclcpp::QoS& qos, const ::rclcpp::PublisherOptions& options);
2168 template <
typename M>
2187 template <
typename M>
2189 const ::rclcpp::QoS& qos,
2190 const ::rclcpp::SubscriptionOptions& options);
2235 typename M,
typename F,
2236 typename =
typename std::enable_if<std::is_convertible<F, void (*)(
const M&)>::value>::type>
2238 const ::rclcpp::QoS& qos, F callback,
2239 const ::rclcpp::SubscriptionOptions& options = {});
2252 template <
typename M,
typename F,
2253 typename =
typename std::enable_if<
2254 std::is_convertible<F, void (*)(
const M&,
const uint8_t*, size_t)>::value>::type>
2256 const ::rclcpp::QoS& qos, F callback,
2257 const ::rclcpp::SubscriptionOptions& options = {});
2259#if defined(NROS_SAFETY_E2E)
2278 template <
typename M,
typename F,
2279 typename =
typename std::enable_if<std::is_convertible<
2280 F, void (*)(
const M&, const ::nros_cpp_integrity_status_t&)>::value>::type>
2282 const ::rclcpp::QoS& qos, F callback,
2283 const ::rclcpp::SubscriptionOptions& options = {});
2300 template <
typename S>
2317 template <
typename S,
typename F,
2318 typename =
typename std::enable_if<std::is_convertible<
2319 F, void (*)(
const typename S::Request&,
typename S::Response&)>::value>::type>
2322 const ::rclcpp::ServiceOptions& options = {});
2339 template <
typename S>
2354 template <
typename S,
typename F,
2355 typename =
typename std::enable_if<
2356 std::is_convertible<F, void (*)(
const typename S::Response&)>::value>::type>
2359 const ::rclcpp::ClientOptions& options = {});
2371 template <
typename A>
2374 const ::rclcpp::ActionServerOptions& options = {});
2382 template <
typename A>
2389 template <
typename A>
2391 const char* action_name);
2394 template <
typename A>
2396 const char* action_name);
2403 template <
typename M>
2431 nros_cpp_timer_callback_t callback,
void* context =
nullptr) {
2433 size_t handle_id = 0;
2435 executor_handle_,
static_cast<uint8_t
>(clock.get_clock_type()), period_ms, callback,
2436 context, &handle_id);
2438 out.executor_ = executor_handle_;
2439 out.handle_id_ = handle_id;
2440 out.initialized_ =
true;
2463 template <
typename Cb>
2465 const ::rclcpp::CallbackGroup* group =
nullptr,
2466 bool autostart =
true);
2468#ifdef NROS_CPP_HAS_STD_CHRONO
2472 template <typename Rep, typename Period, typename Cb>
2474 const ::rclcpp::CallbackGroup* group =
nullptr,
2475 bool autostart =
true);
2489 void* context =
nullptr) {
2491 size_t handle_id = 0;
2493 nros_cpp_timer_create(executor_handle_, period_ms, callback, context, &handle_id);
2495 out.executor_ = executor_handle_;
2496 out.handle_id_ = handle_id;
2497 out.initialized_ =
true;
2520 template <
class C,
void (C::*Method)()>
2523 out, period_ms, [](
void* ctx) { (
static_cast<C*
>(ctx)->*Method)(); }, self);
2532 template <
class C,
void (C::*Method)()>
2535 out, clock, period_ms, [](
void* ctx) { (
static_cast<C*
>(ctx)->*Method)(); }, self);
2540 template <
class C,
void (C::*Method)()>
2542 uint64_t period_ms, C* self) {
2544 group, out, period_ms, [](
void* ctx) { (
static_cast<C*
>(ctx)->*Method)(); }, self);
2556 void* context =
nullptr) {
2558 size_t handle_id = 0;
2559 nros_cpp_ret_t ret = nros_cpp_timer_create_oneshot(executor_handle_, delay_ms, callback,
2560 context, &handle_id);
2562 out.executor_ = executor_handle_;
2563 out.handle_id_ = handle_id;
2564 out.initialized_ =
true;
2587 if (!::rclcpp::detail::admit_callback_group(name)) {
2588 const ::rclcpp::detail::DeclaredCallbackGroups* g =
2589 ::rclcpp::detail::declared_callback_groups_scope();
2590 const char* list = (g !=
nullptr) ? g->list :
nullptr;
2592 while (name[len] !=
'\0')
2596 this->
set_error(
"create_callback_group: the group is not in this registration's "
2598 ::rclcpp::detail::DECLARED_CALLBACK_GROUP_MISMATCH);
2600 return ::rclcpp::CallbackGroup{name};
2610 ::rclcpp::CallbackGroup::SharedPtr
2612 bool automatically_add_to_executor_with_node =
true) {
2613 (void)automatically_add_to_executor_with_node;
2614 return ::rclcpp::CallbackGroup::SharedPtr(type);
2629 uint64_t period_ms, nros_cpp_timer_callback_t callback,
2630 void* context =
nullptr) {
2632 size_t handle_id = 0;
2634 executor_handle_, &handle_, period_ms, callback, context, group.get_name(), &handle_id);
2636 out.executor_ = executor_handle_;
2637 out.handle_id_ = handle_id;
2638 out.initialized_ =
true;
2663 typename M,
typename F,
2664 typename =
typename std::enable_if<std::is_convertible<F, void (*)(
const M&)>::value>::type>
2667 const ::rclcpp::QoS& qos, F callback,
2668 const ::rclcpp::SubscriptionOptions& options = {});
2681 template <
typename M>
2696 void* context =
nullptr) {
2698 size_t handle_id = 0;
2699 nros_cpp_ret_t ret = nros_cpp_guard_condition_create(executor_handle_, callback, context,
2700 out.storage_, &handle_id);
2702 out.initialized_ =
true;
2703 out.executor_ = executor_handle_;
2704 out.handle_id_ = handle_id;
2745 template <
typename M>
2770 template <
typename M,
class C,
void (C::*Method)(const M& msg)>
2776 template <
typename M,
class C,
void (C::*Method)(const M& msg)>
2797 const int declared = ::rclcpp::declared_depth(type_name, topic);
2800 if (declared == ::rclcpp::DECLARED_DEPTH_UNDECLARED) {
2803 if (declared == qos.depth()) {
2811 "create_subscription_in: ::rclcpp::QoS depth disagrees with the depth declared for "
2812 "this topic in the contract sidecar. Depth multiplies the arena, so the "
2813 "declaration and the code must state one number, not two.",
2833 const int rel = ::rclcpp::declared_reliability(type_name, topic);
2834 if (rel != ::rclcpp::DECLARED_POLICY_UNDECLARED &&
2835 rel !=
static_cast<int>(qos.reliability())) {
2837 this->
get_name(), topic,
"reliability",
2840 static_cast<int>(qos.reliability())));
2841 this->
set_error(
"create_subscription_in: ::rclcpp::QoS reliability disagrees with the "
2842 "reliability declared for this topic in the contract sidecar.",
2846 const int dur = ::rclcpp::declared_durability(type_name, topic);
2847 if (dur != ::rclcpp::DECLARED_POLICY_UNDECLARED &&
2848 dur !=
static_cast<int>(qos.durability())) {
2850 this->
get_name(), topic,
"durability",
2853 this->
set_error(
"create_subscription_in: ::rclcpp::QoS durability disagrees with the "
2854 "durability declared for this topic in the contract sidecar.",
2882 if (name ==
nullptr || nn ==
nullptr) {
2885 const ::rclcpp::declared_params::Node* declaring =
2886 ::rclcpp::declared_param_node((ns !=
nullptr) ? ns :
"", nn);
2887 if (declaring ==
nullptr || ::rclcpp::declared_param_exempt(name)) {
2890 const int declared = ::rclcpp::declared_param_type(declaring, name);
2891 if (declared == passed_type) {
2895 declared, passed_type);
2896 this->
set_error(
"declare_parameter: the code does not declare this parameter the way "
2897 "its contract does (see the line above for the node, the parameter and "
2898 "the contract). The parameter store is sized from the contract's "
2899 "`params:`, so the two must state one name and one type.",
2915 if (!__atomic_load_n(&has_error_, __ATOMIC_RELAXED)) {
2920 __atomic_store_n(&has_error_,
true, __ATOMIC_RELEASE);
2934 nros_cpp_node_destroy(&handle_);
2935 initialized_ =
false;
2941 : handle_(other.handle_), initialized_(other.initialized_),
2942 executor_handle_(other.executor_handle_), clock_(other.clock_), options_(other.options_),
2946 has_error_(other.has_error_), error_what_(other.error_what_),
2947 error_code_(other.error_code_) {
2948 other.initialized_ =
false;
2949 other.executor_handle_ =
nullptr;
2953 if (
this != &other) {
2955 nros_cpp_node_destroy(&handle_);
2957 handle_ = other.handle_;
2958 initialized_ = other.initialized_;
2959 executor_handle_ = other.executor_handle_;
2960 clock_ = other.clock_;
2961 options_ = other.options_;
2962 has_error_ = other.has_error_;
2963 error_what_ = other.error_what_;
2964 error_code_ = other.error_code_;
2965 other.initialized_ =
false;
2966 other.executor_handle_ =
nullptr;
2973 Node& operator=(
const Node&) =
delete;
2985 template <
typename S>
2987 bool (*trampoline)(
const uint8_t*,
size_t, uint8_t*,
size_t,
size_t*,
2989 void* context, const ::rclcpp::QoS& qos,
2990 const ::rclcpp::ServiceOptions& options,
const void* capture =
nullptr,
2991 size_t capture_len = 0,
void (*capture_drop)(
void*) =
nullptr);
2997 template <
typename S>
2999 bool (*trampoline)(
const uint8_t*,
size_t, ::rmw_request_id_t*,
3000 uint8_t*,
size_t,
size_t*,
void*),
3001 void* context, const ::rclcpp::QoS& qos,
3002 const ::rclcpp::ServiceOptions& options,
const void* capture =
nullptr,
3003 size_t capture_len = 0,
void (*capture_drop)(
void*) =
nullptr);
3007 template <
typename S>
3016 template <
typename S,
typename F>
3018 const ::rclcpp::QoS& qos,
3019 ::rclcpp::tr::integral_constant<int, 0>);
3020 template <
typename S,
typename F>
3022 const ::rclcpp::QoS& qos,
3023 ::rclcpp::tr::integral_constant<int, 1>);
3030 void apply_options_(const ::rclcpp::NodeOptions& options) {
3035 if (!options.start_parameter_event_publisher() && initialized_) {
3036 (void)nros_cpp_node_disable_parameter_events(&handle_);
3038 Clock chosen(options.clock_type());
3039 if (!chosen.is_valid()) {
3040 this->set_error(
"NodeOptions::clock_type (not a clock)",
3047 nros_cpp_node_t handle_;
3049 void* executor_handle_;
3057 ::rclcpp::NodeOptions options_;
3079 bool has_error_ =
false;
3080 const char* error_what_ =
nullptr;
3081 int32_t error_code_ = 0;
3093 friend class ::rclcpp::Executor;
3094 friend class ::rclcpp::NodeBuilder;
3097 const char* session_name);
3103 const char* session_name,
const char* node_namespace);
3105 const char* session_name);
3125 template <
int = 0>
struct GlobalStorageHolder {
3126 alignas(8)
static uint8_t storage[NROS_CPP_EXECUTOR_STORAGE_SIZE];
3128 static uint8_t* global_storage() {
return GlobalStorageHolder<>::storage; }
3149 static bool global_initialized() {
3150 return nros_cpp_context_is_live(GlobalStorageHolder<>::storage);
3158alignas(8) uint8_t Node::GlobalStorageHolder<N>::storage[NROS_CPP_EXECUTOR_STORAGE_SIZE] = {};
3192#ifndef NROS_COMPONENT_MAX_TIMERS
3193#define NROS_COMPONENT_MAX_TIMERS 8
3202#if NROS_COMPONENT_MAX_TIMERS < 1
3203#error "NROS_COMPONENT_MAX_TIMERS must be >= 1: it sizes a C array (issue 1015)"
3225template <::
size_t MaxTimers = NROS_COMPONENT_MAX_TIMERS>
3227 static_assert(MaxTimers >= 1,
3228 "NodeWithTimers<0> has no pool -- derive ::rclcpp::Node directly, or use "
3229 "the out-ref create_wall_timer(Timer&, ...) family");
3241 Timer* slot = this->next_timer_slot(
"create_wall_timer_in");
3242 if (slot ==
nullptr)
return;
3244 static_cast<C*
>(
this));
3254 void* context =
nullptr) {
3255 Timer* slot = this->next_timer_slot(
"create_wall_timer_in");
3256 if (slot ==
nullptr)
return;
3267 template <
class C,
void (C::*Method)()>
3269 Timer* slot = this->next_timer_slot(
"create_timer_in_group");
3270 if (slot ==
nullptr)
return;
3272 static_cast<C*
>(
this));
3282 nros_cpp_timer_callback_t callback,
void* context =
nullptr) {
3283 Timer* slot = this->next_timer_slot(
"create_timer_in_group");
3284 if (slot ==
nullptr)
return;
3302 Timer* next_timer_slot(
const char* what) {
3303 if (timer_count_ >= MaxTimers) {
3304 this->set_error(what, -1);
3307 return &timers_[timer_count_];
3310 Timer timers_[MaxTimers];
3311 ::size_t timer_count_ = 0;
3324 return init_in(locator, domain_id,
"node");
3327inline Result init_in(
const char* locator, uint8_t domain_id,
const char* session_name) {
3332 return init_in(locator, domain_id, session_name,
nullptr);
3335inline Result init_in(
const char* locator, uint8_t domain_id,
const char* session_name,
3336 const char* node_namespace) {
3340 if (session_name ==
nullptr) {
3343#if defined(NROS_CPP_STD) || (__STDC_HOSTED__ + 0)
3363#ifdef NROS_ENTRY_LOCATOR
3364 if (locator ==
nullptr) {
3365 locator = NROS_ENTRY_LOCATOR;
3368#ifdef NROS_ENTRY_DOMAIN_ID
3372 if (domain_id == 0) {
3373 domain_id =
static_cast<uint8_t
>(NROS_ENTRY_DOMAIN_ID);
3403#ifdef NROS_ENTRY_RMW
3404 const char* rmw = NROS_ENTRY_RMW;
3406 const char* rmw =
nullptr;
3415 if (node_namespace !=
nullptr && node_namespace[0] ==
'\0') {
3416 node_namespace =
nullptr;
3424 nros_cpp_executor_storage_check(::rclcpp::Node::global_storage(),
3425 sizeof(::rclcpp::Node::GlobalStorageHolder<>::storage));
3430 nros_cpp_ret_t ret = nros_cpp_init_rmw(rmw, locator, domain_id, session_name, node_namespace,
3431 ::rclcpp::Node::global_storage());
3438 const char* session_name) {
3441 if (session_name ==
nullptr) {
3444#ifdef NROS_ENTRY_LOCATOR
3445 if (locator ==
nullptr) {
3446 locator = NROS_ENTRY_LOCATOR;
3449#ifdef NROS_ENTRY_DOMAIN_ID
3450 if (domain_id == 0) {
3451 domain_id =
static_cast<uint8_t
>(NROS_ENTRY_DOMAIN_ID);
3463 nros_cpp_executor_storage_check(::rclcpp::Node::global_storage(),
3464 sizeof(::rclcpp::Node::GlobalStorageHolder<>::storage));
3469 nros_cpp_ret_t ret = nros_cpp_init_rmw(rmw, locator, domain_id, session_name,
nullptr,
3470 ::rclcpp::Node::global_storage());
3477 if (!::rclcpp::Node::global_initialized()) {
3482 return Result(nros_cpp_fini(::rclcpp::Node::global_storage()));
3486 if (!::rclcpp::Node::global_initialized())
return nullptr;
3487 return ::rclcpp::Node::global_storage();
3498 bool scoped =
false;
3499 for (
int i = 0; argv !=
nullptr && i < argc && !scoped; ++i) {
3500 const char* a = argv[i];
3501 const char* want =
"--ros-args";
3502 while (a !=
nullptr && *a !=
'\0' && *a == *want) {
3506 scoped = a !=
nullptr && *a ==
'\0' && *want ==
'\0';
3510 if (!scoped && !nros_cpp_baked_ros_args_present()) {
3513 char why[256] = {0};
3514 const int32_t rc = nros_cpp_install_argv_remaps(executor, argc, argv, why,
sizeof(why));
3521 RCLC_LOG_ERROR(::rclcpp::detail::log_handle(
nullptr),
"rclcpp::init: refused: %.120s",
3522 why[0] !=
'\0' ? why :
"invalid executor handle or argv");
3523 NROS_RCLCPP_SAY_REFUSED(NROS_RCLCPP_REFUSE_INIT_ARGV);
3541 if (installed != 0) {
3543 return Result(installed);
3554inline Result init_in(
int argc,
char const*
const* argv,
const char* session_name) {
3555 const char* name = (session_name !=
nullptr) ? session_name :
"nros_cpp";
3565 return ::rclcpp::Node::global_initialized() && !::nros_cpp_termination_requested();
3577 if (!::rclcpp::Node::global_initialized()) {
3580 out.executor_handle_ = ::rclcpp::Node::global_storage();
3581 return ::rclcpp::Node::create(out, name, ns);
3597 const char* ns =
nullptr) {
3598 if (executor_handle ==
nullptr) {
3601 out.executor_handle_ = executor_handle;
3602 return ::rclcpp::Node::create(out, name, ns);
3619 out.executor_handle_ = storage_;
3620 return ::rclcpp::Node::create(out, name, ns);
3643 : executor_handle_(executor_handle), name_(name),
3644 options_(nros_cpp_node_get_default_options()) {}
3651 copy_bounded(name, options_.rmw_name, &options_.rmw_name_len, NROS_CPP_RMW_NAME_LEN);
3658 copy_bounded(loc, options_.locator, &options_.locator_len, NROS_CPP_LOCATOR_LEN);
3665 options_.domain_id_override = id;
3675 copy_bounded(ns, options_.namespace_, &options_.namespace_len, NROS_CPP_NAMESPACE_LEN);
3682 options_.sched_context_id = sc_id;
3689 out.executor_handle_ = executor_handle_;
3691 nros_cpp_node_create_ex(executor_handle_, name_, &options_, &out.handle_);
3693 out.initialized_ =
true;
3699 static void copy_bounded(
const char* src, uint8_t* dst,
size_t* dst_len,
size_t cap) {
3701 if (src !=
nullptr) {
3702 while (src[n] !=
'\0' && n < cap) {
3703 dst[n] =
static_cast<uint8_t
>(src[n]);
3708 for (
size_t i = n; i < cap; ++i) {
3714 void* executor_handle_;
3716 nros_cpp_node_options_t options_;
3730 const DeclaredCallbackGroups& groups) {
3731 const char* missing =
nullptr;
3733 if (first_uncreated_callback_group(groups, &missing, &len)) {
3735 node.
set_error(
"a CALLBACK_GROUPS group was never created",
3736 DECLARED_CALLBACK_GROUP_MISMATCH);
Definition rclcpp.hpp:195
Result create_node(::rclcpp::Node &out, const char *name, const char *ns=nullptr)
Definition node.hpp:3617
NodeBuilder node_builder(const char *name)
Definition node.hpp:3719
NodeBuilder & locator(const char *loc)
Definition node.hpp:3657
NodeBuilder & sched(uint8_t sc_id)
Definition node.hpp:3681
Result build(::rclcpp::Node &out) const
Materialize the Node.
Definition node.hpp:3687
NodeBuilder(void *executor_handle, const char *name)
Definition node.hpp:3642
NodeBuilder & rmw(const char *name)
Definition node.hpp:3650
NodeBuilder & domain_id(uint32_t id)
Definition node.hpp:3664
NodeBuilder & namespace_(const char *ns)
Definition node.hpp:3674
::rclcpp::TimerHandle create_wall_timer(::rclcpp::Duration period, Cb cb, const ::rclcpp::CallbackGroup *group=nullptr, bool autostart=true)
void create_timer_in_group(const CallbackGroup &group, uint64_t period_ms)
Definition node.hpp:3268
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:3281
void create_wall_timer_in(uint64_t period_ms)
Definition node.hpp:3240
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:3253
Node & operator=(Node &&other)
Definition node.hpp:2952
bool check_declared_depth(const char *type_name, const char *topic, const ::rclcpp::QoS &qos)
Definition node.hpp:2796
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:2533
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:1887
Result count_subscribers(const char *topic_name, size_t *out_count) const
Definition node.hpp:1996
SharedPtr shared_from_this()
Definition node.hpp:1071
Result create_timer(Timer &out, const Clock &clock, uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
Definition node.hpp:2430
Time now() const
Definition node.hpp:1870
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:973
Result get_parameter_types(const char *const *names, ::size_t count, ParameterType *out) const
Definition rclcpp.hpp:1955
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 > ConstWeakPtr
Const spelling of WeakPtr.
Definition node.hpp:1058
Result add_on_set_parameters_callback(OnSetParametersCallbackType callback, void *context, OnSetParametersCallbackToken &out_handle)
Definition rclcpp.hpp:2014
::rclcpp::Handle< const Node > ConstSharedPtr
rclcpp::Node::ConstSharedPtr.
Definition node.hpp:1053
Result create_timer_in_group(const ::rclcpp::CallbackGroup &group, Timer &out, uint64_t period_ms, C *self)
Definition node.hpp:2541
Node(const char *name, const char *ns, const ::rclcpp::NodeOptions &options)
Definition node.hpp:1015
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:1843
Result create_service(::rclcpp::PollService< S > &out, const char *service_name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
typename::rclcpp::Subscription< M >::SharedPtr create_subscription(const char *topic, const ::rclcpp::QoS &qos, Cb cb, const ::rclcpp::SubscriptionOptions &options)
typename::rclcpp::Subscription< M >::SharedPtr create_subscription(const char *topic, ::size_t depth, Cb cb, const ::rclcpp::SubscriptionOptions &options)
create_subscription<M>(topic, depth, callback, options).
::rclcpp::Handle< Node > WeakPtr
Definition node.hpp:1056
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:1874
typename::rclcpp::Subscription< M >::SharedPtr create_subscription(const char *topic, const ::rclcpp::QoS &qos, Cb cb)
void create_generic_publisher(const A &topic, const B &type, const ::rclcpp::QoS &qos, const R &...)
Definition node.hpp:1355
Result count_clients(const char *service_name, size_t *out_count) const
Definition node.hpp:2005
Result create_wall_timer(Timer &out, uint64_t period_ms, C *self)
Definition node.hpp:2521
Result get_node_names(nros_cpp_node_visit_fn visit, void *ctx) const
Definition node.hpp:1956
Result init(const char *name, const char *ns=nullptr)
Definition node.hpp:884
::rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr get_node_waitables_interface()
See get_node_base_interface.
Definition node.hpp:1095
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, const ::rclcpp::CallbackGroup *group=nullptr, bool autostart=true)
bool check_declared_param(const char *name, int passed_type)
Definition node.hpp:2879
Result describe_parameter(const char *name, ParameterDescriptor &out, char *text, ::size_t text_len) const
Definition rclcpp.hpp:1966
T declare_parameter(const char *name, T default_value=T())
rclcpp::Node::declare_parameter<T>(name, default).
Definition rclcpp.hpp:1851
Result remove_on_set_parameters_callback(OnSetParametersCallbackToken handle)
rclcpp::Node::remove_on_set_parameters_callback(handle).
Definition rclcpp.hpp:2021
const char * serialization_format() const
Definition node.hpp:1798
~Node()
Definition node.hpp:2932
static Result create(Node &out, const char *name, const char *ns=nullptr)
Definition node.hpp:1737
bool get_parameter_or(const char *name, T &out, T fallback) const
Definition rclcpp.hpp:1935
typename::rclcpp::Service< S >::SharedPtr create_service(const char *name, F callback, const ::rclcpp::QoS &qos, const ::rclcpp::CallbackGroup *group)
ParameterType get_parameter_type(const char *name) const
Definition rclcpp.hpp:1947
bool ok() const
Definition node.hpp:969
bool has_parameter(const char *name) const
rclcpp::Node::has_parameter(name).
Definition rclcpp.hpp:1906
::rclcpp::CallbackGroup::SharedPtr create_callback_group(::rclcpp::CallbackGroupType type, bool automatically_add_to_executor_with_node=true)
Definition node.hpp:2611
Result count_services(const char *service_name, size_t *out_count) const
Definition node.hpp:2012
void * executor_handle() const
Definition node.hpp:1911
Result list_parameters(const char *prefix, char *out_names, ::size_t name_stride, ::size_t max_names, ::size_t &count) const
Definition rclcpp.hpp:2004
::rclcpp::Publisher< M > create_publisher_in(const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
Definition node.hpp:2747
Result get_publishers_info_by_topic(const char *topic_name, ::rclcpp::TopicEndpointInfoVisitFn visit, void *ctx) const
Definition node.hpp:2098
::rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr get_node_logging_interface()
See get_node_base_interface.
Definition node.hpp:1091
::rclcpp::Handle< Node > SharedPtr
Definition node.hpp:1051
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:2940
Node(const char *name, const ::rclcpp::NodeOptions &options)
Definition node.hpp:1008
const char * rmw_implementation_identifier() const
Definition node.hpp:1815
Result create_guard_condition(::rclcpp::GuardCondition &out, nros_cpp_guard_callback_t callback, void *context=nullptr)
Definition node.hpp:2695
const char * get_namespace() const
Get the node namespace.
Definition node.hpp:1757
bool initialized() const
Definition node.hpp:1127
void set_error(const char *what, int32_t code)
Definition node.hpp:2911
Node & nros_node()
Definition node.hpp:1131
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:2061
Result count_publishers(const char *topic_name, size_t *out_count) const
Definition node.hpp:1989
Result start_parameter_services()
Definition node.hpp:1919
int32_t error_code() const
The raw error code of the first latched failure, or 0.
Definition node.hpp:980
const char * get_name() const
Get the node name.
Definition node.hpp:1751
bool is_valid() const
Check if the node is initialized and valid.
Definition node.hpp:1873
::rclcpp::node_interfaces::NodeGraphInterface::SharedPtr get_node_graph_interface()
See get_node_base_interface.
Definition node.hpp:1087
Result create_wall_timer(Timer &out, uint64_t period_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
Definition node.hpp:2488
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:2628
::rclcpp::CallbackGroup create_callback_group(const char *name)
Definition node.hpp:2586
Node(::rclcpp::NodeHandle handle, const char *name, const char *ns=nullptr)
Definition node.hpp:929
Node(const char *name, const char *ns=nullptr)
Definition node.hpp:866
Result set_parameters_atomically(const ParameterWrite *writes, ::size_t count)
Definition rclcpp.hpp:2010
::rclcpp::Owned<::rclcpp::PollClient< S > > create_client(const char *name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
::rclcpp::SubscriptionHandle<::rclcpp::GenericSubscription > create_generic_subscription(const char *topic, const char *type, const char *type_hash, const ::rclcpp::QoS &qos, Cb callback)
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:2038
bool check_declared_qos(const char *type_name, const char *topic, const ::rclcpp::QoS &qos)
Definition node.hpp:2829
Result create_timer_oneshot(Timer &out, uint64_t delay_ms, nros_cpp_timer_callback_t callback, void *context=nullptr)
Definition node.hpp:2555
Result get_service_names_and_types(nros_cpp_names_and_types_visit_fn visit, void *ctx) const
Definition node.hpp:1976
Result get_topic_names_and_types(nros_cpp_names_and_types_visit_fn visit, void *ctx) const
Definition node.hpp:1968
Result set_parameter(const char *name, T value)
Definition rclcpp.hpp:1898
const Clock * get_clock() const
Const overload of get_clock().
Definition node.hpp:1861
Result get_fully_qualified_name(char *buf, size_t buf_len, size_t *out_len=nullptr) const
Definition node.hpp:1776
Result get_subscriptions_info_by_topic(const char *topic_name, ::rclcpp::TopicEndpointInfoVisitFn visit, void *ctx) const
Definition node.hpp:2121
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:1859
void create_generic_subscription(const A &topic, const B &type, const ::rclcpp::QoS &qos, Cb &&callback, const R &...)
Definition node.hpp:1366
const Node & nros_node() const
Const overload of [nros_node].
Definition node.hpp:1133
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:2020
Result get_publishers_info_by_topic(const char *topic_name, nros_cpp_endpoint_info_visit_fn visit, void *ctx) const
Definition node.hpp:2083
void create_subscription_in_group(const ::rclcpp::CallbackGroup &group, const char *topic, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
::rclcpp::node_interfaces::NodeBaseInterface::SharedPtr get_node_base_interface()
Definition node.hpp:1079
Node()
Definition node.hpp:849
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:2682
Result undeclare_parameter(const char *name)
Definition rclcpp.hpp:1943
const ::rclcpp::NodeOptions & get_node_options() const
Definition node.hpp:1022
::rclcpp::node_interfaces::NodeClockInterface::SharedPtr get_node_clock_interface()
See get_node_base_interface.
Definition node.hpp:1083
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:1073
void set_qos_overrides(const nros_cpp_qos_override_t *overrides, size_t len)
Definition node.hpp:1899
Result init_on(void *executor_handle, const char *name, const char *ns=nullptr)
Definition node.hpp:895
Result get_subscriptions_info_by_topic(const char *topic_name, nros_cpp_endpoint_info_visit_fn visit, void *ctx) const
Definition node.hpp:2111
::rclcpp::Owned<::rclcpp::GenericPublisher > create_generic_publisher(const char *topic, const char *type, const char *type_hash, const ::rclcpp::QoS &qos=::rclcpp::QoS::default_profile())
Definition rclcpp.hpp:1383
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:2050
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&)).
Definition publisher.hpp:178
static constexpr QoS services()
Services profile: RELIABLE + VOLATILE + KEEP_LAST(10).
Definition qos.hpp:805
static constexpr QoS default_profile()
Default profile: RELIABLE + VOLATILE + KEEP_LAST(10).
Definition qos.hpp:799
int32_t raw() const
Get the raw integer code (for FFI interop).
Definition result.hpp:236
bool ok() const
Returns true if the operation succeeded.
Definition result.hpp:227
static constexpr ResultOf success()
Named constructors.
Definition result.hpp:239
Definition result.hpp:332
static ResultOf ok(T value)
Definition result.hpp:334
static ResultOf error(ErrorCode code)
Definition result.hpp:340
Definition service.hpp:146
Definition subscription.hpp:197
static const bool value
Definition qos.hpp:889
One slice's handle; Tag only keeps the five spellings distinct types.
Definition node.hpp:240
Node * node() const
Definition node.hpp:247
Context get_context() const
Definition rclcpp.hpp:318
const NodeInterfaceHandle * operator->() const
Definition node.hpp:251
NodeInterfaceHandle()
Definition node.hpp:244
NodeInterfaceHandle SharedPtr
Upstream's Node*InterfaceSharedPtr — the handle itself (no allocator).
Definition node.hpp:243
NodeInterfaceHandle(Node *node)
Definition node.hpp:245
Definition client.hpp:256
Definition server.hpp:351
rclcpp::Executor — drives transport I/O and dispatches callbacks.
int nros_cpp_ret_t
Definition future.hpp:25
rclcpp::GuardCondition — cross-thread wake source.
Definition rclcpp.hpp:418
void report_declared_depth_mismatch(const char *node_name, const char *topic, int declared, int passed)
Definition node.hpp:509
const char * declared_reliability_spelling(int ordinal)
The contract spelling of a reliability ordinal, for the report above.
Definition node.hpp:603
void report_declared_policy_mismatch(const char *node_name, const char *topic, const char *policy, const char *declared, const char *passed)
Definition node.hpp:579
void report_component_failure(const char *node_name, const char *what, int32_t code)
Definition node.hpp:480
constexpr int32_t DECLARED_PARAM_MISMATCH
Definition node.hpp:620
int32_t apply_ros_args(void *executor, int argc, char const *const *argv)
Definition node.hpp:3495
Result init_honouring_ros_args(int argc, char const *const *argv, const char *name)
Definition node.hpp:3531
const char * declared_durability_spelling(int ordinal)
The contract spelling of a durability ordinal, for the report above.
Definition node.hpp:611
constexpr int32_t DECLARED_DEPTH_MISMATCH
Definition node.hpp:504
void finish_declared_callback_groups(::rclcpp::Node &node, const DeclaredCallbackGroups &groups)
Definition node.hpp:3729
void report_callback_group_mismatch(const char *node_name, const char *how, const char *name, int len, const char *list)
Definition node.hpp:538
void report_declared_param_mismatch(const char *fqn, const char *param, const char *contract, int declared, int passed)
Definition node.hpp:626
constexpr int32_t DECLARED_QOS_MISMATCH
Definition node.hpp:574
Definition rclcpp.hpp:317
NodeInterfaceHandle< 3 > NodeLoggingInterface
Definition node.hpp:264
NodeInterfaceHandle< 0 > NodeBaseInterface
Definition node.hpp:261
NodeInterfaceHandle< 1 > NodeClockInterface
Definition node.hpp:262
NodeInterfaceHandle< 2 > NodeGraphInterface
Definition node.hpp:263
NodeInterfaceHandle< 4 > NodeWaitablesInterface
Definition node.hpp:265
Client & operator=(Client &&other)
Definition client.hpp:1002
constexpr uint8_t kDomainIdExplicitZero
Definition node.hpp:466
Result shutdown_in()
Definition node.hpp:3476
Result create_node(::rclcpp::Node &out, const char *name, const char *ns)
Definition node.hpp:3576
@ Reliable
Definition qos.hpp:149
@ BestEffort
Definition qos.hpp:150
Result init_in(const char *locator=nullptr, uint8_t domain_id=0)
Definition node.hpp:3316
Result spin_once(int32_t timeout_ms=10)
Definition rclcpp.hpp:97
void init()
rclcpp::init() — the zero-argument form. ADOPT.
Definition rclcpp.hpp:542
bool ok()
Definition node.hpp:3564
Result spin_in()
Definition rclcpp.hpp:331
Result create_node_on(::rclcpp::Node &out, void *executor_handle, const char *name, const char *ns)
Definition node.hpp:3596
ResultOf<::rclcpp::Node > make_node(const char *name, const char *ns=nullptr)
Definition node.hpp:3608
ResultOf< Publisher< M > > create_publisher(::rclcpp::Node &node, const char *topic, const QoS &qos=QoS::default_profile())
Definition publisher.hpp:705
void * global_handle()
Definition node.hpp:3485
@ InvalidArgument
Null pointer, empty topic name, or out-of-range value.
Definition result.hpp:122
@ AlreadyExists
Already exists (duplicate declare/register).
Definition result.hpp:126
@ NotInitialized
Definition result.hpp:131
Result init_with_rmw(const char *rmw, const char *locator=nullptr, uint8_t domain_id=0, const char *session_name="node")
Definition node.hpp:3437
@ Volatile
Definition qos.hpp:164
@ TransientLocal
Definition qos.hpp:165
ResultOf< void > Result
Definition result.hpp:247
rclcpp::QoS — full DDS-shaped QoS settings (Phase 108.B.7).
**auto handle
Definition client.hpp:127
::rclcpp::Owned< Client > SharedPtr
Definition client.hpp:487
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:448
constexpr bool valid() const
Definition node.hpp:440
constexpr NodeHandle()
Definition node.hpp:422
const char * launch_name
Definition node.hpp:405
void * executor
Definition node.hpp:401
constexpr NodeHandle(void *exec)
Definition node.hpp:425
const char * launch_namespace
Launch-declared namespace, same contract.
Definition node.hpp:407
const nros_cpp_qos_override_t * qos_overrides
Definition node.hpp:418
constexpr const char * resolve_name(const char *fallback) const
Definition node.hpp:444
constexpr NodeHandle(void *exec, const char *name, const char *ns, const nros_cpp_qos_override_t *overrides, size_t override_count)
Definition node.hpp:436
constexpr NodeHandle(void *exec, const char *name, const char *ns)
Definition node.hpp:430
size_t qos_override_count
Entries in qos_overrides; 0 = none.
Definition node.hpp:420
rclcpp::Timer — periodic callback driven by the executor.