I’ve decided to publicly release the ROS2 version of ROS Babel Fish.
This might raise two questions:
What is ROS(2) Babel Fish?
ROS(2) Babel Fish are C++ message introspection packages that allow subscribing and publishing messages that are unknown at compile time.
Possible use cases include adding ROS support as plugin for other languages / frameworks that would otherwise require manual implementation for each message type.
A ROS1 example would be my qml_ros_plugin which adds ROS support natively in QML.
(ROS2 version will be released in the next week(s))
Why was this a decision?
Well, currently it is incomplete. Normally, it would not only support message subscribing and publishing but like ROS Babel Fish also include support actions and services.
ROS2 Babel Fish includes support for that but unfortunately, the rosidl_typesupport package is missing the symbols to obtain the typesupport for services and actions. A PR is pending but until that is merged, services and actions are not supported.
These answers may have raised some more questions:
What is different from existing solutions like ROS2 Introspection?
Well for one, it is not just intended for message receiving but complete ROS communication.
Also, it is built on the built-in introspection packages and works on a layer above the middleware, hence, it should in theory work with any middleware and could in the future even support zero-copy communication (with introspection overhead of course).
How does it work?
In contrast to ROS1, there isn’t a single serialization scheme and the message definition isn’t sent to each subscriber, hence, we need to obtain the type support for the message type from the local machine. This means, unlike ROS Babel Fish, ROS2 Babel Fish requires the message libraries to be available on the machine in all cases even when receiving messages.
When the type of a message is given or obtained, it will dynamically load the message libraries and look up the symbols that are generated by the introspection packages that ROS2 provides.
These are then used to wrap the memory representing the message with added methods to more easily look into the message structure and content, and/or modify the message’s content.
That’s all folks! Questions and comments are welcome!
Shoutout and big thanks to @facontidavide who helped me a lot when I started looking into how introspection would work for ROS2!