12#ifndef NROS_RCLCPP_RCLCPP_HPP
13#define NROS_RCLCPP_RCLCPP_HPP
18#include "rclcpp/detail/nros_cpp_ffi.h"
20#include "rclcpp/detail/traits.hpp"
21#include "rclcpp/logging.hpp"
29#include "rclcpp/duration.hpp"
30#include "rclcpp/time.hpp"
31#include "rclcpp/clock.hpp"
33#include "rclcpp/options.hpp"
45#include "rclcpp/generic.hpp"
50#include "rclcpp/polling_action_server.hpp"
51#include "rclcpp/polling_action_client.hpp"
52#include "rclcpp/polling_client.hpp"
53#include "rclcpp/polling_service.hpp"
54#include "rclcpp/polling_subscription.hpp"
55#include "rclcpp/parameter.hpp"
61#include "rclcpp/node_parameters.hpp"
62#include "rclcpp_lifecycle/lifecycle_node.hpp"
63#include "rclcpp/rosout.hpp"
73#include "rclcpp/detail/component.hpp"
98 if (!::rclcpp::Node::global_initialized()) {
114 nros_cpp_monitors_arm();
133 return Result(nros_cpp_trace_marker(
id, arg));
159 if (executor ==
nullptr) {
162 nros_cpp_shutdown_callback_handle_t raw = NROS_CPP_SHUTDOWN_CALLBACK_HANDLE_INVALID;
163 nros_cpp_ret_t ret = nros_cpp_add_pre_shutdown_callback(executor, callback, context, &raw);
178 if (executor ==
nullptr) {
181 nros_cpp_shutdown_callback_handle_t raw = NROS_CPP_SHUTDOWN_CALLBACK_HANDLE_INVALID;
182 nros_cpp_ret_t ret = nros_cpp_add_on_shutdown_callback(executor, callback, context, &raw);
191 if (executor ==
nullptr)
return false;
192 return nros_cpp_remove_pre_shutdown_callback(executor,
handle.value()) == 0;
199 if (executor ==
nullptr)
return false;
200 return nros_cpp_remove_on_shutdown_callback(executor,
handle.value()) == 0;
218 explicit Context(
void* executor) : executor_(executor) {}
230 nros_cpp_shutdown_callback_handle_t raw = NROS_CPP_SHUTDOWN_CALLBACK_HANDLE_INVALID;
231 nros_cpp_ret_t ret = nros_cpp_add_pre_shutdown_callback(executor_, callback, context, &raw);
239 nros_cpp_shutdown_callback_handle_t raw = NROS_CPP_SHUTDOWN_CALLBACK_HANDLE_INVALID;
240 nros_cpp_ret_t ret = nros_cpp_add_on_shutdown_callback(executor_, callback, context, &raw);
246 if (executor_ ==
nullptr)
return false;
247 const bool removed = nros_cpp_remove_pre_shutdown_callback(executor_,
handle.value()) == 0;
248#if defined(NROS_CPP_STD)
249 if (removed) release_closure(
handle.value());
255 if (executor_ ==
nullptr)
return false;
256 const bool removed = nros_cpp_remove_on_shutdown_callback(executor_,
handle.value()) == 0;
257#if defined(NROS_CPP_STD)
258 if (removed) release_closure(
handle.value());
263#if defined(NROS_CPP_STD)
266 PreShutdownCallbackHandle add_pre_shutdown_callback(::std::function<void()> callback) {
268 auto* fn = new ::std::function<void()>(
static_cast<::std::function<
void()
>&&>(callback));
273 closures()[h.value()].reset(fn);
279 auto* fn = new ::std::function<void()>(
static_cast<::std::function<
void()
>&&>(callback));
280 if (!add_on_shutdown_callback(&Context::run_closure, fn, &h).
ok()) {
284 closures()[h.value()].reset(fn);
289 static void run_closure(
void* fn) {
290 if (fn !=
nullptr) (*
static_cast<::std::function<
void()
>*>(fn))();
293 ::std::map<nros_cpp_shutdown_callback_handle_t, ::std::unique_ptr<::std::function<void()>>>;
294 static ClosureMap& closures() {
298 static void release_closure(nros_cpp_shutdown_callback_handle_t h) { closures().erase(h); }
318inline bool Clock::sleep_until(Time until, Context context) {
319 if (until.get_clock_type() != get_clock_type())
return false;
320 void* executor = context.executor_handle();
321 if (executor ==
nullptr || !
::rclcpp::ok())
return false;
323 nros_cpp_spin_until_clock(executor, &clock_, until.nanoseconds(), 10);
324 return ret == NROS_CPP_RET_OK && now() >= until;
326inline bool Clock::sleep_until(Time until) {
327 return sleep_until(until, contexts::get_global_default_context());
329inline bool Clock::sleep_for(Duration rel_time, Context context) {
330 return sleep_until(now() + rel_time, context);
332inline bool Clock::sleep_for(Duration rel_time) {
333 return sleep_for(rel_time, contexts::get_global_default_context());
338 return Context(node_ !=
nullptr ? node_->executor_handle() :
nullptr);
351 if (!::rclcpp::Node::global_initialized()) {
357 void* storage = ::rclcpp::Node::global_storage();
359 if (!last.
ok())
return last;
373 if (!::rclcpp::Node::global_initialized()) {
381 return Result(nros_cpp_spin_for(::rclcpp::Node::global_storage(), duration_ms, poll_ms));
420#include <type_traits>
445 return s ==
nullptr ? false
446 :
"--ros-args"[i] ==
'\0' ? s[i] ==
'\0'
447 : s[i] !=
"--ros-args"[i] ? false
452 return i >= argc ? false
453 : argv ==
nullptr ? false
504 RCLC_LOG_ERROR(log_handle(
nullptr),
"rclcpp::Node::%s(\"%.64s\") failed: rclcpp::ErrorCode %d",
505 verb, name !=
nullptr ? name :
"",
static_cast<int>(code));
506 NROS_RCLCPP_SAY_REFUSED(NROS_RCLCPP_ABORT_FAILED_CREATE);
544inline void init(
int argc,
char const*
const* argv) {
579 return ::rclcpp::shutdown_in().ok();
647 const ::rclcpp::QoS& qos) {
665#if defined(NROS_CPP_HAS_STD_STRING)
745 const ::rclcpp::QoS& qos) {
756 return this->
create_publisher<M>(topic.c_str(), ::rclcpp::QoS(
static_cast<uint32_t
>(depth)));
801template <
typename M,
typename Cb>
812template <
typename M,
typename Cb>
814 ::size_t depth, Cb cb) {
857 const ::rclcpp::QoS& qos) {
866template <
typename S,
typename F,
typename>
867inline typename Service<S>::SharedPtr Node::create_service(const ::std::string& name, F callback,
868 const ::rclcpp::QoS& qos) {
869 return this->
template create_service<S>(name.c_str(), callback, qos);
876template <
typename S,
typename F,
typename,
typename>
877inline typename Service<S>::SharedPtr Node::create_service(const ::std::string& name, F callback,
878 const ::rclcpp::QoS& qos) {
881 return this->
template create_service<S>(name.c_str(), callback, qos);
889inline ::rclcpp::Owned<::rclcpp::PollClient<S>> Node::create_client(const ::std::string& name,
890 const ::rclcpp::QoS& qos) {
892 return this->
template create_client<S>(name.c_str(), qos);
899template <
typename S,
typename F,
typename>
901 const ::rclcpp::QoS& qos) {
902 return this->
template create_client<S>(name.c_str(), callback, qos);
909template <
typename S,
typename F,
typename,
typename>
911 const ::rclcpp::QoS&) {
912 static_assert(::rclcpp::detail::refuse<F>::value,
913 NROS_RCLCPP_REFUSE_SHARED_PTR_SERVICE_CALLBACK);
922#if defined(NROS_CPP_HAS_SHARED_PTR)
972template <
typename N, typename ::rclcpp::tr::enable_if<
973 ::rclcpp::tr::is_convertible<N*, ::rclcpp::Node*>::value,
int>::type = 0>
974inline ::rclcpp::Node&
as_node_ref(const ::std::shared_ptr<N>& n) {
1017 if (!node || !node->initialized()) {
1030 if (!node || !node->initialized()) {
1038 if (executor ==
nullptr)
return;
1039 (void)nros_cpp_spin_some(executor, 0);
1078 return f.is_ready();
1080#if defined(NROS_CPP_HAS_STD_FUTURE)
1081template <
typename T>
inline bool future_is_ready(const ::std::shared_future<T>& f) {
1082 return f.valid() && f.wait_for(::std::chrono::seconds(0)) == ::std::future_status::ready;
1084template <
typename T>
inline bool future_is_ready(::std::shared_future<T>& f) {
1085 return f.valid() && f.wait_for(::std::chrono::seconds(0)) == ::std::future_status::ready;
1087template <
typename T>
inline bool future_is_ready(::std::future<T>& f) {
1088 return f.valid() && f.wait_for(::std::chrono::seconds(0)) == ::std::future_status::ready;
1093template <
typename Future>
1095 int32_t timeout_ms = -1) {
1096 if (!node || !node->initialized()) {
1100 constexpr int32_t kPollMs = 10;
1101 const bool bounded = timeout_ms >= 0;
1103 const uint64_t budget_ns = bounded ?
static_cast<uint64_t
>(timeout_ms) * 1000000ull : 0ull;
1131template <
typename Future>
1133 int32_t timeout_ms,
bool process) {
1135 constexpr int32_t kPollMs = 10;
1136 const bool bounded = timeout_ms >= 0;
1138 const uint64_t budget_ns = bounded ?
static_cast<uint64_t
>(timeout_ms) * 1000000ull : 0ull;
1139 while (process ?
::rclcpp::ok() : !::nros_cpp_termination_requested()) {
1149template <
typename NodePtr>
1151 const bool live = node && node->initialized();
1152 const char* name = live ? node->get_name() :
"";
1157 if (node->executor_handle() != executor) {
1161 NROS_RCLCPP_SAY_REFUSED(NROS_RCLCPP_REFUSE_FOREIGN_EXECUTOR_NODE);
1163 NROS_RCLCPP_SAY_REFUSED(NROS_RCLCPP_REFUSE_FOREIGN_NODE);
1171template <
typename Future>
1174 return ::rclcpp::detail::spin_executor_until_future_complete(storage_, future, timeout_ms,
1211 void add_node(const ::rclcpp::Node::SharedPtr& node,
bool notify =
true) {
1217 template <
typename NodePtr,
typename T =
void>
1221 static_assert(::rclcpp::detail::refuse<T>::value, NROS_RCLCPP_REFUSE_REMOVE_NODE);
1227 template <
typename Future>
1230 future, timeout_ms,
true);
1236 if (max_duration_ms == 0) {
1237 NROS_RCLCPP_SAY_REFUSED(
"spin_all(0) REFUSED: max_duration must be positive, as in "
1266 if (executor ==
nullptr)
return;
1267 (void)nros_cpp_spin_some(executor, max_ms);
1275 static_assert(::rclcpp::detail::refuse<T>::value,
1276 NROS_RCLCPP_REFUSE_MULTI_THREADED_EXECUTOR);
1294#if defined(NROS_CPP_HAS_SHARED_PTR)
1303template <
typename N, typename ::rclcpp::tr::enable_if<
1304 ::rclcpp::tr::is_convertible<N*, Node*>::value,
int>::type = 0>
1305inline void spin(const ::std::shared_ptr<N>& node) {
1309template <
typename N, typename ::rclcpp::tr::enable_if<
1310 ::rclcpp::tr::is_convertible<N*, Node*>::value,
int>::type = 0>
1311inline void spin_some(const ::std::shared_ptr<N>& node) {
1316 typename N,
typename Future,
1317 typename ::rclcpp::tr::enable_if<::rclcpp::tr::is_convertible<N*, Node*>::value,
int>::type = 0>
1319 Future&& future, int32_t timeout_ms = -1) {
1338template <
typename M,
typename Cb>
1341 Cb cb, ::rclcpp::tr::false_type ) {
1356 NROS_RCLCPP_REFUSE_SUBSCRIPTION_CALLBACK_SHAPE);
1357 using Capture = ::rclcpp::InplaceFn<void(
const M&)>;
1359 ::rclcpp::tr::forward_rvalue(cb)));
1360 ::size_t handle_id = 0;
1362 node, topic, qos, captured, &handle_id);
1366 captured.relinquish();
1377template <
typename M,
typename Cb>
1380 Cb cb, ::rclcpp::tr::true_type ) {
1383 NROS_RCLCPP_REFUSE_SUBSCRIPTION_CALLBACK_SHAPE);
1384 using Capture = ::rclcpp::InplaceFn<void(
const M&, const ::rclcpp::MessageInfo&)>;
1386 ::rclcpp::tr::forward_rvalue(cb)));
1387 ::size_t handle_id = 0;
1389 node, topic, qos, captured, &handle_id);
1393 captured.relinquish();
1402inline ::rclcpp::Owned<::rclcpp::GenericPublisher>
1404 const ::rclcpp::QoS& qos) {
1405 ::rclcpp::GenericPublisher p;
1407 this->
ffi_handle(), p, topic, type, type_hash, qos),
1408 "create_generic_publisher", topic);
1409 return ::rclcpp::Owned<::rclcpp::GenericPublisher>(::rclcpp::tr::forward_rvalue(p));
1412template <
typename Cb>
1413inline ::rclcpp::SubscriptionHandle<::rclcpp::GenericSubscription>
1415 const ::rclcpp::QoS& qos, Cb callback) {
1416 ::rclcpp::GenericSubscription::Callback fn(::rclcpp::tr::forward_rvalue(callback));
1417 ::size_t handle_id = 0;
1419 ::rclcpp::detail::register_generic_subscription(this->
ffi_handle(), topic, type, type_hash,
1420 qos, fn, &handle_id),
1421 "create_generic_subscription", topic);
1422 return ::rclcpp::SubscriptionHandle<::rclcpp::GenericSubscription>(this->
executor_handle(),
1426template <
typename M,
typename Cb>
1436 return ::rclcpp::detail::create_subscription_dispatch<M>(
1437 *
this, topic, qos, ::rclcpp::tr::forward_rvalue(cb),
1438 ::rclcpp::tr::integral_constant<bool, takes_info>());
1441template <
typename M,
typename Cb>
1443 ::size_t depth, Cb cb) {
1445 ::rclcpp::tr::forward_rvalue(cb));
1448template <
typename M,
typename Cb>
1451 const ::rclcpp::SubscriptionOptions& options) {
1457 if (options.sched_context != ::rclcpp::SCHED_CONTEXT_UNSET) {
1459 "create_subscription(..., options.sched_context)", topic);
1465 constexpr bool cb_takes_info =
1470 if (options.message_info && !cb_takes_info) {
1473 "create_subscription(..., options.message_info) with a callback taking no "
1474 "rclcpp::MessageInfo",
1480template <
typename M,
typename Cb>
1483 const ::rclcpp::SubscriptionOptions& options) {
1485 ::rclcpp::tr::forward_rvalue(cb), options);
1488template <
typename S>
1490 const ::rclcpp::QoS& qos) {
1498 "create_service", name);
1499 return ::rclcpp::Owned<::rclcpp::PollService<S>>(::rclcpp::tr::forward_rvalue(s));
1502template <
typename S,
typename F,
typename>
1504 const ::rclcpp::QoS& qos) {
1512 "create_service", name);
1516template <
typename S,
typename F,
typename,
typename>
1518 const ::rclcpp::QoS& qos) {
1519#if defined(NROS_CPP_HAS_SHARED_PTR)
1526 constexpr int shape = ::rclcpp::detail::service_ptr_shape<S, F>::value;
1527 constexpr int stateful = ::rclcpp::detail::stateful_service_shape<S, F>::value;
1528 static_assert(shape != 0 || stateful != 0 || ::rclcpp::detail::refuse<F>::value,
1529 NROS_RCLCPP_REFUSE_SERVICE_CALLBACK_SHAPE);
1532 this->
template register_hosted_service_<S>(
1533 s, name, ::rclcpp::tr::forward_rvalue(callback), qos,
1534 ::rclcpp::tr::integral_constant<
int, (shape != 0 ? 0 : 1)>()),
1535 "create_service", name);
1541 static_assert(::rclcpp::detail::refuse<F>::value, NROS_RCLCPP_REFUSE_SERVICE_CALLBACK_SHAPE);
1546#if defined(NROS_CPP_HAS_SHARED_PTR)
1547template <
typename S,
typename F>
1548inline Result Node::register_hosted_service_(
Service<S>& out,
const char* name, F callback,
1549 const ::rclcpp::QoS& qos,
1550 ::rclcpp::tr::integral_constant<int, 0>) {
1551 constexpr int shape = ::rclcpp::detail::service_ptr_shape<S, F>::value;
1552 return this->
template register_service_<S>(
1553 out, name, &::rclcpp::detail::shared_ptr_service_trampoline<S, shape>::call,
1554 ::rclcpp::detail::shared_ptr_service_context<S>(
1555 callback, ::rclcpp::tr::integral_constant<
int, (shape == 3 ? 3 : 2)>()),
1556 qos, ::rclcpp::ServiceOptions());
1559template <
typename S,
typename F>
1560inline Result Node::register_hosted_service_(Service<S>& out,
const char* name, F callback,
1561 const ::rclcpp::QoS& qos,
1562 ::rclcpp::tr::integral_constant<int, 1>) {
1563 constexpr int stateful = ::rclcpp::detail::stateful_service_shape<S, F>::value;
1564 using Fn = ::rclcpp::detail::StatefulServiceFn<S>;
1565 Fn captured(::rclcpp::detail::stateful_service_adapter<S, (stateful != 0 ? stateful : 1)>::wrap(
1566 ::rclcpp::tr::forward_rvalue(callback)));
1567 const Result r = this->
template register_service_<S>(
1568 out, name, &::rclcpp::detail::stateful_service_trampoline<S>::call,
nullptr, qos,
1569 ::rclcpp::ServiceOptions(), &captured,
sizeof(Fn),
1570 &::rclcpp::detail::stateful_service_trampoline<S>::destroy);
1573 captured.relinquish();
1579template <
typename S,
typename F>
1581 const ::rclcpp::QoS& qos,
1582 const ::rclcpp::CallbackGroup* group) {
1584 if (group !=
nullptr && group->get_name() !=
nullptr) {
1586 "create_service(..., named callback group)", name);
1588 return this->
template create_service<S>(name, ::rclcpp::tr::forward_rvalue(callback), qos);
1591template <
typename S>
1593 const ::rclcpp::QoS& qos) {
1601 "create_client", name);
1602 return ::rclcpp::Owned<::rclcpp::PollClient<S>>(::rclcpp::tr::forward_rvalue(c));
1605template <
typename S,
typename F,
typename>
1607 const ::rclcpp::QoS& qos) {
1616 "create_client", name);
1620template <
typename S,
typename F,
typename,
typename>
1622 static_assert(::rclcpp::detail::refuse<F>::value,
1623 NROS_RCLCPP_REFUSE_SHARED_PTR_SERVICE_CALLBACK);
1645 typedef char yes_t[1];
1646 typedef char no_t[2];
1647 template <
typename G>
1648 static yes_t& probe(G* g,
decltype((*g)(*
static_cast<const TimerInfo*
>(
nullptr)), 0));
1649 template <
typename G>
static no_t& probe(...);
1652 static const bool value =
sizeof(probe<F>(
nullptr, 0)) ==
sizeof(yes_t);
1658template <typename F, bool TakesInfo = timer_takes_info<F>::value>
struct TimerAdapter {
1661 const rcl_clock_type_t clock =
static_cast<rcl_clock_type_t
>(raw.clock_type);
1662 const TimerInfo info{Time(raw.expected_call_time, clock),
1663 Time(raw.actual_call_time, clock)};
1678 static constexpr tr::size_type
value = NROS_CPP_CALLBACK_CAPACITY;
1699template <
typename Cb>
1701 Duration period, Cb&& cb,
const char* verb,
1702 const CallbackGroup* group =
nullptr,
1703 bool autostart =
true) {
1704 using F =
typename tr::decay<Cb>::type;
1708 Capture captured(Adapter{tr::relay<Cb>(cb)});
1711 nros_cpp_timer_info_callback_t invoke = [](
const nros_cpp_timer_call_info_t* info,
void* ctx) {
1712 (*
static_cast<Capture*
>(ctx))(*info);
1714 nros_cpp_timer_callback_t destroy = [](
void* ctx) {
static_cast<Capture*
>(ctx)->clear(); };
1715 const int64_t ns = period.nanoseconds();
1716 const uint64_t ms = ns > 0 ?
static_cast<uint64_t
>(ns / 1000000) : uint64_t(0);
1717 size_t handle_id = 0;
1718 const nros_cpp_node_t* h = node.
ffi_handle();
1719 const char* group_name = group !=
nullptr ? group->get_name() :
nullptr;
1721 :
Result(nros_cpp_timer_create_capturing_with_info(
1722 h,
static_cast<uint8_t
>(clock_type), ms, invoke,
1723 reinterpret_cast<const uint8_t*
>(&captured),
sizeof(Capture),
1724 destroy, group_name, autostart, &handle_id));
1726 captured.relinquish();
1740template <
typename Cb>
1742 const ::rclcpp::CallbackGroup* group,
1744 return ::rclcpp::detail::register_timer_capturing(*
this, RCL_STEADY_TIME, period,
1745 ::rclcpp::tr::forward_rvalue(cb),
1746 "create_wall_timer", group, autostart);
1749#ifdef NROS_CPP_HAS_STD_CHRONO
1750template <
typename Rep,
typename Period,
typename Cb>
1752 Cb cb, const ::rclcpp::CallbackGroup* group,
1754 const auto ns = ::std::chrono::duration_cast<::std::chrono::nanoseconds>(period).count();
1755 return this->
create_wall_timer(::rclcpp::Duration::from_nanoseconds(
static_cast<int64_t
>(ns)),
1756 ::rclcpp::tr::forward_rvalue(cb), group, autostart);
1765inline ::rclcpp::Node&
as_node_ref(const ::rclcpp::Node::SharedPtr& n) {
1789template <
typename NodeT,
typename CallbackT>
1790inline ::rclcpp::TimerHandle
1791create_timer(NodeT&& node, ::rclcpp::Clock* clock, ::rclcpp::Duration period, CallbackT&& callback,
1792 const ::rclcpp::CallbackGroup* group =
nullptr,
bool autostart =
true) {
1794 const rcl_clock_type_t type =
1795 clock !=
nullptr ? clock->get_clock_type() : n.
get_clock()->get_clock_type();
1796 return ::rclcpp::detail::register_timer_capturing(n, type, period,
1797 ::rclcpp::tr::relay<CallbackT>(callback),
1798 "create_timer", group, autostart);
1801#ifdef NROS_CPP_HAS_STD_CHRONO
1807template <typename NodeT, typename Rep, typename Period, typename CallbackT>
1808inline ::rclcpp::TimerHandle
1809create_timer(NodeT&& node, ::rclcpp::Clock* clock, ::std::chrono::duration<Rep, Period> period,
1810 CallbackT&& callback, const ::rclcpp::CallbackGroup* group =
nullptr,
1811 bool autostart =
true) {
1812 const auto ns = ::std::chrono::duration_cast<::std::chrono::nanoseconds>(period).count();
1813 return create_timer(::rclcpp::tr::relay<NodeT>(node), clock,
1814 ::rclcpp::Duration::from_nanoseconds(
static_cast<int64_t
>(ns)),
1815 ::rclcpp::tr::relay<CallbackT>(callback), group, autostart);
1887 if (code == NROS_CPP_RET_UNSUPPORTED) {
1900template <
typename T>
1902 const char* param) {
1903 const char* n = (node !=
nullptr) ? node :
"?";
1904 const char* p = (param !=
nullptr) ? param :
"?";
1905 const int declared = node_param_type<T>::value;
1906 const char* want = ::rclcpp::declared_param_type_name(declared);
1911 if (node_param_get(h, param, i).
ok()) {
1912 if (declared == ::rclcpp::param_type::DOUBLE) {
1913 NROS_ERROR(
"node \"%s\": parameter \"%s\" is declared double but the launch value is "
1914 "the integer %lld; write %lld.0 in the YAML.",
1915 n, p,
static_cast<long long>(i),
static_cast<long long>(i));
1917 NROS_ERROR(
"node \"%s\": parameter \"%s\" is declared %s but the launch value is the "
1918 "integer %lld; write a %s value in the YAML.",
1919 n, p, want,
static_cast<long long>(i), want);
1921 }
else if (node_param_get(h, param, d).
ok()) {
1922 NROS_ERROR(
"node \"%s\": parameter \"%s\" is declared %s but the launch value is the "
1923 "double %g; write a %s value in the YAML.",
1924 n, p, want, d, want);
1925 }
else if (node_param_get(h, param, b).
ok()) {
1926 NROS_ERROR(
"node \"%s\": parameter \"%s\" is declared %s but the launch value is the "
1927 "bool %s; write a %s value in the YAML.",
1928 n, p, want, b ?
"true" :
"false", want);
1929 }
else if (node_param_get(h, param, str,
sizeof(str)).
ok()) {
1930 NROS_ERROR(
"node \"%s\": parameter \"%s\" is declared %s but the launch value is the "
1931 "string \"%s\"; write a %s value in the YAML.",
1932 n, p, want, str, want);
1934 NROS_ERROR(
"node \"%s\": parameter \"%s\" is declared %s but the launch value has "
1935 "another type; write a %s value in the YAML.",
1946 return default_value;
1948 const ::nros_cpp_node_t* h = this->
ffi_handle();
1949 Result r = ::rclcpp::detail::node_param_declare(h, name, default_value);
1950 if (!r.
ok() && r.
raw() != RCLC_RET_ALREADY_EXISTS) {
1952 return default_value;
1955 if (!::rclcpp::detail::node_param_get(h, name, out).
ok()) {
1956 if (r.
raw() == RCLC_RET_ALREADY_EXISTS) {
1961 return default_value;
1971 return ::rclcpp::detail::node_param_get(this->
ffi_handle(), name, out).ok();
1980 (void)::rclcpp::detail::node_param_get(this->
ffi_handle(), name, out);
1995 return ::rclcpp::detail::node_param_set(this->
ffi_handle(), name, value);
2003 return ::rclcpp::detail::node_param_has(this->
ffi_handle(), name);
2015template <
typename T>
2017 const ParameterDescriptor& descriptor) {
2025 (void)::rclcpp::detail::node_param_apply_descriptor(
2026 this->
ffi_handle(), name, descriptor, ::rclcpp::detail::node_param_type<T>::value);
2030template <
typename T>
2032 if (::rclcpp::detail::node_param_get(this->
ffi_handle(), name, out).
ok()) {
2040 return ::rclcpp::detail::node_param_undeclare(this->
ffi_handle(), name);
2045 if (!::rclcpp::detail::node_param_get_type(this->
ffi_handle(), name, code).
ok()) {
2046 return PARAMETER_NOT_SET;
2048 return static_cast<ParameterType
>(code);
2052 ParameterType* out)
const {
2053 if ((names ==
nullptr || out ==
nullptr) && count != 0) {
2054 return Result(RCL_RET_INVALID_ARGUMENT);
2056 for (::size_t i = 0; i < count; ++i) {
2059 return Result(RCL_RET_OK);
2063 ::size_t text_len)
const {
2064 out = parameter_descriptor();
2067 char* description =
nullptr;
2068 char* constraints =
nullptr;
2070 if (text !=
nullptr && text_len >= 2) {
2071 half = text_len / 2;
2073 constraints = text + half;
2076 Result r = ::rclcpp::detail::node_param_describe(this->
ffi_handle(), name, description, half,
2077 constraints, half, &out.read_only, &type);
2078 if (r.
raw() == RCLC_RET_NOT_FOUND) {
2081 out.description = description;
2082 out.additional_constraints = constraints;
2086 if (type == ::rclcpp::param_type::INTEGER) {
2088 ::rclcpp::detail::node_param_get_range(this->
ffi_handle(), name, &out.integer_from,
2089 &out.integer_to, &out.integer_step)
2091 }
else if (type == ::rclcpp::param_type::DOUBLE) {
2093 ::rclcpp::detail::node_param_get_range(this->
ffi_handle(), name, &out.double_from,
2094 &out.double_to, &out.double_step)
2101 ::size_t max_names, ::size_t& count)
const {
2102 return ::rclcpp::detail::node_param_list(this->
ffi_handle(), prefix, out_names, name_stride,
2107 return ::rclcpp::detail::node_params_set_atomically(this->
ffi_handle(), writes, count);
2112 OnSetParametersCallbackToken& out_handle) {
2113 return ::rclcpp::detail::node_param_add_on_set_callback(this->
ffi_handle(), callback, context,
2118 return ::rclcpp::detail::node_param_remove_on_set_callback(this->
ffi_handle(), handle);
2132template <
typename T>
2133inline T node_declare_typed(Node& n,
const char* name, T v,
const ParameterDescriptor* d) {
2134 return d !=
nullptr ? n.template declare_parameter<T>(name, v, *d)
2135 : n.template declare_parameter<T>(name, v);
2138inline ParameterValue node_declare_value(Node& n,
const char* name,
const ParameterValue& v,
2139 const ParameterDescriptor* d) {
2140 switch (v.get_type()) {
2141 case PARAMETER_BOOL:
2142 return ParameterValue(node_declare_typed<bool>(n, name, v.as_bool(), d));
2143 case PARAMETER_INTEGER:
2144 return ParameterValue(
2145 static_cast<long long>(node_declare_typed<int64_t>(n, name, v.as_int(), d)));
2146 case PARAMETER_DOUBLE:
2147 return ParameterValue(node_declare_typed<double>(n, name, v.as_double(), d));
2148 case PARAMETER_STRING:
2149 return ParameterValue(node_declare_typed<::std::string>(n, name, v.as_string(), d));
2150 case PARAMETER_BOOL_ARRAY:
2151 return ParameterValue(
2152 node_declare_typed<::std::vector<bool>>(n, name, v.as_bool_array(), d));
2153 case PARAMETER_INTEGER_ARRAY:
2154 return ParameterValue(
2155 node_declare_typed<::std::vector<int64_t>>(n, name, v.as_integer_array(), d));
2156 case PARAMETER_DOUBLE_ARRAY:
2157 return ParameterValue(
2158 node_declare_typed<::std::vector<double>>(n, name, v.as_double_array(), d));
2161 return ParameterValue();
2168template <
typename D>
inline ParameterDescriptor descriptor_from_message(
const D& m) {
2169 ParameterDescriptor d = ::rclcpp::parameter_descriptor();
2170 d.description = m.description.c_str();
2171 d.additional_constraints = m.additional_constraints.c_str();
2172 d.read_only = m.read_only;
2173 for (
const auto& r : m.floating_point_range) {
2175 d.double_from = r.from_value;
2176 d.double_to = r.to_value;
2177 d.double_step = r.step;
2180 for (
const auto& r : m.integer_range) {
2182 d.integer_from = r.from_value;
2183 d.integer_to = r.to_value;
2184 d.integer_step =
static_cast<int64_t
>(r.step);
2190inline Node::SetParametersOutcome node_set_outcome(Result r) {
2191 Node::SetParametersOutcome o;
2192 o.successful = r.ok();
2193 if (!o.successful) {
2194 o.reason =
"set_parameter refused (nano-ros code " + ::std::to_string(r.raw()) +
")";
2201inline ParameterValue Node::declare_parameter(
const char* name,
2202 const ParameterValue& default_value) {
2203 return ::rclcpp::detail::node_declare_value(*
this, name, default_value,
nullptr);
2206inline ParameterValue Node::declare_parameter(
const char* name,
const ParameterValue& default_value,
2207 const ParameterDescriptor& descriptor) {
2208 return ::rclcpp::detail::node_declare_value(*
this, name, default_value, &descriptor);
2211template <
typename D,
typename>
2212inline ParameterValue Node::declare_parameter(
const char* name,
const ParameterValue& default_value,
2213 const D& descriptor) {
2214 const ParameterDescriptor d = ::rclcpp::detail::descriptor_from_message(descriptor);
2215 return ::rclcpp::detail::node_declare_value(*
this, name, default_value, &d);
2218template <
typename T,
typename D,
typename>
2219inline T Node::declare_parameter(
const char* name, T default_value,
const D& descriptor) {
2220 const ParameterDescriptor d = ::rclcpp::detail::descriptor_from_message(descriptor);
2221 return this->
template declare_parameter<T>(name, default_value, d);
2224inline bool Node::get_parameter(
const char* name, Parameter& out)
const {
2226 switch (this->get_parameter_type(name)) {
2227 case PARAMETER_BOOL: {
2229 if (!this->
template get_parameter<bool>(name, x))
return false;
2230 v = ParameterValue(x);
2233 case PARAMETER_INTEGER: {
2235 if (!this->
template get_parameter<int64_t>(name, x))
return false;
2236 v = ParameterValue(
static_cast<long long>(x));
2239 case PARAMETER_DOUBLE: {
2241 if (!this->
template get_parameter<double>(name, x))
return false;
2242 v = ParameterValue(x);
2245 case PARAMETER_STRING: {
2247 if (!this->
template get_parameter<::std::string>(name, x))
return false;
2248 v = ParameterValue(x);
2251 case PARAMETER_BOOL_ARRAY: {
2252 ::std::vector<bool> x;
2253 if (!this->
template get_parameter<::std::vector<bool>>(name, x))
return false;
2254 v = ParameterValue(x);
2257 case PARAMETER_INTEGER_ARRAY: {
2258 ::std::vector<int64_t> x;
2259 if (!this->
template get_parameter<::std::vector<int64_t>>(name, x))
return false;
2260 v = ParameterValue(x);
2263 case PARAMETER_DOUBLE_ARRAY: {
2264 ::std::vector<double> x;
2265 if (!this->
template get_parameter<::std::vector<double>>(name, x))
return false;
2266 v = ParameterValue(x);
2272 out = Parameter(::std::string(name), v);
2276inline Parameter Node::get_parameter(const ::std::string& name)
const {
2278 (void)this->get_parameter(name.c_str(), p);
2282inline ::std::vector<Parameter>
2283Node::get_parameters(const ::std::vector<::std::string>& names)
const {
2284 ::std::vector<Parameter> out;
2285 out.reserve(names.size());
2286 for (
const auto& n : names) {
2287 out.push_back(this->get_parameter(n));
2292inline Node::SetParametersOutcome Node::set_parameter(
const Parameter& p) {
2293 const char* name = p.get_name().c_str();
2294 Result r(NROS_CPP_RET_UNSUPPORTED);
2295 switch (p.get_type()) {
2296 case PARAMETER_BOOL:
2297 r = this->
template set_parameter<bool>(name, p.as_bool());
2299 case PARAMETER_INTEGER:
2300 r = this->
template set_parameter<int64_t>(name, p.as_int());
2302 case PARAMETER_DOUBLE:
2303 r = this->
template set_parameter<double>(name, p.as_double());
2305 case PARAMETER_STRING:
2306 r = this->
template set_parameter<::std::string>(name, p.as_string());
2308 case PARAMETER_BOOL_ARRAY:
2309 r = this->
template set_parameter<::std::vector<bool>>(name, p.as_bool_array());
2311 case PARAMETER_INTEGER_ARRAY:
2312 r = this->
template set_parameter<::std::vector<int64_t>>(name, p.as_integer_array());
2314 case PARAMETER_DOUBLE_ARRAY:
2315 r = this->
template set_parameter<::std::vector<double>>(name, p.as_double_array());
2320 return ::rclcpp::detail::node_set_outcome(r);
2323inline ::std::vector<Node::SetParametersOutcome>
2324Node::set_parameters(const ::std::vector<Parameter>& parameters) {
2325 ::std::vector<SetParametersOutcome> out;
2326 out.reserve(parameters.size());
2327 for (
const auto& p : parameters) {
2328 out.push_back(this->set_parameter(p));
2333template <
typename F>
2334inline node_interfaces::OnSetParametersCallbackHandle::SharedPtr
2335Node::add_on_set_parameters_callback(F callback) {
2336 using Handle = node_interfaces::OnSetParametersCallbackHandle;
2337 auto handle = ::std::make_shared<Handle>();
2338 handle->callback = [callback](const ::std::vector<Parameter>& params)
mutable ->
bool {
2339 return static_cast<bool>(callback(params).successful);
2341 handle->node = this->ffi_handle();
2342 Result r = ::rclcpp::detail::node_param_add_on_set_callback(
handle->node, &Handle::trampoline,
2347 handle->registered =
true;
2351inline void Node::remove_on_set_parameters_callback(
2352 const node_interfaces::OnSetParametersCallbackHandle*
handle) {
2354 const_cast<node_interfaces::OnSetParametersCallbackHandle*
>(
handle)->unregister();
2358namespace node_interfaces {
2359inline bool NodeParametersInterface::has_parameter(const ::std::string& name)
const {
2360 return node_ !=
nullptr && node_->has_parameter(name);
2362inline ParameterValue NodeParametersInterface::declare_parameter(const ::std::string& name,
2363 const ParameterValue& v) {
2364 return node_ ==
nullptr ? ParameterValue() : node_->declare_parameter(name, v);
2366template <
typename D>
2367inline ParameterValue NodeParametersInterface::declare_parameter(const ::std::string& name,
2368 const ParameterValue& v,
2369 const D& descriptor) {
2370 return node_ ==
nullptr ? ParameterValue() : node_->declare_parameter(name, v, descriptor);
2372inline bool NodeParametersInterface::get_parameter(const ::std::string& name,
2373 Parameter& out)
const {
2374 return node_ !=
nullptr && node_->get_parameter(name, out);
2376inline Parameter NodeParametersInterface::get_parameter(const ::std::string& name)
const {
2377 return node_ ==
nullptr ? Parameter(name) : node_->get_parameter(name);
2379inline const ::std::map<::std::string, ParameterValue>&
2380NodeParametersInterface::get_parameter_overrides()
const {
2381 using Map = ::std::map<::std::string, ParameterValue>;
2385 static ::std::map<const void*, Map> copies;
2387 if (node_ ==
nullptr || node_->ffi_handle() ==
nullptr) {
2391 static bool add(
const ParameterWrite* write,
void* context) {
2392 if (write !=
nullptr && write->name !=
nullptr) {
2393 (*
static_cast<Map*
>(context))[write->name] =
2394 Parameter::from_write(*write).get_parameter_value();
2400 (void)::rclcpp::detail::node_param_list_overrides(node_->ffi_handle(), &Sink::add, &now,
2402 Map& kept = copies[node_->ffi_handle()];
2404 kept =
static_cast<Map&&
>(now);
2481 : period_ns_(frequency_hz > 0.0 ? static_cast<int64_t>(1000000000.0 / frequency_hz) : 0) {
2488 if (period_ns_ < 0) period_ns_ = 0;
2492#ifdef NROS_CPP_HAS_STD_CHRONO
2498 template <typename Rep, typename Period>
2499 explicit Rate(std::chrono::duration<Rep, Period>
period)
2500 : period_ns_(std::chrono::duration_cast<std::chrono::nanoseconds>(
period).count()) {
2501 if (period_ns_ < 0) period_ns_ = 0;
2512 if (period_ns_ <= 0) {
2516 if (now_ns >= next_tick_ns_) {
2522 next_tick_ns_ = now_ns +
static_cast<uint64_t
>(period_ns_);
2525 const uint64_t remaining_ns = next_tick_ns_ - now_ns;
2528 uint32_t remaining_ms =
static_cast<uint32_t
>((remaining_ns + 999999ull) / 1000000ull);
2529 if (remaining_ms == 0) remaining_ms = 1;
2530 next_tick_ns_ +=
static_cast<uint64_t
>(period_ns_);
2531 const int32_t poll_ms = remaining_ms < 10u ? static_cast<int32_t>(remaining_ms) : 10;
2545 ::rclcpp::Duration
period()
const { return ::rclcpp::Duration::from_nanoseconds(period_ns_); }
2549 uint64_t next_tick_ns_;
2563#include "rclcpp_action/create_client.hpp"
2564#include "rclcpp_action/create_server.hpp"
2567#include "rclcpp/parameter_event_handler.hpp"
::rclcpp::ClientHandle< S > SharedPtr
Definition client.hpp:142
Definition rclcpp.hpp:214
Context()
Definition rclcpp.hpp:217
Context(void *executor)
Definition rclcpp.hpp:218
Context SharedPtr
Definition rclcpp.hpp:216
Result add_pre_shutdown_callback(ShutdownCallback callback, void *context, PreShutdownCallbackHandle *out=nullptr)
The C-callback forms, on every target. See rclcpp::pre_shutdown.
Definition rclcpp.hpp:227
bool remove_pre_shutdown_callback(const PreShutdownCallbackHandle &handle)
true when handle named a live callback.
Definition rclcpp.hpp:245
Context * operator->()
Definition rclcpp.hpp:219
void * executor_handle() const
The executor handle this context names; null for an empty one.
Definition rclcpp.hpp:222
const Context * operator->() const
Definition rclcpp.hpp:220
bool remove_on_shutdown_callback(const OnShutdownCallbackHandle &handle)
Definition rclcpp.hpp:254
bool is_valid() const
Context::is_valid() — named, and not yet shut down.
Definition rclcpp.hpp:224
Result add_on_shutdown_callback(ShutdownCallback callback, void *context, OnShutdownCallbackHandle *out=nullptr)
Definition rclcpp.hpp:236
void add_node(const NodePtr &node, bool notify=true)
Definition rclcpp.hpp:1178
FutureReturnCode spin_until_future_complete(Future &&future, int32_t timeout_ms=-1)
Definition rclcpp.hpp:1172
Definition future.hpp:337
const nros_cpp_node_t * ffi_handle() const
Definition node.hpp:1919
Result get_parameter_types(const char *const *names, ::size_t count, ParameterType *out) const
Definition rclcpp.hpp:2051
Result add_on_set_parameters_callback(OnSetParametersCallbackType callback, void *context, OnSetParametersCallbackToken &out_handle)
Definition rclcpp.hpp:2110
::rclcpp::Owned<::rclcpp::PollService< S > > create_service(const char *name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
bool get_parameter(const char *name, T &out) const
Definition rclcpp.hpp:1970
typename::rclcpp::Subscription< M >::SharedPtr create_subscription(const char *topic, const ::rclcpp::QoS &qos, Cb cb)
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:2941
Result describe_parameter(const char *name, ParameterDescriptor &out, char *text, ::size_t text_len) const
Definition rclcpp.hpp:2062
T declare_parameter(const char *name, T default_value=T())
rclcpp::Node::declare_parameter<T>(name, default).
Definition rclcpp.hpp:1941
Result remove_on_set_parameters_callback(OnSetParametersCallbackToken handle)
rclcpp::Node::remove_on_set_parameters_callback(handle).
Definition rclcpp.hpp:2117
bool get_parameter_or(const char *name, T &out, T fallback) const
Definition rclcpp.hpp:2031
ParameterType get_parameter_type(const char *name) const
Definition rclcpp.hpp:2043
bool ok() const
Definition node.hpp:998
bool has_parameter(const char *name) const
rclcpp::Node::has_parameter(name).
Definition rclcpp.hpp:2002
void * executor_handle() const
Definition node.hpp:1943
Result list_parameters(const char *prefix, char *out_names, ::size_t name_stride, ::size_t max_names, ::size_t &count) const
Definition rclcpp.hpp:2100
::rclcpp::Handle< Node > SharedPtr
Definition node.hpp:1080
void set_error(const char *what, int32_t code)
Definition node.hpp:2973
const char * get_name() const
Get the node name.
Definition node.hpp:1783
Result set_parameters_atomically(const ParameterWrite *writes, ::size_t count)
Definition rclcpp.hpp:2106
::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)
Result set_parameter(const char *name, T value)
Definition rclcpp.hpp:1994
Clock * get_clock()
Definition node.hpp:1891
Result undeclare_parameter(const char *name)
Definition rclcpp.hpp:2039
::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:1403
Definition executor.hpp:91
Definition executor.hpp:84
Definition publisher.hpp:179
::rclcpp::Owned< Publisher< M > > SharedPtr
Definition publisher.hpp:203
Definition rclcpp.hpp:2476
bool sleep()
Definition rclcpp.hpp:2511
Rate(::rclcpp::Duration period)
Definition rclcpp.hpp:2487
Rate(double frequency_hz)
Definition rclcpp.hpp:2480
void reset()
rclcpp::Rate::reset() — anchor the next tick one period from now.
Definition rclcpp.hpp:2537
::rclcpp::Duration period() const
Definition rclcpp.hpp:2545
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 service.hpp:146
size_t handle_id() const
Executor arena slot for the registration; SIZE_MAX until registered.
Definition service.hpp:282
::rclcpp::ServiceHandle< S > SharedPtr
Definition service.hpp:158
::rclcpp::SubscriptionHandle< M > SharedPtr
Definition subscription.hpp:220
Definition rclcpp.hpp:1644
static const bool value
Definition rclcpp.hpp:1652
The refusal behind MultiThreadedExecutor; see that alias.
Definition rclcpp.hpp:1272
MultiThreadedExecutorRefused(Args &&...)
Definition rclcpp.hpp:1274
void spin_some(uint32_t max_ms=0)
Definition rclcpp.hpp:1264
void spin()
Block until rclcpp::ok() goes false — rclcpp::spin_in().
Definition rclcpp.hpp:1260
void remove_node(const NodePtr &node, bool notify=true)
REFUSED — remove_node; see rclcpp::Executor::remove_node.
Definition rclcpp.hpp:1218
FutureReturnCode spin_until_future_complete(Future &&future, int32_t timeout_ms=-1)
Definition rclcpp.hpp:1228
SingleThreadedExecutor()
Definition rclcpp.hpp:1207
void spin_node_once(const ::rclcpp::Node::SharedPtr &node, int32_t timeout_ms)
Definition rclcpp.hpp:1254
void spin_all(uint32_t max_duration_ms)
Definition rclcpp.hpp:1235
void add_node(const ::rclcpp::Node::SharedPtr &node, bool notify=true)
Definition rclcpp.hpp:1211
void spin_node_some(const ::rclcpp::Node::SharedPtr &node)
Definition rclcpp.hpp:1246
Node * node() const
The node this handle names (null for a default-constructed one).
Definition node.hpp:254
Context get_context() const
Definition rclcpp.hpp:337
rclcpp::Future<T> — single-shot deferred result.
int nros_cpp_ret_t
Definition future.hpp:25
nros_cpp_ret_t nros_cpp_spin_once(void *handle, int32_t timeout_ms)
uint64_t nros_cpp_time_ns(void)
Definition rclcpp.hpp:305
Context get_global_default_context()
Definition rclcpp.hpp:308
Definition rclcpp.hpp:437
void check_node_on_executor(const NodePtr &node, void *executor, bool process)
The add_node check, against one executor handle.
Definition rclcpp.hpp:1150
Subscription< M >::SharedPtr create_subscription_dispatch(::rclcpp::Node &node, const char *topic, const ::rclcpp::QoS &qos, Cb cb, ::rclcpp::tr::false_type)
The one-argument callback path (void(const M&), or a hosted pointer shape).
Definition rclcpp.hpp:1340
constexpr const char * PARAM_VALUE_TYPE_MISMATCH_WHAT
The set_error text for a declaration whose value in effect has another type.
Definition node.hpp:683
void abort_failed_create(const char *verb, const char *name, int32_t code)
Definition rclcpp.hpp:497
@ SUB_SHAPE_NONE
Definition subscription.hpp:719
void require_created(::rclcpp::Result r, const char *verb, const char *name)
Definition rclcpp.hpp:512
void report_param_value_type_mismatch(const ::nros_cpp_node_t *h, const char *node, const char *param)
Definition rclcpp.hpp:1901
TimerHandle register_timer_capturing(::rclcpp::Node &node, rcl_clock_type_t clock_type, Duration period, Cb &&cb, const char *verb, const CallbackGroup *group=nullptr, bool autostart=true)
Definition rclcpp.hpp:1700
constexpr bool is_ros_args_flag(char const *s, int i=0)
Definition rclcpp.hpp:444
constexpr const char * PARAM_STORE_FULL_WHAT
Definition node.hpp:674
void refuse_param_declare(Node &node, int32_t code)
Definition rclcpp.hpp:1886
constexpr int32_t PARAM_VALUE_TYPE_MISMATCH
Definition node.hpp:669
int32_t apply_ros_args(void *executor, int argc, char const *const *argv)
Definition node.hpp:3572
Result register_subscription_capturing_message_info(::rclcpp::Node &node, const char *topic, const QoS &qos, const Fn &fn, size_t *out_handle_id)
Definition subscription.hpp:900
inline ::rclcpp::Node & as_node_ref(const ::rclcpp::Node::SharedPtr &n)
Definition rclcpp.hpp:1765
Result register_subscription_capturing(::rclcpp::Node &node, const char *topic, const QoS &qos, const Fn &fn, size_t *out_handle_id)
Definition subscription.hpp:935
FutureReturnCode spin_executor_until_future_complete(void *executor, Future &future, int32_t timeout_ms, bool process)
Definition rclcpp.hpp:1132
constexpr const char * PARAM_DECLARE_REFUSED_WHAT
The set_error text for any other refusal of a declaration.
Definition node.hpp:679
bool future_is_ready(F &f)
Definition rclcpp.hpp:1077
constexpr bool argv_has_ros_args(int argc, char const *const *argv, int i=0)
Definition rclcpp.hpp:451
Definition rclcpp.hpp:1184
MultiThreadedExecutorRefused<> MultiThreadedExecutor
Definition rclcpp.hpp:1288
Definition rclcpp.hpp:336
NodeInterfaceHandle< 0 > NodeBaseInterface
Definition node.hpp:268
constexpr uint32_t kTraceAppMarkerFirst
First application trace marker id (see trace_marker).
Definition rclcpp.hpp:118
Rate WallRate
Definition rclcpp.hpp:2554
void(*)(void *context) ShutdownCallback
Definition executor.hpp:47
void spin(const Node::SharedPtr &node)
Definition rclcpp.hpp:1016
void spin_some(const Node::SharedPtr &node)
Definition rclcpp.hpp:1029
inline ::rclcpp::TimerHandle create_timer(NodeT &&node, ::rclcpp::Clock *clock, ::rclcpp::Duration period, CallbackT &&callback, const ::rclcpp::CallbackGroup *group=nullptr, bool autostart=true)
Definition rclcpp.hpp:1791
Result init_in(const char *locator=nullptr, uint8_t domain_id=0)
Definition node.hpp:3379
Result spin_once(int32_t timeout_ms=10)
Definition rclcpp.hpp:97
FutureReturnCode
Definition rclcpp.hpp:608
@ TIMEOUT
The deadline passed with the future still pending.
Definition rclcpp.hpp:611
@ INTERRUPTED
rclcpp::ok() went false (shutdown) before the future was ready.
Definition rclcpp.hpp:613
@ SUCCESS
Definition rclcpp.hpp:609
void init()
rclcpp::init() — the zero-argument form. ADOPT.
Definition rclcpp.hpp:561
FutureReturnCode spin_until_future_complete(const Node::SharedPtr &node, Future &&future, int32_t timeout_ms=-1)
Definition rclcpp.hpp:1094
bool remove_on_shutdown_callback(OnShutdownCallbackHandle handle)
Definition rclcpp.hpp:197
bool ok()
Definition node.hpp:3641
Result spin_in()
Definition rclcpp.hpp:350
Result trace_marker(uint32_t id, uint32_t arg)
Definition rclcpp.hpp:132
void * global_handle()
Definition node.hpp:3562
Result on_shutdown(ShutdownCallback callback, void *context=nullptr, OnShutdownCallbackHandle *out=nullptr)
Definition rclcpp.hpp:175
bool shutdown()
Definition rclcpp.hpp:578
constexpr uint32_t kTraceAppMarkerLast
Definition rclcpp.hpp:121
bool remove_pre_shutdown_callback(PreShutdownCallbackHandle handle)
Definition rclcpp.hpp:189
void arm_monitors()
Definition rclcpp.hpp:113
@ NotInitialized
Definition result.hpp:131
@ Unsupported
Operation not implemented by the active backend.
Definition result.hpp:152
Result pre_shutdown(ShutdownCallback callback, void *context=nullptr, PreShutdownCallbackHandle *out=nullptr)
Definition rclcpp.hpp:156
ResultOf< void > Result
Definition result.hpp:247
rclcpp::Node and global session helpers.
rclcpp::Publisher<M> — typed topic publisher.
rclcpp::QoS — full DDS-shaped QoS settings.
rclcpp::Client<S> — the arena-registered (callback-style) service client, and Client<S>::SharedPtr = ...
**auto handle
Definition client.hpp:127
rclcpp::Result, rclcpp::ErrorCode, and the RCLCPP_TRY macro.
rclcpp::Service<S> — the arena-registered (callback-style) service server, and Service<S>::SharedPtr ...
rclcpp::Stream<T> — multi-shot message receiver.
void operator()(const nros_cpp_timer_call_info_t &)
Definition rclcpp.hpp:1669
F f
Definition rclcpp.hpp:1668
Definition rclcpp.hpp:1658
F f
Definition rclcpp.hpp:1659
void operator()(const nros_cpp_timer_call_info_t &raw)
Definition rclcpp.hpp:1660
Definition subscription.hpp:767
Which SubscriptionCallbackShape the callable F is, for message M.
Definition subscription.hpp:761
Definition subscription.hpp:874
Definition subscription.hpp:855
static constexpr tr::size_type value
Definition rclcpp.hpp:1681
Definition rclcpp.hpp:1677
static constexpr tr::size_type value
Definition rclcpp.hpp:1678
rclcpp::Subscription<M> — the typed DISPATCH subscriber: the arena owns it and the executor calls you...