|
nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
|
#include <executor.hpp>
Public Member Functions | |
| Result | create_node (Node &out, const char *name, const char *ns=nullptr) |
| Executor () | |
| Default constructor — creates an uninitialized executor. | |
| Executor (Executor &&other) | |
| 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) |
| Result | shutdown () |
| Shut down the executor and close the middleware connection. | |
| Result | spin (uint32_t duration_ms, int32_t poll_ms=10) |
| Result | spin_once (int32_t timeout_ms=10) |
| ~Executor () | |
| Destructor — shuts down if still active. | |
Static Public Member Functions | |
| static Result | create (Executor &out, const char *locator, uint8_t domain_id, const char *session_name) |
| static Result | create (Executor &out, const char *locator=nullptr, uint8_t domain_id=0) |
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:
|
inline |
Default constructor — creates an uninitialized executor.
|
inline |
Destructor — shuts down if still active.
|
inline |
|
inlinestatic |
Create and initialize an executor with an explicit session name.
session_name flows through to the XRCE-DDS RMW backend as the per-process key derivation seed. Two processes sharing one XRCE Agent MUST use distinct names; see nros::init's named overload for the full discussion.
|
inlinestatic |
Create and initialize an executor.
Opens a middleware connection. This is the explicit alternative to nros::init().
| out | Receives the initialized executor. |
| locator | Middleware locator (e.g., "tcp/127.0.0.1:7447"), or nullptr. |
| domain_id | ROS domain ID (0-232). |
|
inline |
Get the raw executor storage (for advanced use).
Non-const: downstream FFI mutates executor state through this pointer (e.g. spin_once), so exposing it as const would be a lie. Callers that only need to observe the handle should do so through methods on Executor directly.
|
inline |
Phase 104.C.9 — chainable Node-creation builder.
Mirrors Rust's Executor::node_builder(name).rmw(...).locator(...) .domain_id(...).namespace(...).sched(...).build(). Use this when binding a Node to a specific RMW backend, locator, domain, or SchedContext. Definition follows the full NodeBuilder class in node.hpp.
|
inline |
Check if the executor is initialized.
Phase 124.F.3 — session-level connectivity probe.
Wire-level round-trip ("is the peer / agent / router
reachable?") with timeout_ms budget. Returns Result::success() on reply, ErrorCode::Timeout on no reply, ErrorCode::Unsupported when the active backend can't probe. Mirrors micro-ROS's rmw_uros_ping_agent.
Useful for reconnect-on-link-loss patterns — call periodically and tear down / re-open the executor on timeout.
|
inline |
Shut down the executor and close the middleware connection.
Spin for a duration (blocking).
Repeatedly calls spin_once() until duration_ms has elapsed.
| duration_ms | Total time to spin, in milliseconds. |
| poll_ms | Individual spin_once timeout (default: 10ms). |
Drive transport I/O and dispatch callbacks.
Processes pending subscriptions, timers, services, and guard conditions. Call this periodically in your main loop.
| timeout_ms | Maximum time to block waiting for I/O. |