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