Skip to main content

Crate nros_node

Crate nros_node 

Source
Expand description

Node abstraction for nros

This crate provides the high-level Node API for creating ROS 2 compatible publishers and subscribers on embedded systems.

§Executor-Based API

The executor-based API provides a unified interface that works on both std (desktop) and no_std (embedded) targets.

§Desktop Example

use nros::prelude::*;
use std_msgs::msg::Int32;

let config = ExecutorConfig::from_env().node_name("my_node");
let mut executor: Executor = Executor::open(&config)?;

// Register subscription callback
let node = executor.node_builder("my_node").build()?;
executor.node_mut(node).create_subscription::<Int32, _>("/topic", |msg: &Int32| {
    println!("Received: {}", msg.data);
})?;

// Spin (processes callbacks)
executor.spin_blocking(SpinOptions::default());

§Embedded Example

use nros::prelude::*;
use std_msgs::msg::Int32;

let config = ExecutorConfig { locator: "tcp/192.168.1.1:7447", ..Default::default() };
let mut executor: Executor = Executor::open(&config)?;

// Register subscription callback
let node = executor.node_builder("my_node").build()?;
executor.node_mut(node).create_subscription::<Int32, _>("/cmd", |msg: &Int32| {
    // process message...
})?;

// In your main loop:
loop {
    executor.spin_once(core::time::Duration::from_millis(10));
    // platform delay...
}

§Features

  • std - Enable standard library support (spin_blocking)
  • alloc - Enable heap allocation (parameter service boxed replies)

Re-exports§

pub use timer::TimerCallbackFn;
pub use timer::TimerDuration;
pub use timer::TimerHandle;
pub use timer::TimerMode;
pub use timer::TimerState;
pub use lifecycle::LifecycleCallbackFn;
pub use lifecycle::LifecycleError;
pub use lifecycle::LifecyclePollingNode;
pub use executor::BootConfig;
pub use executor::BootConfigError;
pub use executor::DOMAIN_ID_EXPLICIT_ZERO_C_ABI;
pub use executor::DOMAIN_ID_MAX;
pub use executor::ExecutorConfig;
pub use executor::ExecutorSemantics;
pub use executor::GuardConditionHandle;
pub use executor::HandleId;
pub use executor::HandleSet;
pub use executor::InvocationMode;
pub use executor::NodeError;
pub use executor::RawAcceptedCallback;
pub use executor::RawCancelCallback;
pub use executor::RawGoalCallback;
pub use executor::RawResponseCallback;
pub use executor::RawServiceCallback;
pub use executor::RawSubscriptionCallback;
pub use executor::ReadinessSnapshot;
pub use executor::SpinOnceResult;
pub use executor::SpinOptions;
pub use executor::SpinPeriodPollingResult;
pub use executor::Trigger;
pub use executor::baked_domain_from_c_abi;
pub use executor::ActionClient;
pub use executor::ActionClientCore;
pub use executor::ActionServer;
pub use executor::ActionServerCore;
pub use executor::ActionServerHandle;
pub use executor::ActionServerRawHandle;
pub use executor::ActiveGoal;
pub use executor::CallbackGroup;
pub use executor::CompletedGoal;
pub use executor::EmbeddedPublisher;
pub use executor::EmbeddedRawPublisher;
pub use executor::EmbeddedServiceClient;
pub use executor::EmbeddedServiceServer;
pub use executor::Executor;
pub use executor::FeedbackStream;
pub use executor::GoalFeedbackStream;
pub use executor::LoanError;
pub use executor::NodeHandle;
pub use executor::Promise;
pub use executor::PublishLoan;
pub use executor::RawActionClientSpec;
pub use executor::RawActionServerSpec;
pub use executor::RawActiveGoal;
pub use executor::RawServiceClient;
pub use executor::RawServiceServer;
pub use executor::RawSubscription;
pub use executor::RecvView;
pub use executor::SessionHandle;
pub use executor::Subscription;
pub use executor::executor_storage_layout;
pub use executor::executor_storage_u64_len;
pub use executor::ExecutorInlineStorage;
pub use executor::ExecutorSizing;
pub use executor::SessionSpec;
pub use executor::SpinPeriodResult;

Modules§

c_waker
Phase 122.3.c.6.e — C-ABI-compatible Waker bridge.
config
Build-time configurable constants.
executor
Embedded executor with build-time configured arena.
lifecycle
Lifecycle node API (REP-2002)
limits
Shared string-length and resource caps used by the Rust, C, and C++ APIs.
rmw_type_registry
Phase 212.K.7.6.b — runtime cyclonedds type-descriptor registry hook. Per-type descriptor registration — generic seam (Phase 248 C2).
session
Concrete session type aliases resolved at compile time.
timer
Timer API for nros

Structs§

ActionInfo
Action information for action client/server
BakedBootConfig
Build-time-baked boot config, emitted (in W4b) into the .nros_boot_config linker section by the entry macro / cmake. Fixed-size + pointer-free so a future post-link tool can patch it in place (RFC-0045). The resolver reads it on embedded via BootConfig::from_baked (in nros-node).
CdrReader
CDR reader for deserialization
CdrWriter
CDR writer for serialization.
GoalId
Unique identifier for a goal
NodeConfig
Node configuration
PublisherHandle
Handle to a publisher
PublisherOptions
Options for creating a publisher
QosPolicyMask
Bitmask of QoS policies a backend can honour. See Session::supported_qos_policies.
QosSettings
Full DDS-shaped QoS profile. Matches the field set of upstream rmw_qos_profile_t.
ServiceInfo
Service information for service client/server
StandaloneNode
ROS 2 Node for embedded systems
SubscriberHandle
Handle to a subscriber
SubscriberOptions
Options for creating a subscriber
TopicInfo
Topic information for pub/sub
TransportConfig
Transport session configuration

Enums§

CancelResponse
Cancel goal response codes
DeserError
Deserialization error.
GoalResponse
Goal accept/reject response codes
GoalStatus
Goal status states
LifecycleState
Lifecycle state (REP-2002)
LifecycleTransition
Lifecycle transition (REP-2002)
QosDurabilityPolicy
QoS durability policy
QosHistoryPolicy
QoS history policy
QosLivelinessPolicy
QoS liveliness policy. Matches DDS LIVELINESS semantics.
QosReliabilityPolicy
QoS reliability policy
SerError
Serialization error.
SessionMode
Session mode
StandaloneNodeError
Node error types
TransitionResult
Result of a lifecycle transition callback.
TransportError
Transport error types.

Constants§

BOOT_SET_DOMAIN
Bit 2 — domain_id field is set.
BOOT_SET_LOCATOR
Bit 1 — locator field is set.
BOOT_SET_NAMESPACE
Bit 3 — namespace field is set.
BOOT_SET_NODE_NAME
Bit 0 — node_name field is set.
NROS_BOOT_CONFIG_MAGIC
0x4E524243 = ASCII “NRBC”. A post-link tool scans for this magic to locate the struct in a firmware image.
NROS_BOOT_CONFIG_VERSION
Layout version — lets the resolver reject a mismatched baked struct.
SERVER_DISCOVERY_PROBE_TIMEOUT_MS
Server-discovery probe cadence (issue #224 — one shared constant; was independently defined at four call sites across nros-node and nros-c). One probe per second balances “see freshly-declared tokens quickly” against “burn fewer FFI round-trips on a healthy network”; the outer wall-clock budget is the caller’s.

Traits§

Publisher
Publisher trait for sending messages.
ServiceClientTrait
Service client trait for sending requests.
ServiceServerTrait
Service server trait for handling requests.
Session
Transport session trait — the per-process anchor an RMW backend gives to the executor.
Subscriber
Subscriber trait for receiving messages.