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
Wakerbridge. - 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§
- Action
Info - Action information for action client/server
- Baked
Boot Config - Build-time-baked boot config, emitted (in W4b) into the
.nros_boot_configlinker 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 viaBootConfig::from_baked(innros-node). - CdrReader
- CDR reader for deserialization
- CdrWriter
- CDR writer for serialization.
- GoalId
- Unique identifier for a goal
- Node
Config - Node configuration
- Publisher
Handle - Handle to a publisher
- Publisher
Options - Options for creating a publisher
- QosPolicy
Mask - 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. - Service
Info - Service information for service client/server
- Standalone
Node - ROS 2 Node for embedded systems
- Subscriber
Handle - Handle to a subscriber
- Subscriber
Options - Options for creating a subscriber
- Topic
Info - Topic information for pub/sub
- Transport
Config - Transport session configuration
Enums§
- Cancel
Response - Cancel goal response codes
- Deser
Error - Deserialization error.
- Goal
Response - Goal accept/reject response codes
- Goal
Status - Goal status states
- Lifecycle
State - Lifecycle state (REP-2002)
- Lifecycle
Transition - Lifecycle transition (REP-2002)
- QosDurability
Policy - QoS durability policy
- QosHistory
Policy - QoS history policy
- QosLiveliness
Policy - QoS liveliness policy. Matches DDS
LIVELINESSsemantics. - QosReliability
Policy - QoS reliability policy
- SerError
- Serialization error.
- Session
Mode - Session mode
- Standalone
Node Error - Node error types
- Transition
Result - Result of a lifecycle transition callback.
- Transport
Error - Transport error types.
Constants§
- BOOT_
SET_ DOMAIN - Bit 2 —
domain_idfield is set. - BOOT_
SET_ LOCATOR - Bit 1 —
locatorfield is set. - BOOT_
SET_ NAMESPACE - Bit 3 —
namespacefield is set. - BOOT_
SET_ NODE_ NAME - Bit 0 —
node_namefield 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.
- Service
Client Trait - Service client trait for sending requests.
- Service
Server Trait - 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.