ROS 2 Dynamic Typesupport Explanation

Hello all!

What am I trying to do?
I have a list of variables of different ROS types (specifically from a Behavior Tree blackboard, but this detail may be irrelevant). I want to save this list (blackboard) to a yaml or json file such that I can later read the file and create a new blackboard with the same data. To accomplish this I need to know the type of each variable in the list so the nodes can covert the data from json/yaml to its corresponding ROS data type.

I’ve been looking into ROS’s dynamic typesupport capabilities such that I can define a dynamic type and declare each variable in such a manner that my node can abstract the variables’ specific type. Specifically, I’m getting familiar with the ros2/rosidl_dynamic_typesupport repo. Unfortunately, I have not found documentation on how to use this tool.

In this post, @gbiggs made a reference to the osrf/dynamic_message_introspection package, but this does not seem to be what I’m looking for. (Please let me know if I’m mistaken).

Questions:
Is there documentation that I can study to better understand ROS’s dynamic typesupport capabilities? If not, can someone point me in the right direction?

Thank you all for your time and attention.

Sergio

here for the basic concept of this, Internal ROS 2 interfaces — ROS 2 Documentation: Humble documentation

1 Like

Are you using C++ or pyhton ?
Also are your messages known / static in advance ?

I am using C++.

My messages are not known at compile time, only during runtime. The input list can be a combination of any data type depending on how the user sets up the behavior tree.

In that case I am out of ideas. For static messages, there is a reflection API that you can use. This might work for dynamic messages as well, but the latest rumors I head about it was that its incomplete.

This is the reflection API in case you want to take a look: