nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
Classes | Functions | Variables
rclcpp::detail Namespace Reference

Classes

struct  action_endpoint_hashes_of
 
struct  action_endpoint_hashes_of< A, typename nros_void_< decltype(A::SEND_GOAL_SERVICE_HASH)>::type >
 
class  is_qos_arg
 
struct  nros_void_
 
struct  qos_arg_strip
 
struct  qos_arg_strip< const F & >
 
struct  qos_arg_strip< const F >
 
struct  qos_arg_strip< F & >
 

Functions

void abort_failed_create (const char *verb, const char *name, int32_t code)
 
template<class A >
nros_cpp_action_hashes_t action_endpoint_hashes ()
 
constexpr bool argv_has_ros_args (int argc, char const *const *argv, int i=0)
 
inline ::rclcpp::Node & as_node_ref (::rclcpp::Node &n)
 
inline ::rclcpp::Node & as_node_ref (::rclcpp::Node *n)
 
inline ::rclcpp::Node & as_node_ref (const ::rclcpp::Node::SharedPtr &n)
 
const char * declared_durability_spelling (int ordinal)
 The contract spelling of a durability ordinal, for the report above.
 
const char * declared_reliability_spelling (int ordinal)
 The contract spelling of a reliability ordinal, for the report above.
 
constexpr bool is_ros_args_flag (char const *s, int i=0)
 
constexpr QoS qos_from_ffi (const nros_cpp_qos_t &f)
 
constexpr Duration qos_window_duration (uint32_t ms)
 
constexpr uint32_t qos_window_ms (const Duration &d)
 
template<typename Cb >
TimerHandle register_timer_capturing (::rclcpp::Node &node, rcl_clock_type_t clock_type, Duration period, Cb &&cb, const char *verb)
 
void report_callback_group_mismatch (const char *node_name, const char *how, const char *name, int len, const char *list)
 
void report_component_failure (const char *node_name, const char *what, int32_t code)
 
void report_declared_depth_mismatch (const char *node_name, const char *topic, int declared, int passed)
 
void report_declared_param_mismatch (const char *fqn, const char *param, const char *contract, int declared, int passed)
 
void report_declared_policy_mismatch (const char *node_name, const char *topic, const char *policy, const char *declared, const char *passed)
 
void require_created (::rclcpp::Result r, const char *verb, const char *name)
 

Variables

constexpr int32_t DECLARED_DEPTH_MISMATCH = -403
 
constexpr int32_t DECLARED_PARAM_MISMATCH = -446
 
constexpr int32_t DECLARED_QOS_MISMATCH = DECLARED_DEPTH_MISMATCH
 

Function Documentation

◆ abort_failed_create()

void rclcpp::detail::abort_failed_create ( const char *  verb,
const char *  name,
int32_t  code 
)
inline

What upstream's throw becomes here — phase-428 W5 finding 9.

The create_* verbs on rclcpp::Node (then nros::Node, reached as rclcpp::Node through an alias since phase-427 W1-W3) used to write (void)this->create_…(…) and return the shared_ptr regardless. The (void) was not incidental: rclcpp::Result carries [[nodiscard]] (result.hpp, phase-428 W6), and the casts SUPPRESSED the one signal that existed. Measured, because the claim is easy to overstate: no C++ lane in this tree compiles with -Werror, so a bare discard here is a -Wunused-result WARNING and just check cpp stays green through it — the Rust-side -D warnings has no C++ counterpart. Even at full strength it would only have told the AUTHOR of this header, never the porting user, which is why the fix is a runtime refusal rather than a lint.

Every alternative was weighed against RFC-0089 Part I ("a difference must be one the compiler points at, and where it cannot be, it must be loud by other means"):

  • a Result-returning overload makes the compiler point at it — and at every SUCCEEDING call too, so a ported auto pub = node->create_publisher <M>("chatter", 10); no longer compiles. That trades clause 2 (port upstream: same name, same shape) for a diagnostic on the path that is not broken. Rejected.
  • a null shared_ptr says nothing at compile time and, at runtime, says nothing either: create_wall_timer's result is stored and never dereferenced, so a null there is a timer that silently never fires — the same "reads as success" one level down. Rejected.
  • an ok() flag on the node is opt-in, and a ported file never asks. It would also be a member written by us and read by nobody, which is finding 10 in the same sweep. Rejected.

So: the loudest thing available, at the earliest point the defect is knowable, which is the CALL. This is the identical shape rclcpp::init(argc, argv) uses for --ros-args a few lines below, and it is what an uncaught upstream throw actually does to a tutorial main — terminate with a diagnostic, rather than continue with a dead object.

The failure is still HANDLEABLE: the underlying out-ref rclcpp::Node verbs return rclcpp::Result into caller-owned storage, and the message names them.

◆ action_endpoint_hashes()

template<class A >
nros_cpp_action_hashes_t rclcpp::detail::action_endpoint_hashes ( )
inline

◆ argv_has_ros_args()

constexpr bool rclcpp::detail::argv_has_ros_args ( int  argc,
char const *const *  argv,
int  i = 0 
)
constexpr

◆ as_node_ref() [1/3]

inline ::rclcpp::Node & rclcpp::detail::as_node_ref ( ::rclcpp::Node &  n)

◆ as_node_ref() [2/3]

inline ::rclcpp::Node & rclcpp::detail::as_node_ref ( ::rclcpp::Node *  n)

◆ as_node_ref() [3/3]

inline ::rclcpp::Node & rclcpp::detail::as_node_ref ( const ::rclcpp::Node::SharedPtr &  n)

NodeT in upstream's signature is anything node-shaped — this, a reference, or (hosted) a shared_ptr, whose overload is in the hosted block above. One overload set, so the free function does not need three copies. phase-482 W2 — Node::SharedPtr is a freestanding handle.

◆ declared_durability_spelling()

const char * rclcpp::detail::declared_durability_spelling ( int  ordinal)
inline

The contract spelling of a durability ordinal, for the report above.

◆ declared_reliability_spelling()

const char * rclcpp::detail::declared_reliability_spelling ( int  ordinal)
inline

The contract spelling of a reliability ordinal, for the report above.

◆ is_ros_args_flag()

constexpr bool rclcpp::detail::is_ros_args_flag ( char const *  s,
int  i = 0 
)
constexpr

Does this argv carry --ros-args? Factored out of init so the decision is TESTABLE: an abort inside init can only be exercised by a process that then dies, which is the shape of a check nothing ever runs. constexpr, and that is the point: it makes the predicate assertable with a static_assert, so its cases run in every check cpp with no link and no process. std::strcmp is not constexpr in C++14, hence the open-coded compare.

◆ qos_from_ffi()

constexpr QoS rclcpp::detail::qos_from_ffi ( const nros_cpp_qos_t &  f)
constexpr

issue 1437 — declared here, defined below QoS, and named as a friend of it. See the definition for what it is for and why it is the one function in this header that writes QoS's members.

The inverse of qos_to_ffi — issue 1437.

Used by the get_actual_qos() family, which is the only direction that produces a profile the CALLER did not write. The four static_casts are the same value-for-value mirror qos_to_ffi relies on in the other direction: rclcpp::ReliabilityPolicy and nros_cpp_qos_reliability_t agree enumerator for enumerator, sentinels included, and the static_asserts in tests/compile/qos_policy_accessors.cpp measure that rather than trusting it. Neither vocabulary is the RMW ABI's, whose numbering differs from both in all four enums — nothing here may be cast to an NROS_RMW_* value.

Writes QoS's members directly — see the friend declaration on the class for why this one function may and no setter can. The three windows are stored as the milliseconds the ABI carries, so the round-trip through qos_to_ffi is exact.

◆ qos_window_duration()

constexpr Duration rclcpp::detail::qos_window_duration ( uint32_t  ms)
constexpr

The inverse: the C ABI's milliseconds as a Duration. Exact, and exact in both directions — qos_window_ms(qos_window_duration(ms)) == ms.

◆ qos_window_ms()

constexpr uint32_t rclcpp::detail::qos_window_ms ( const Duration &  d)
constexpr

Milliseconds one QoS window is worth, at the Duration → C-ABI boundary.

The C ABI is uint32_t milliseconds (nros_cpp_qos_t.deadline_ms and siblings) and 0 there means INFINITE, so truncation is not a rounding question — a 500 µs deadline truncated to 0 would silently mean "no deadline at all". So:

  • <= 0 → 0. A non-positive window is the "unset" spelling (Duration() / Duration::zero()), and 0 is the ABI's infinity.
  • otherwise ROUND UP to the next whole millisecond. A sub-millisecond window becomes 1 ms rather than infinity, and rounding up is the lenient direction for all three policies (a longer deadline, lifespan or lease never turns a working profile into a violated one).
  • above UINT32_MAX ms (~49.7 days) → UINT32_MAX, saturating rather than wrapping into a short window.

◆ register_timer_capturing()

template<typename Cb >
TimerHandle rclcpp::detail::register_timer_capturing ( ::rclcpp::Node &  node,
rcl_clock_type_t  clock_type,
Duration  period,
Cb &&  cb,
const char *  verb 
)
inline

Register cb as a timer on clock_type, its callable held by the arena.

The bridge between rclcpp::InplaceFn and nros_cpp_timer_create_capturing, the timer twin of register_subscription_capturing. The InplaceFn's bytes are COPIED into the arena; on success this object relinquishes them without destroying, because the arena's copy now owns the callable and its destroy hook runs clear() on that copy when the timer is released. A capture that owns something (a std::string, a shared_ptr) is destroyed exactly once, there.

◆ report_callback_group_mismatch()

void rclcpp::detail::report_callback_group_mismatch ( const char *  node_name,
const char *  how,
const char *  name,
int  len,
const char *  list 
)
inline

phase-459 W6 – the boot-time diagnostic for a callback group the code and the registration's CALLBACK_GROUPS disagree on. how is "created" (the code made a group the keyword did not declare) or "declared" (the keyword declared one the constructor never made). Names both sides: the group, and the declared list it was checked against. name is not NUL-terminated at len when it points into that list.

◆ report_component_failure()

void rclcpp::detail::report_component_failure ( const char *  node_name,
const char *  what,
int32_t  code 
)
inline

Boot-failure diagnostic (RFC-0044 Q2, refined in 242.4; moved off ComponentNode onto Node by phase-427 W4).

A failed entity/param creation in a node constructor is unrecoverable on firmware (boot is all-or-nothing) — but the constructor does not abort. It records the ok() latch and the generated entry / single-node carrier checks it post-construct, then halts boot naming the failing node via this helper. Hosted builds also print to stderr; freestanding builds get the overridable sink, whose default is nros_log (issue 1576). NOT [[noreturn]] — the caller decides how to halt.

◆ report_declared_depth_mismatch()

void rclcpp::detail::report_declared_depth_mismatch ( const char *  node_name,
const char *  topic,
int  declared,
int  passed 
)
inline

The boot-time diagnostic for that disagreement — the runtime twin of the static_assert, and it prints the same three facts: the topic, the depth the declaration states, and the depth the code passed.

◆ report_declared_param_mismatch()

void rclcpp::detail::report_declared_param_mismatch ( const char *  fqn,
const char *  param,
const char *  contract,
int  declared,
int  passed 
)
inline

The boot-time diagnostic for that disagreement. It names the node, the parameter and the contract, and for a type mismatch both types, because set_error records one const char* and a boot failure that says only "parameter disagrees" leaves the reader to grep two files for the pair.

◆ report_declared_policy_mismatch()

void rclcpp::detail::report_declared_policy_mismatch ( const char *  node_name,
const char *  topic,
const char *  policy,
const char *  declared,
const char *  passed 
)
inline

The boot-time diagnostic for a POLICY disagreement. policy is "reliability" or "durability"; declared and passed are the contract's own spellings ("best_effort", "transient_local", ...).

◆ require_created()

void rclcpp::detail::require_created ( ::rclcpp::Result  r,
const char *  verb,
const char *  name 
)
inline

The one spelling every create_* verb uses. Takes the Result by value so the [[nodiscard]] is consumed HERE and cannot be silently dropped again.

Variable Documentation

◆ DECLARED_DEPTH_MISMATCH

constexpr int32_t rclcpp::detail::DECLARED_DEPTH_MISMATCH = -403
constexpr

phase-403 step 2 — the code set_error records when a subscription's QoS depth disagrees with the depth its system's contract declared.

Named after the phase rather than borrowed from nros_cpp_ret_t: this is not a backend failure, it is the image contradicting its own manifest, and a code that also means "the RMW said no" would send the reader to the wrong half of the tree.

◆ DECLARED_PARAM_MISMATCH

constexpr int32_t rclcpp::detail::DECLARED_PARAM_MISMATCH = -446
constexpr

phase-446 W6 – the code set_error records when a node declares a parameter its contract does not declare, or with another type.

◆ DECLARED_QOS_MISMATCH

constexpr int32_t rclcpp::detail::DECLARED_QOS_MISMATCH = DECLARED_DEPTH_MISMATCH
constexpr

issue 1256 – the code set_error records when a subscription's QoS RELIABILITY or DURABILITY disagrees with what its contract declared. The same number as DECLARED_DEPTH_MISMATCH: both are the image contradicting its own contract, and the FFI seam reports either as -403. The diagnostic printed beside it names which policy.