Add dynamic message functionality #262
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an overview PR to see the changes at a high level. I recommend you check out this branch and run
cargo doc
to see what the API looks like. For the review, it will be split into smaller parts.What are dynamic messages?
Dynamic messages are messages whose type is only known at runtime. You create dynamic messages by specifying the type as a string, e.g. "geometry_msgs/msg/Twist". The dynamic message module then looks for a shared introspection type support library, loads it, and parses the structure of the C message struct from it. That structure contains information about what fields the message contains and what their types are, e.g.
field 'angular' of type 'Vector3' at offset 24
. Using the structure, the dynamic message module can then read out the value of each field, and even modify it. Basically, it allows accessing the fields of the message as a HashMap from string to a value like this:This is useful for writing generic tools such as introspection tools, bridges to other communication systems, or nodes that manipulate messages à la
topic_tools
.In C++, a similar thing exists in https://github.com/osrf/dynamic_message_introspection and https://github.com/facontidavide/ros2_introspection.
Features:
unsafe
required in user codeNon-features:
Notes
dynamic_message
module is behind a feature flag that will be disabled by default. Thus, there is no impact on compile times for the majority of users who do not need this.Future work:
Subscription
andDynamicSubscription
(and the same for publishers) – this can also help compilation times by monomorphizing Subscription.