Skip to content

Add Advanced Features (Messages, QoS, Executors, Components)#12

Merged
Michi-Tsubaki merged 1 commit intomainfrom
add-advanced-features
Oct 25, 2025
Merged

Add Advanced Features (Messages, QoS, Executors, Components)#12
Michi-Tsubaki merged 1 commit intomainfrom
add-advanced-features

Conversation

@Michi-Tsubaki
Copy link
Copy Markdown
Owner

@Michi-Tsubaki Michi-Tsubaki commented Oct 25, 2025

Overview

This PR adds advanced ROS2 features to ROS2.jl, including dynamic message handling, custom QoS profiles, multi-threaded executors, and component management.

Changes

New Module: src/messages.jl

  • get_available_message_types(): Query all available message types
  • create_msg_dynamic(): Create messages at runtime
  • get_message_fields(): Introspect message structure
  • is_valid_message_type(): Validate message type
  • QoSProfile: Custom Quality of Service configuration
  • DEFAULT_QOS, SENSOR_DATA_QOS: Predefined QoS profiles

New Module: src/advanced.jl

  • MultiThreadedExecutor: Concurrent message processing
  • LifecycleNode: Node lifecycle management
  • ComponentManager: Dynamic component loading/unloading
  • set_domain_id(), get_domain_id(): Domain ID configuration

New Examples

  • examples/example_messages.jl: Dynamic message creation and introspection
  • examples/example_advanced.jl: Multi-threaded execution, QoS, and components

API Examples

Dynamic Messages

using ROS2

init()
node = ROSNode("dynamic_example")

# Query available types
available_types = get_available_message_types()
println("Available types: $(length(available_types))")

# Create message dynamically
twist_msg = create_msg_dynamic("geometry_msgs.msg.Twist")
twist_msg.linear.x = 1.0
twist_msg.angular.z = 0.5

# Introspect message
fields = get_message_fields("geometry_msgs.msg.Twist")
println("Fields: $fields")

shutdown()

Multi-threaded Executor

using ROS2

init()
set_domain_id(1)

node = ROSNode("advanced_node")

# Create multi-threaded executor
executor = MultiThreadedExecutor(4)
add_node(executor, node)

# Custom QoS
custom_qos = QoSProfile("best_effort", "volatile", "keep_last", 10)
pub = Publisher(node, "data", "std_msgs.msg.String")

spin_executor(executor)

Component Management

using ROS2

init()

# Manage components
manager = ComponentManager("ComponentManager")
components = list_components(manager)

response = load_component(manager, "composition", "composition::Talker", "talker")
if response.success
    println("Loaded: $(response.unique_id)")
    unload_component(manager, response.unique_id)
end

shutdown()

Features

  • Runtime message type discovery and creation
  • Custom QoS for reliability and performance tuning
  • Parallel message processing with thread pools
  • Dynamic node loading without recompilation
  • Lifecycle state management
  • Domain ID configuration for network isolation

Testing

Tested with:

  • ROS2 Humble on Ubuntu 22.04
  • ROS2 Jazzy on Ubuntu 24.04
  • Dynamic message creation with various message types
  • Multi-threaded execution with high-frequency publishing
  • Component loading with demo nodes

Dependencies

  • composition_interfaces (for component management)
  • rclcpp_components (for component containers)

Backward Compatibility

Fully backward compatible. All existing code continues to work without modifications.

@Michi-Tsubaki Michi-Tsubaki merged commit 581ff39 into main Oct 25, 2025
4 checks passed
@Michi-Tsubaki Michi-Tsubaki added the enhancement New feature or request label Oct 26, 2025
@Michi-Tsubaki Michi-Tsubaki changed the title Add advanced features Add Advanced Features (Messages, QoS, Executors, Components) Oct 26, 2025
@Michi-Tsubaki Michi-Tsubaki deleted the add-advanced-features branch October 31, 2025 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant