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::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::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::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::SessionSpec;
pub use executor::SpinPeriodResult;

Modules§

c_waker
Phase 122.3.c.6.e — C-ABI-compatible Waker bridge.
config
Build-time configurable constants.
cyclonedds_register
Phase 212.K.7.6.b — runtime cyclonedds type-descriptor registry hook. Per-type descriptor registration — generic seam (Phase 248 C2).
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.
session
Concrete session type aliases resolved at compile time.
timer
Timer API for nros

Structs§

ActionInfo
Action information for action client/server
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.

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.