|
nros C API
Lightweight ROS 2 client for embedded real-time systems
|
#include <nros_generated.h>
Data Fields | |
| uint32_t | generation |
| uint8_t | node_id |
phase-379 W4 — a checkable reference to the node an entity was created on.
Replaces the *const nros_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:
.bss), butvTaskDelete, andnros_node_t a = b; is legal and silent — C has no move semantics, and we have no allocator to hide an indirection behind.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. nros_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.
| uint32_t nros_node_ref_t::generation |
Slot generation when the entity was created. 0 = no node bound.
| uint8_t nros_node_ref_t::node_id |
Executor node slot (nros_node_t::node_id). 0 = the primary node.