|
nros C API
Lightweight ROS 2 client for embedded real-time systems
|
#include <nros_generated.h>
Data Fields | |
| bool | executor_bound |
| uint32_t | generation |
| uint8_t | node_id |
phase-379 W4 — a checkable reference to the node an entity was created on.
Replaces the *const rcl_node_t each entity used to store. That pointer was never dereferenced anywhere in the C API — it was assigned, nulled, and asserted on — so it bought provenance nobody could use while leaving a raw pointer that invites a dereference the platform cannot support:
rcl's alternative (rcl_publisher_fini(&pub, &node)) does not remove that assumption; it relocates it to a caller who cannot check it either.
So the entity stores an IDENTITY instead: the executor slot the node is bound to, plus the generation that slot carried when the entity was created. rcl_node_fini bumps the generation, which makes "finalise an entity after its node" a return code rather than a silent success.
generation == 0 is reserved and never issued, so a zeroed struct — the common C mistake — can never resolve.
| bool rclc_node_ref_t::executor_bound |
Was the node bound to an EXECUTOR (rclc_executor_node_init) rather than initialised on the legacy support path? (issue 1405)
Both carry slot 0 when they are the first node, so node_id alone cannot say whether there is a NodeRecord to register under. The registration paths used node_id != 0 for that, which sent an executor's PRIMARY node down the legacy arm: its entities registered on session 0 even when the node itself lives on another session. This field occupies what was padding, so the struct's size and alignment are unchanged, and a zeroed struct reads as "not executor-bound".
| uint32_t rclc_node_ref_t::generation |
Slot generation when the entity was created. 0 = no node bound.
| uint8_t rclc_node_ref_t::node_id |
Executor node slot (rcl_node_t::node_id). 0 = the primary node.