Skip to main content

Crate ros2msg

Crate ros2msg 

Source
Expand description

§ROS2 Message Parser

A comprehensive Rust library for parsing ROS2 message, service, and action files. This crate provides functionality to parse .msg, .srv, and .action files according to the ROS2 IDL specification.

§Features

  • Message parsing: Parse .msg files with support for primitive types, arrays, and constants
  • Service parsing: Parse .srv files with request/response separation
  • Action parsing: Parse .action files with goal/result/feedback sections
  • Comprehensive validation: Validates names, types, and values according to ROS2 standards
  • Error handling: Detailed error messages for debugging parsing issues
  • Serde support: Optional serialization support with the serde feature

§Quick Start

use ros2msg::{parse_message_string, parse_service_string, parse_action_string};

// Parse a message
let msg_content = r#"
int32 x
int32 y
string name
"#;
let msg_spec = parse_message_string("geometry_msgs", "Point", msg_content)?;
println!("Parsed message: {}", msg_spec);

// Parse a service
let srv_content = r#"
int32 a
int32 b
---
int32 sum
"#;
let srv_spec = parse_service_string("example_msgs", "AddTwoInts", srv_content)?;
println!("Parsed service: {}", srv_spec);

// Parse an action
let action_content = r#"
int32 order
---
int32[] sequence
---
int32[] partial_sequence
"#;
let action_spec = parse_action_string("example_msgs", "Fibonacci", action_content)?;
println!("Parsed action: {}", action_spec);

§Modules

  • msg: ROS2 message/service/action parser (.msg, .srv, .action files)
  • idl: ROS2 IDL parser (full IDL specification support)
  • generator: Code generator for converting ROS2 interfaces to Rust types
  • [ros2args]: ROS2 command-line arguments parser

Re-exports§

pub use msg::ActionSpecification;
pub use msg::AnnotationValue;
pub use msg::Annotations;
pub use msg::BaseType;
pub use msg::Constant;
pub use msg::Field;
pub use msg::InterfaceSpecification;
pub use msg::MessageSpecification;
pub use msg::PRIMITIVE_TYPES;
pub use msg::ParseError;
pub use msg::ParseResult;
pub use msg::PrimitiveValue;
pub use msg::ServiceSpecification;
pub use msg::Type;
pub use msg::Value;
pub use msg::create_feedback_message;
pub use msg::create_service_event_message;
pub use msg::is_valid_constant_name;
pub use msg::is_valid_field_name;
pub use msg::is_valid_message_name;
pub use msg::is_valid_package_name;
pub use msg::parse_action_file;
pub use msg::parse_action_string;
pub use msg::parse_interface_file;
pub use msg::parse_message_file;
pub use msg::parse_message_string;
pub use msg::parse_primitive_value_string;
pub use msg::parse_service_file;
pub use msg::parse_service_string;

Modules§

generator
Code generator for ROS2 interfaces
idl
ROS2 IDL parser
idl_adapter
MSG/SRV/Action to IDL converter
msg
ROS2 Message/Service/Action parser

Constants§

VERSION
Version information