|
nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
|
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 & > |
Variables | |
| constexpr int32_t | DECLARED_DEPTH_MISMATCH = -403 |
| constexpr int32_t | DECLARED_PARAM_MISMATCH = -446 |
| constexpr int32_t | DECLARED_QOS_MISMATCH = DECLARED_DEPTH_MISMATCH |
|
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"):
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.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.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.
|
inline |
|
constexpr |
| inline ::rclcpp::Node & rclcpp::detail::as_node_ref | ( | ::rclcpp::Node & | n | ) |
| inline ::rclcpp::Node & rclcpp::detail::as_node_ref | ( | ::rclcpp::Node * | n | ) |
| 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.
The contract spelling of a durability ordinal, for the report above.
The contract spelling of a reliability ordinal, for the report above.
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.
|
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.
The inverse: the C ABI's milliseconds as a Duration. Exact, and exact in both directions — qos_window_ms(qos_window_duration(ms)) == ms.
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.UINT32_MAX ms (~49.7 days) → UINT32_MAX, saturating rather than wrapping into a short window.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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", ...).
|
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.
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.
phase-446 W6 – the code set_error records when a node declares a parameter its contract does not declare, or with another type.
|
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.