Software
ros_babel_fish
By emergenCITY, Germany (checked on github.com/LOEWE-emergenCITY (opens in a new tab)), from github.com/LOEWE-emergenCITY/ros_babel_fish (opens in a new tab)
- Middleware
- Library
- MIT
A C++ library that lets ROS2 nodes subscribe to, publish, and call services or actions for message types unknown at compile time.
Facts
- GitHub stars
- 61read on 22 Nov 2026
- Last update
- 13 Oct 2026Newest commit on rolling
- Maintenance
- Activea commit in the last 90 days
- Difficulty
- Advanced
- Hardware it needs, as the project states it
- Only full support for foxy, rolling and ROS2 jazzy and later; on other versions services and actions do not work, while subscribing and publishing work on all ROS2 versions.
Checked on GitHub on 22 Nov 2026.
Licenses
- Code
- MIT (opens in a new tab)
Read by Robotheca from LICENSE (opens in a new tab) (MIT) at commit c6f4bb2 (opens in a new tab), on 16 Oct 2026.
- Commercial use
- Yes
At a glance
- What it is
- Subscribes to and publishes any available ROS2 message type without compile-time definitions.
- Supports providing and calling services and actions.
- Requires the type support for the used message, service, or action to be available on the machine.
- Serializes messages to and from JSON and YAML via the ros_babel_fish_tools package.
- Includes CLI tools: echo prints a topic's first message, topic_stats reports rate, latency and bandwidth.
- Includes service_stats, which measures round-trip time and can repeatedly call a service to report call rate and timeouts.
Robotheca's summary of the project's documents, not the creator's words.
- Robots on Robotheca
- No robot on Robotheca uses it yet.
- Licence
- MIT. Commercial use: Yes. Where it was read
- Install
- In the creator's words: The project's README (opens in a new tab)
- Maintenance
- Active, last commit on 13 Oct 2026.
Use it
How to install it, in the creator's words: The project's README (opens in a new tab)
Robotheca doesn't review code. Read it before running it.
Files and versions
- Repository on GitHubgithub.com/LOEWE-emergenCITY/ros_babel_fish (opens in a new tab)
- The version Robotheca readc6f4bb2 (opens in a new tab)
- Latest releaseNone published on GitHub
Robotheca never hosts the code: each link goes to the creator's own page.
The README
The creator's own README, copied as written: README.md by emergenCITY, at commit c6f4bb2, under MIT (opens in a new tab). The original on GitHub (opens in a new tab).
Read the README here
Image: Reliability Rating (opens in a new tab) (opens in a new tab) Image: Security Rating (opens in a new tab) (opens in a new tab) Image: Maintainability Rating (opens in a new tab) (opens in a new tab) Image: Vulnerabilities (opens in a new tab) (opens in a new tab)
ROS Babel Fish
This library enables ROS2 nodes written in C++ to communicate using message types that are unknown at compile time.
You can subscribe and even publish any available message type. It also supports both providing and calling services and actions. However, the type support for the used message, service or action needs to be available on the machine and in the environment the node is running in.
Please strongly consider whether you actually need this library because there may be a better solution. Possible use cases where you do need it are:
- UIs displaying the content of various at compile time unknown messages
- Plugins for (script) languages that can not access the C++ message definitions without modification
- Serialization and Deserialization from and to JSON and YAML (see Serialization)
[!NOTE] Spot for shameless self-advertising
Check out my QML ROS2 plugin (opens in a new tab) and QML6 ROS2 plugin (opens in a new tab) which use this library to allow subscribing, publishing and more directly in QML. The latter is the basis for RQml (opens in a new tab).
Scientific Works
If you are using this module in a scientific context, feel free to cite this paper:
@INPROCEEDINGS{fabian2021hri,
author = {Stefan Fabian and Oskar von Stryk},
title = {Open-Source Tools for Efficient ROS and ROS2-based 2D Human-Robot Interface Development},
year = {2021},
booktitle = {2021 European Conference on Mobile Robots (ECMR)},
}
Installation
Clone this repo into the src folder of your colcon workspace, build and open a new terminal or source the workspace overlay again.
(Beginners: see here (opens in a new tab) for an introduction to workspaces)
Note: Only foxy, rolling and ROS2 versions from jazzy upwards have full support for this library as the others are missing functionality in the core ROS packages and the backports have not been merged yet. On the other versions, services and actions do not work. Subscribing and publishing works on all ROS2 versions.
Examples
Subscribing
using namespace ros_babel_fish; // Except Node all of the following classes are in that namespace
Node node;
BabelFish::SharedPtr fish = BabelFish::make_shared();
// Subscribe topic /pose
BabelFishSubscription::SharedPtr sub = fish->create_subscription( node, topic, 1, &callback );
/* ... */
void callback( const ros_babel_fish::CompoundMessage::SharedPtr &msg )
{
std::cout << "Message received!" << std::endl;
std::cout << "Datatype:" << msg->datatype() << std::endl; // geometry_msgs::msg::Pose
std::cout << "Name:" << msg->name() << std::endl; // geometry_msgs/msg/Pose
std::cout << "Message Content:" << std::endl;
const CompoundMessage &compound = *msg;
std::cout << "Position: " << compound["position"]["x"].value<double>() << ", " << compound["position"]["y"].value<double>() << ", "
<< compound["position"]["z"].value<double>() << std::endl;
// Alternatively, you can use the new get<T> convenience method
std::cout << "Orientation: " << compound["orientation"].get<double>("w") << ", " << compound["orientation"].get<double>("x") << ", "
<< compound["orientation"].get<double>("y") << ", " << compound["orientation"].get<double>("z") << std::endl;
};
Publishing
using namespace ros_babel_fish; // Except Node all of the following classes are in that namespace
Node node;
BabelFish fish;
// Advertise a publisher on topic /pose
BabelFishPublisher::SharedPtr pub_pose = fish->create_publisher( node, "/pose", "geometry_msgs/msg/Pose", 1 );
CompoundMessage::SharedPtr message = fish->create_message_shared( "geometry_msgs/msg/Pose" );
auto &compound = *message;
compound["position"].as<CompoundMessage>()["x"].as<ValueMessage<double>>().setValue(1.1);
// or using convenience methods
compound["position"]["y"].as<ValueMessage<double>>().setValue(2.4);
// or using even more convenience methods
compound["position"]["z"] = 3.6;
// UPDATE: now also shorter with explicit type
compound["position"].set<double>("z", 3.6)
// Be careful with your types here. Casting to a wrong type will throw an exception!
// The as<ValueMessage<T>> method is also a bit faster because the convenience method
// will automatically convert to the right type and perform bound and compatibility checks.
// This makes it more robust but comes with a little overhead.
// Note that assigning a double to a float field will always throw an exception because
// the float may not have the required resolution.
// Assigning, e.g., an int to a uint8 field will only throw if the int is out of bounds (0-255)
// otherwise a warning will be printed because uint8 is not compatible with all possible values
// of int. This warning can be disabled as a compile option.
compound["orientation"]["w"] = 0.384;
compound["orientation"]["x"] = -0.003;
compound["orientation"]["y"] = -0.876;
compound["orientation"]["z"] = 0.292;
pub_pose->publish( compound );
For more examples on how to use this library, check the examples (opens in a new tab) folder.
Serialization
JSON Serialization
The ros_babel_fish_tools package provides a header-only JSON conversion using the nlohmann_json library.
#include <ros_babel_fish_tools/nlohmann_json_serialization.hpp>
// Convert a message to JSON
nlohmann::json j = ros_babel_fish_tools::message_to_json( *msg );
std::cout << j.dump() << std::endl;
// Convert JSON back to a message
ros_babel_fish_tools::json_to_message( j, *empty_msg );
YAML Serialization
The ros_babel_fish_tools package also provides YAML conversion using the yaml-cpp library through yaml_cpp_vendor.
#include <ros_babel_fish_tools/yaml_cpp_serialization.hpp>
// Convert a message to YAML
YAML::Node node = ros_babel_fish_tools::message_to_yaml( *msg );
std::cout << node << std::endl;
// Convert YAML back to a message
ros_babel_fish_tools::yaml_to_message( node, *empty_msg );
Echo Tool
The echo tool is a CLI utility that prints the first message of a topic as JSON and then exits.
ros2 run ros_babel_fish_tools echo /topic [type]
[!TIP] Use
--yamlto change the output format to YAML and--pretty(or-p) to format the JSON output.
Topic Stats Tool
The topic_stats tool subscribes to a topic and periodically reports message rate, latency, deserialization time and bandwidth.
Bandwidth and deserialization time are measured for any message type; latency requires the message to have a std_msgs/Header header field and is reported as n/a otherwise.
ros2 run ros_babel_fish_tools topic_stats /topic [type]
Options:
| Option | Description |
|---|---|
--window <seconds> | Reporting interval in seconds (default: 5) |
--out <file> | Write per-message measurements (receive time, latency, deserialize time, size) to a CSV file |
--compress <algo> | Also report compressed bandwidth and (de)compression time; algo is lz4 or zstd |
--ros-args ... | Pass ROS arguments (e.g. -p use_sim_time:=true) |
-h, --help | Show the help message |
Service Stats Tool
The service_stats tool calls a service and reports the round-trip time, the request and response sizes and the time spent serializing the request and deserializing the response.
By default a single call is made and its measurements are printed; with --rate the service is called repeatedly and the call rate, min/avg/max of each metric, bandwidth and the number of timed-out calls are reported once per window.
ros2 run ros_babel_fish_tools service_stats /service [type] [options]
Options:
| Option | Description |
|---|---|
--rate <hz> | Call repeatedly at up to this many calls per second (default: perform a single call and exit) |
--window <seconds> | Reporting interval in seconds; only used with --rate (default: 5) |
--timeout <seconds> | Per-call response timeout; a call that exceeds it is counted as timed out (default: wait indefinitely) |
--request <yaml> | Request payload as an inline YAML map (default: empty request) |
--request-file <file> | Read the request payload from a YAML file |
--out <file> | Write per-call measurements (call time, round-trip time, success, response size, deserialize time) to a CSV file |
--ros-args ... | Pass ROS arguments (e.g. -p use_sim_time:=true); end them with -- so the remaining options are parsed by the tool |
-h, --help | Show the help message |
License
This project is licensed under the MIT License.
The ros_babel_fish_tools package includes the nlohmann_json library, which is also licensed under the MIT License and the utf8cpp library, which is licensed under the BSL-1.0 License.
Robotheca lists software as a reference: nothing is hosted or run here, and every fact links to where it was read.