Skip to main content

Crate ros2_types

Crate ros2_types 

Source
Expand description

ROS2 type support library

This crate provides core traits and utilities for ROS2 message types, including RIHS01 (ROS Interface Hashing Standard v1) type hash calculation.

§Features

  • derive: Enable derive macros for TypeDescription and Ros2Msg
  • native: Enable native CDR serialization (for Zenoh, iceoryx2, etc.)

§Traits

This crate provides several traits for ROS2 message types:

  • TypeSupport: For types with type support information and CDR serialization
  • TryClone: For types that can fail cloning (FFI types)
  • ServiceMsg: For ROS2 service types (Request/Response pairs)
  • ActionMsg: For ROS2 action types (Goal/Result/Feedback)
  • ActionGoal, ActionResult: For action service types
  • GetUUID, GoalResponse, ResultResponse: Helper traits for actions

§Native CDR Serialization

When the native feature is enabled, message types can be serialized/deserialized using CDR encoding (compatible with DDS/ROS2):

use ros2_types::TypeSupport;

let msg = std_msgs::msg::String { data: "hello".into() };
let bytes = msg.to_bytes()?;
let decoded = std_msgs::msg::String::from_bytes(&bytes)?;

Note: When using native feature, message structs must derive serde::Serialize and serde::Deserialize.

Re-exports§

pub use cdr::CdrSerde;
pub use types::FIELD_TYPE_BOOLEAN;
pub use types::FIELD_TYPE_BOUNDED_STRING;
pub use types::FIELD_TYPE_BOUNDED_WSTRING;
pub use types::FIELD_TYPE_BYTE;
pub use types::FIELD_TYPE_CHAR;
pub use types::FIELD_TYPE_DOUBLE;
pub use types::FIELD_TYPE_FIXED_STRING;
pub use types::FIELD_TYPE_FIXED_WSTRING;
pub use types::FIELD_TYPE_FLOAT;
pub use types::FIELD_TYPE_INT8;
pub use types::FIELD_TYPE_INT16;
pub use types::FIELD_TYPE_INT32;
pub use types::FIELD_TYPE_INT64;
pub use types::FIELD_TYPE_LONG_DOUBLE;
pub use types::FIELD_TYPE_NESTED_TYPE;
pub use types::FIELD_TYPE_NOT_SET;
pub use types::FIELD_TYPE_STRING;
pub use types::FIELD_TYPE_UINT8;
pub use types::FIELD_TYPE_UINT16;
pub use types::FIELD_TYPE_UINT32;
pub use types::FIELD_TYPE_UINT64;
pub use types::FIELD_TYPE_WCHAR;
pub use types::FIELD_TYPE_WSTRING;
pub use serde;

Modules§

cdr
CDR (Common Data Representation) serialization support
types
Type description data structures

Structs§

MessageTypeName
Information needed to construct a ROS2 message type name
SequenceRaw
Raw sequence type for FFI compatibility
UnsafeDuration
Represents a duration that may not be safe across all platforms.
UnsafeTime
Represents a timestamp that may not be safe across all platforms.

Enums§

Error
Errors that can occur during type hash calculation

Traits§

ActionGoal
Trait for action goal types.
ActionMsg
Trait for ROS2 action message types.
ActionResult
Trait for action result types.
ActionTypeDescription
Trait for ROS2 action types that can provide a type description for hash computation
BigArray
The big array serialization helper trait
GetUUID
Trait for types that contain a UUID.
GoalResponse
Trait for action goal response types.
ResultResponse
Trait for action result response types.
RosFieldType
Trait for types that can be used as fields in ROS2 messages.
ServiceMsg
Trait for ROS2 service message types.
ServiceTypeDescription
Trait for ROS2 service types that can provide a type description for hash computation
TryClone
Trait for type that can fail cloning
TypeDescription
Trait for types that can provide a ROS2 type description
TypeSupport
Trait for types that have type support information.

Functions§

calculate_type_hash
Calculate the RIHS01 type hash for a type description
parse_rihs_string
Parse a RIHS hash string and extract version and hash value

Type Aliases§

Result
Result type for type hash operations