Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version jazzy
Last Updated 2025-05-07
Dev Status DEVELOPED
Released UNRELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 2.25.2
ros_babel_fish_test_msgs 2.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version rolling
Last Updated 2025-05-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 3.25.2
ros_babel_fish_test_msgs 3.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version rolling
Last Updated 2025-05-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 3.25.2
ros_babel_fish_test_msgs 3.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro ardent showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro bouncy showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro crystal showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro eloquent showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro dashing showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro galactic showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro foxy showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro iron showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro lunar showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro jade showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro indigo showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro hydro showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

No version for distro kinetic showing humble. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/LOEWE-emergenCITY/ros2_babel_fish.git
VCS Type git
VCS Version humble
Last Updated 2025-02-07
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.25.2
ros_babel_fish_test_msgs 0.25.2

README

Reliability Rating Security Rating Maintainability Rating Vulnerabilities

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
    • Spot for shameless self-advertising: Check out my ROS2 QML plugin which uses this library to allow subscribing, publishing and more directly in QML

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 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

```C++ 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()["x"].as<ValueMessage>().setValue(1.1); // or using convenience methods compound["position"]["y"].as<ValueMessage>().setValue(2.4); // or using even more convenience methods compound["position"]["z"] = 3.6; // UPDATE: now also shorter with explicit type compound["position"].set("z", 3.6) // Be careful with your types here. Casting to a wrong type will throw an exception! // The as<ValueMessage> 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;

File truncated at 100 lines see the full file

Repository Summary

Checkout URI https://github.com/StefanFabian/ros_babel_fish.git
VCS Type git
VCS Version kinetic
Last Updated 2024-08-29
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.9.3
ros_babel_fish_test_msgs 0.9.3

README

Build Status codecov

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)},
}

ROS BabelFish

This library enables ROS nodes written in C++ to communicate using message types that are unknown at compile time.

[!IMPORTANT] The ROS2 version was moved and can be found here.

You can subscribe and even publish any available message type.
It also supports both providing and calling a service.

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
    • Spot for shameless self-advertising: Check out my ROS QML plugin which uses this library to allow subscribing, publishing and more directly in QML

The main focus of this library was usability but it is also very performant since it uses a lazy copy mechanism for bigger fields such as big arrays.
Instead of copying the message it will retain a pointer at the start of the field. A copy is only made if explicitly requested or a value in the field is changed.

Examples

Subscribing

NodeHandle nh;
BabelFish fish;
// Subscribe topic /pose
ros::Subscriber sub = nh.subscribe<ros_babel_fish::BabelFishMessage>( topic, 1, &callback );

/* ... */

void callback( const ros_babel_fish::BabelFishMessage::ConstPtr &msg )
{
  std::cout << "Message received!" << std::endl;
  std::cout << "Data Type:" << msg->dataType() << std::endl; // geometry_msgs/Pose
  std::cout << "MD5:" << msg->md5Sum() << std::endl; // e45d45a5a1ce597b249e23fb30fc871f
  std::cout << "Message Definition:" << std::endl;
  std::cout << msg->definition() << std::endl;
  std::cout << "Message Content:" << std::endl;
  TranslatedMessage::Ptr translated = fish->translateMessage( msg );
  auto &compound = translated->translated_message->as<CompoundMessage>();
  std::cout << "Position: " << compound["position"]["x"].value<double>() << ", " << compound["position"]["y"].value<double>() << ", "
            << compound["position"]["z"].value<double>() << std::endl;
  std::cout << "Orientation: " << compound["orientation"]["w"].value<double>() << ", " << compound["orientation"]["x"].value<double>() << ", "
            << compound["orientation"]["y"].value<double>() << ", " << compound["orientation"]["z"].value<double>() << std::endl;
};

Publishing

NodeHandle nh;
BabelFish fish;
// Advertise a publisher on topic /pose
ros::Publisher pub_pose = fish.advertise( nh, "geometry_msgs/Pose", "/pose", 1, true );

Message::Ptr message = fish.createMessage( "geometry_msgs/Pose" );
auto &compound = message->as<CompoundMessage>();
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;
// 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;

BabelFishMessage::Ptr translated_message = fish.translateMessage( message );
pub_pose.publish( translated_message );

Message Extraction

If you are only interested in a specific part of the message, you may not want to deserialize the entire message.

```C++ BabelFish fish; MessageExtractor extractor(fish); // We want the position of a pose stamped SubMessageLocation location = extractor.retrieveLocationForPath( “geometry_msgs/PoseStamped”, “pose.position” );

File truncated at 100 lines see the full file

Repository Summary

Checkout URI https://github.com/StefanFabian/ros_babel_fish.git
VCS Type git
VCS Version kinetic
Last Updated 2024-08-29
Dev Status DEVELOPED
Released RELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros_babel_fish 0.9.3
ros_babel_fish_test_msgs 0.9.3

README

Build Status codecov

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)},
}

ROS BabelFish

This library enables ROS nodes written in C++ to communicate using message types that are unknown at compile time.

[!IMPORTANT] The ROS2 version was moved and can be found here.

You can subscribe and even publish any available message type.
It also supports both providing and calling a service.

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
    • Spot for shameless self-advertising: Check out my ROS QML plugin which uses this library to allow subscribing, publishing and more directly in QML

The main focus of this library was usability but it is also very performant since it uses a lazy copy mechanism for bigger fields such as big arrays.
Instead of copying the message it will retain a pointer at the start of the field. A copy is only made if explicitly requested or a value in the field is changed.

Examples

Subscribing

NodeHandle nh;
BabelFish fish;
// Subscribe topic /pose
ros::Subscriber sub = nh.subscribe<ros_babel_fish::BabelFishMessage>( topic, 1, &callback );

/* ... */

void callback( const ros_babel_fish::BabelFishMessage::ConstPtr &msg )
{
  std::cout << "Message received!" << std::endl;
  std::cout << "Data Type:" << msg->dataType() << std::endl; // geometry_msgs/Pose
  std::cout << "MD5:" << msg->md5Sum() << std::endl; // e45d45a5a1ce597b249e23fb30fc871f
  std::cout << "Message Definition:" << std::endl;
  std::cout << msg->definition() << std::endl;
  std::cout << "Message Content:" << std::endl;
  TranslatedMessage::Ptr translated = fish->translateMessage( msg );
  auto &compound = translated->translated_message->as<CompoundMessage>();
  std::cout << "Position: " << compound["position"]["x"].value<double>() << ", " << compound["position"]["y"].value<double>() << ", "
            << compound["position"]["z"].value<double>() << std::endl;
  std::cout << "Orientation: " << compound["orientation"]["w"].value<double>() << ", " << compound["orientation"]["x"].value<double>() << ", "
            << compound["orientation"]["y"].value<double>() << ", " << compound["orientation"]["z"].value<double>() << std::endl;
};

Publishing

NodeHandle nh;
BabelFish fish;
// Advertise a publisher on topic /pose
ros::Publisher pub_pose = fish.advertise( nh, "geometry_msgs/Pose", "/pose", 1, true );

Message::Ptr message = fish.createMessage( "geometry_msgs/Pose" );
auto &compound = message->as<CompoundMessage>();
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;
// 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;

BabelFishMessage::Ptr translated_message = fish.translateMessage( message );
pub_pose.publish( translated_message );

Message Extraction

If you are only interested in a specific part of the message, you may not want to deserialize the entire message.

```C++ BabelFish fish; MessageExtractor extractor(fish); // We want the position of a pose stamped SubMessageLocation location = extractor.retrieveLocationForPath( “geometry_msgs/PoseStamped”, “pose.position” );

File truncated at 100 lines see the full file