ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

You could give cpp_introspection a try. The package cannot introspect arbitrary mesage types, but only messages from packages for which an introspection library have been built before. It is therefore no solution for rosserial_server, but probably for others with similar problems.

There is no documentation available so far. Here is a simple usage example:

# add this to your CMakeLists.txt:
find_package(cpp_introspection REQUIRED)
introspection_add(nav_msgs RECURSIVE)

You can then examine the package and messages in a C++ program like that:

#include <iostream>
#include <introspection/introspection.h>

using namespace cpp_introspection;

int main(int argc, char **argv) {
    load("path/to/introspections/libs");
    MessagePtr msg = messageByDataType("nav_msgs/Odometry");

    if (!msg) {
        std::cerr << "not found" << std::endl;
        return 1;
    }

    std::cout << "Definition of " << msg->getDataType() << ":" << std::endl;
    std::cout << msg->getDefinition() << std::endl;
    return 0;
}

Check the message.h header to get an impression of the full message API.

As far as I know there is no built-in mechanism in ROS or roscpp that allows introspection of messages in C++ without having to include the headers or invoke external programs. The cleanest solution would be to automatically compile a light-weight library for each message package by extending gencpp and use pluginlib or a similar mechanism to load them dynamically on demand.