|
| Result | add_on_shutdown_callback (ShutdownCallback callback, void *context=nullptr, OnShutdownCallbackHandle *out=nullptr) |
| |
| Result | add_pre_shutdown_callback (ShutdownCallback callback, void *context=nullptr, PreShutdownCallbackHandle *out=nullptr) |
| |
| Result | count_publishers (const char *topic_name, size_t *out_count) |
| |
| Result | count_subscribers (const char *topic_name, size_t *out_count) |
| |
| Result | create_node (Node &out, const char *name, const char *ns=nullptr) |
| |
| | Executor () |
| | Default constructor — creates an uninitialized executor.
|
| |
| | Executor (Executor &&other) |
| |
| Result | get_client_names_and_types_by_node (const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) |
| | phase-381 W4 — what services one named node CALLS, with the types.
|
| |
| Result | get_node_names (nros_cpp_node_visit_fn visit, void *ctx) |
| |
| Result | get_publisher_names_and_types_by_node (const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) |
| | phase-381 W4 — what one named node PUBLISHES, with the types.
|
| |
| Result | get_publishers_info_by_topic (const char *topic_name, nros_cpp_endpoint_info_visit_fn visit, void *ctx) |
| |
| Result | get_service_names_and_types (nros_cpp_names_and_types_visit_fn visit, void *ctx) |
| |
| Result | get_service_names_and_types_by_node (const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) |
| | phase-381 W4 — what services one named node SERVES, with the types.
|
| |
| Result | get_subscription_names_and_types_by_node (const char *node_name, const char *node_namespace, nros_cpp_names_and_types_visit_fn visit, void *ctx) |
| |
| Result | get_subscriptions_info_by_topic (const char *topic_name, nros_cpp_endpoint_info_visit_fn visit, void *ctx) |
| | phase-381 W4 — the subscriptions on topic_name, one visit each.
|
| |
| Result | get_topic_names_and_types (nros_cpp_names_and_types_visit_fn visit, void *ctx) |
| |
| void * | handle () |
| |
| NodeBuilder | node_builder (const char *name) |
| |
| bool | ok () const |
| | Check if the executor is initialized.
|
| |
| Executor & | operator= (Executor &&other) |
| |
| Result | ping (int32_t timeout_ms) |
| |
| bool | remove_on_shutdown_callback (OnShutdownCallbackHandle handle) |
| |
| bool | remove_pre_shutdown_callback (PreShutdownCallbackHandle handle) |
| |
| Result | shutdown () |
| | Shut down the executor and close the middleware connection.
|
| |
| Result | spin (int32_t poll_ms=10) |
| |
| Result | spin (uint32_t duration_ms, int32_t poll_ms) |
| |
| Result | spin_for (uint32_t duration_ms, int32_t poll_ms=10) |
| |
| Result | spin_once (int32_t timeout_ms=10) |
| |
| | ~Executor () |
| | Destructor — shuts down if still active.
|
| |
Explicit executor for managing ROS 2 entities and spinning.
Mirrors rclcpp::executors::SingleThreadedExecutor. Provides an explicit alternative to the global nros::init()/nros::spin_once() free functions.
The executor uses inline opaque storage — no heap allocation required.
Usage:
}
Definition executor.hpp:106
static Result create(Executor &out, const char *locator=nullptr, uint8_t domain_id=0)
Definition executor.hpp:120
bool ok() const
Check if the executor is initialized.
Definition executor.hpp:393
Result shutdown()
Shut down the executor and close the middleware connection.
Definition executor.hpp:474
Result spin_once(int32_t timeout_ms=10)
Definition executor.hpp:198
Result create_node(Node &out, const char *name, const char *ns=nullptr)
Definition node.hpp:1048
#define NROS_TRY(expr)
Definition result.hpp:128
Register a callback to run BEFORE this executor's entities are torn down — rclcpp's Context::add_pre_shutdown_callback. Issue 0790.
This is the load-bearing half and the one with no workaround. The callback runs while every publisher, subscription, service and client still works, so a node can publish a final state, answer a last request, park an actuator or release a bus. After teardown it cannot: on a device there is no OS to reclaim a claimed SPI bus, an armed DMA channel or an actuator holding its last commanded position.
The callbacks run from [shutdown] (and from the destructor, which shuts down if still active). They are a CLEAN-STOP facility: a watchdog reset, a hard fault or an abort does not come through here, and nothing backed by a static table could promise otherwise.
- Parameters
-
| callback | Function to invoke. Must not be null. |
| context | Opaque pointer handed back to callback. Must stay valid until the callback runs or is removed. |
| out | Receives the handle remove_pre_shutdown_callback takes. Optional. |
- Returns
- Success,
ErrorCode::Full when the fixed table is exhausted (NROS_EXECUTOR_MAX_SHUTDOWN_CBS, default 2), or ErrorCode::NotInitialized.
| Result nros::Executor::get_node_names |
( |
nros_cpp_node_visit_fn |
visit, |
|
|
void * |
ctx |
|
) |
| |
|
inline |
phase-381 W4 — every node on the graph, with its namespace.
visit(name, ns, enclave) is called once per node; enclave is nullptr where the backend tracks none, which is what lets one call answer both rmw_get_node_names forms. Return false to stop early.
Takes a plain function pointer plus ctx rather than a std::function: this header is compiled -nostdinc++ against Zephyr's minimal libcpp in embedded builds, where <functional> does not exist (issue 0112). Every string is BORROWED for the duration of the call.
Reports what has been DISCOVERED and never blocks. The first call after startup legitimately sees a partial graph — the backend keeps a standing query fed by the spin loop — so poll rather than calling once and concluding. An empty enumeration means "nobody seen yet", never "nobody exists", and ErrorCode::Unsupported (a backend with no graph) stays distinct from it.
| Result nros::Executor::get_subscription_names_and_types_by_node |
( |
const char * |
node_name, |
|
|
const char * |
node_namespace, |
|
|
nros_cpp_names_and_types_visit_fn |
visit, |
|
|
void * |
ctx |
|
) |
| |
|
inline |
phase-381 W4 — what one named node SUBSCRIBES to, with the types.
subscription, not subscriber: the C++ surface takes rclcpp's vocabulary (create_subscription, Subscription<T>, get_subscriptions_info_by_topic). rclcpp has no *_by_node form for subscriptions at all, so the WORD comes from its vocabulary rather than from a method it lacks. The C surface says subscriber because rcl does, and the vtable slot because upstream rmw does.
| Result nros::Executor::get_topic_names_and_types |
( |
nros_cpp_names_and_types_visit_fn |
visit, |
|
|
void * |
ctx |
|
) |
| |
|
inline |
phase-381 W4 — every topic on the graph, with the types on it.
visit(name, types, types_count) is called once per distinct TOPIC: a topic carrying two types is one call with two entries, not two calls. types_count may legitimately be 0 on a partially discovered graph. Same discovery caveat as [get_node_names].
| Result nros::Executor::spin |
( |
int32_t |
poll_ms = 10 | ) |
|
|
inline |
Spin until this executor is shut down (blocking) — rclcpp::Executor::spin.
Issue 0338 — this verb used to mean the OPPOSITE here: spin was the BOUNDED form and there was no way to say "spin forever" on an executor, while spin blocks until shutdown in rclcpp, in the C API (nros_executor_spin) and in Rust. A user porting rclcpp code wrote exec.spin() and it did not compile; reaching for spin(ms) instead silently returned early. The bounded form is now [spin_for].
Exit condition: [shutdown] on THIS executor (the executor-scoped analogue of rclcpp exiting when its context is shut down) — typically from a signal handler or another thread. Returns the first non-success spin_once result, or success after a clean shutdown.
- Parameters
-
| poll_ms | Individual spin_once timeout (default: 10ms). |