Crate ros2_client

Source
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§

  • ROS 2 Action machinery
  • Some builtin interfaces for ROS2 communication Defines message types Duration and Time. See builtin_interfaces
  • Some builtin datatypes needed for ROS2 communication Some convenience topic infos for ROS2 communication
  • Message types for ROS 2 Discovery
  • rosout logging data types
  • Defines Message trait, which defines data that is to be sent over Topics.
  • Metadata for received Messages, such as Timestamps and publisher id.
  • This module defines types to represent ROS 2 names for
  • Rust-like representation of ROS2 Parameters
  • Corresponds to package rcl_interfaces. Defines message types for Parameter manipulation.
  • Module for stuff we do not want to export from top level;
  • Implementation of ROS 2 Services
  • Steady time has an arbitrary origin, but is guaranteed to run monotonically (i.e. non-decreasing), regardless of clock corrections or timezones.

Macros§

Structs§

Enums§

Statics§

Traits§

  • A trait to define an Action type
  • Trait to ensure Messages can be (de)serialized
  • 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.