nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
rclcpp::NodeHandle Struct Reference

#include <node.hpp>

Public Member Functions

constexpr NodeHandle ()
 
constexpr NodeHandle (void *exec)
 
constexpr NodeHandle (void *exec, const char *name, const char *ns)
 
constexpr NodeHandle (void *exec, const char *name, const char *ns, const nros_cpp_qos_override_t *overrides, size_t override_count)
 
constexpr const char * resolve_name (const char *fallback) const
 
constexpr const char * resolve_namespace (const char *fallback) const
 The launch namespace if one was declared, else fallback.
 
constexpr bool valid () const
 

Public Attributes

void * executor
 
const char * launch_name
 
const char * launch_namespace
 Launch-declared namespace, same contract.
 
size_t qos_override_count
 Entries in qos_overrides; 0 = none.
 
const nros_cpp_qos_override_t * qos_overrides
 

Detailed Description

Executor-bound node handle the generated entry hands to a node constructor (RFC-0044 §Design.1, merged onto Node by phase-427 W4).

Carries the opaque executor handle the node is created against — the same pointer rclcpp::global_handle() / Node::executor_handle() expose. The entry obtains it post-init and placement-news the component with it.

This was nros::ComponentNode's ctor parameter. ComponentNode is gone; the handle is not, because construction against an EXPLICIT executor is a real capability and the generated entry is its caller. It is the second of the type's TWO constructors — RFC-0047's "one component, several named nodes" does not exist (a component owns exactly one node; what the subnode packages exercise is several named CALLBACK GROUPS), so there is no third.

Issue 1456 — it also carries the node's LAUNCH-DECLARED IDENTITY, and that is what makes an rclcpp-shape component reachable from a launch file at all. That shape constructs its own node (Comp(h) : Node(h, "talker")), so the entry has no create_node call to pass a name and a namespace to — the only thing it hands the component is this handle. Measured before the fix, on a real bus, for a plan declaring name="alpha" namespace="/island": ros2 node list answered /rclcpp_class_name and the component's relative topics resolved at the ROOT, beside a configure-shape sibling in the SAME image answering /island/beta.

This is the NodeOptions seam, in the one place this API has for it. Upstream's component container passes the launch identity into a component through rclcpp::NodeOptions (--ros-args -r __node:=… -r __ns:=…), where the remap OUTRANKS the name the class's constructor writes; the handle is the value our entry hands a component, so the identity rides here and Node's handle constructor applies the same precedence. No user component's signature changes — explicit Comp(rclcpp::NodeHandle) is still the one shape, and a handle built the 1-argument way declares nothing.

nullptr is "the launch file declared none", NOT the empty name or the root: it keeps meaning what it means everywhere else in this header, and the class's own literal stands. "" says the same thing, because an empty C string cannot be told apart from "unset" at this edge (the rule rclcpp::init's node_namespace already states for the session).

Constructor & Destructor Documentation

◆ NodeHandle() [1/4]

constexpr rclcpp::NodeHandle::NodeHandle ( )
inlineconstexpr

◆ NodeHandle() [2/4]

constexpr rclcpp::NodeHandle::NodeHandle ( void *  exec)
inlineexplicitconstexpr

◆ NodeHandle() [3/4]

constexpr rclcpp::NodeHandle::NodeHandle ( void *  exec,
const char *  name,
const char *  ns 
)
inlineconstexpr

The generated entry's constructor: the executor plus whatever the launch file DECLARED. Pass nullptr for a half it did not.

◆ NodeHandle() [4/4]

constexpr rclcpp::NodeHandle::NodeHandle ( void *  exec,
const char *  name,
const char *  ns,
const nros_cpp_qos_override_t *  overrides,
size_t  override_count 
)
inlineconstexpr

The same, plus the node's baked QoS override table (issue 1854). The generated entry writes this form only for a node whose plan carries overrides, so an entry without any reads exactly as before.

Member Function Documentation

◆ resolve_name()

constexpr const char * rclcpp::NodeHandle::resolve_name ( const char *  fallback) const
inlineconstexpr

The launch name if one was declared, else fallback — the component class's own literal. See the type comment for why launch wins.

◆ resolve_namespace()

constexpr const char * rclcpp::NodeHandle::resolve_namespace ( const char *  fallback) const
inlineconstexpr

The launch namespace if one was declared, else fallback.

◆ valid()

constexpr bool rclcpp::NodeHandle::valid ( ) const
inlineconstexpr

Member Data Documentation

◆ executor

void* rclcpp::NodeHandle::executor

◆ launch_name

const char* rclcpp::NodeHandle::launch_name

Launch-declared node name, or nullptr/"" when the launch file named none. Must outlive the node's construction; the generated entry emits a string literal.

◆ launch_namespace

const char* rclcpp::NodeHandle::launch_namespace

Launch-declared namespace, same contract.

◆ qos_override_count

size_t rclcpp::NodeHandle::qos_override_count

Entries in qos_overrides; 0 = none.

◆ qos_overrides

const nros_cpp_qos_override_t* rclcpp::NodeHandle::qos_overrides

Issue 1854 – the node's baked QoS override table (the plan's qos_overrides.<topic>.<role>.<policy> parameters, lowered by nros_orchestration_ir::qos_override), or nullptr when it has none. The configure and c shapes get theirs from the entry's own set_qos_overrides call after create_node; this shape constructs its node AND its entities in the component's constructor, before the entry could make that call, so the table rides on the handle and Node's handle constructor installs it right after the node opens – before the derived constructor creates anything. Must outlive the node; the generated entry passes a static const array.


The documentation for this struct was generated from the following file: