Expand description
ROS 2 client library, similar to the rclcpp or rclpy libraries, in native Rust. The underlying DDS implementation, RustDDS, is also native Rust.
§Example
use futures::StreamExt;
use ros2_client::*;
let context = Context::new().unwrap();
let mut node = context
.new_node(
NodeName::new("/rustdds", "rustdds_listener").unwrap(),
NodeOptions::new().enable_rosout(true),
)
.unwrap();
let chatter_topic = node
.create_topic(
&Name::new("/","topic").unwrap(),
MessageTypeName::new("std_msgs", "String"),
&ros2_client::DEFAULT_SUBSCRIPTION_QOS,
)
.unwrap();
let chatter_subscription = node
.create_subscription::<String>(&chatter_topic, None)
.unwrap();
let subscription_stream = chatter_subscription
.async_stream()
.for_each(|result| async {
match result {
Ok((msg, _)) => println!("I heard: {msg}"),
Err(e) => eprintln!("Receive request error: {:?}", e),
}
});
// Since we enabled rosout, let's log something
rosout!(
node,
ros2::LogLevel::Info,
"wow. very listening. such topics. much subscribe."
);
// Uncomment this to execute until interrupted.
// --> smol::block_on( subscription_stream );
Modules§
- action
- ROS 2 Action machinery
- builtin_
interfaces - Some builtin interfaces for ROS2 communication
Defines message types
Duration
andTime
. See builtin_interfaces - builtin_
topics - Some builtin datatypes needed for ROS2 communication Some convenience topic infos for ROS2 communication
- entities_
info - Message types for ROS 2 Discovery
- log
rosout
logging data types- message
- Defines
Message
trait, which defines data that is to be sent over Topics. - message_
info - Metadata for received
Message
s, such asTimestamp
s and publisher id. - names
- This module defines types to represent ROS 2 names for
- parameters
- Rust-like representation of ROS2 Parameters
- rcl_
interfaces - Corresponds to package rcl_interfaces. Defines message types for Parameter manipulation.
- ros2
- Module for stuff we do not want to export from top level;
- ros_
time - ROS timing abstractions
ROSTime
andSystemTime
- rosout
- Helpers for rosout logging
- service
- Implementation of ROS 2 Services
- steady_
time - Steady time has an arbitrary origin, but is guaranteed to run monotonically (i.e. non-decreasing), regardless of clock corrections or timezones.
Macros§
Structs§
- AService
- AService is a means of constructing a descriptor for a Service on the fly. This allows generic code to construct a Service from the types of request and response.
- Action
- This is used to construct an ActionType implementation from pre-existing component types.
- Action
Type Name - Similar to
MessageTypeName
, but names an Action type. - Client
- Client end of a ROS2 Service
- Context
- Context communicates with other
participants information in ROS2 network. It keeps track of
NodeEntitiesInfo
s. Also acts as a wrapper for a RustDDS instance. - Context
Options - Builder for configuring a
Context
- DEFAULT_
PUBLISHER_ QOS - Basic Reliable QoS for publishing.
- DEFAULT_
SUBSCRIPTION_ QOS - Basic BestEffort QoS for subscribers
- Message
Info - Message metadata
- Message
Type Name - Name for
.msg
type, or a data type carried over a Topic. - Name
- Names for Topics, Services
- Node
- Node in ROS2 network. Holds necessary readers and writers for rosout and parameter events topics internally.
- Node
Logging Handle - A handle to log from any node without moving it between threads.
- Node
Name - Names for Nodes
- Node
Options - Configuration of Node This is a builder-like struct.
- Parameter
- Named parameter
- Publisher
- A ROS2 Publisher
- ROSTime
- ROS Time with nanosecond precision
- Server
- Server end of a ROS2 Service
- Service
Type Name - Similar to
MessageTypeName
, but names a Service type. - Spinner
- Spinner implements Node’s background event loop.
- Subscription
- A ROS2 Subscription
- System
Time - Same as ROSTime, except this one cannot be simulated.
- WString
- UTF-16 strings, as required by the ROS type system.
Enums§
- Node
Create Error - What went wrong in
Node
creation - Node
Event - DDS or ROS 2 Discovery events.
- Parameter
Error - Error when setting
Parameter
s - Parameter
Value - Rust-like representation of ROS2 ParameterValue
- Reader
Wait - Future type for waiting Readers to appear over ROS2 Topic.
- Service
Mapping - Selects how Service Requests and Responses are to be mapped to DDS.
- Writer
Wait - Future type for waiting Writers to appear over ROS2 Topic.
Statics§
Traits§
- Action
Types - A trait to define an Action type
- Message
- Trait to ensure Messages can be (de)serialized
- Rosout
Raw - Ability to write to rosout log.
- Service
- Service trait pairs the Request and Response types together. Additionally, it ensures that Response and Request are Messages (Serializable), and we have a means to name the types.