ROS2 Babel Fish Released

I’ve decided to publicly release the ROS2 version of ROS Babel Fish.

This might raise two questions:

  1. 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))

  2. 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:

  1. 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).

  2. 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!

8 Likes

Interesting…

From my work I have a similar situation. I need to load dynamic libraries into my main program, which are also unknown during compile time.
These dynamic libraries already are built against service/action IDLs that are available in the workspace of the dynamic library.
The IDL files from those messages are not available to the main program.
Once I want to load the dynamic library into the main program, the ld complains that the symbols are not met for the service/action messages.

I solved this by manually loading the IDL files (2 per IDL and the order is important) into my main program and afterwards loading my desired dynamic library.

Does this help you in any way? :slight_smile:
My main program is basically a plain ROS2 wrapper of the great behavior tree library from @facontidavide and solely utilizes the loadPlugin function from that library for all the activity mentioned above.

Thanks for your input!
The problem is that the C-style exported functions to obtain the type support are declared but not implemented for services and actions. The PR I submitted, would fix that, and if it gets merged everything would work as expected.
Currently, for services and actions to work, you’d have to compile my fork with the fix and all used services and actions from source.
So in my case, it’s not about dependency libraries not being loaded but the unmangled symbol to get the type support is not available.
The mangled symbol (C++ namespaced function which ends up getting a nearly unreadable name in the binary) - which your dynamic library is probably using - is available but the mangling depends on the system and compiler so it would be very dirty to try to reproduce and load that.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.