Message definition value in roscpp
It's trivial to get the concatenated definition of a message in roscpp, provided that the message is compiled-in:
#include <iostream>
#include <nav_msgs/Odometry.h>
int main(int argc, char* argv[])
{
std::cout << ros::message_traits::Definition<nav_msgs::Odometry>::value();
return 0;
}
However, I'd like to be able to get arbitrary message definition strings from the workspace, by message type string. Now, I know I can use ros::package::getPath
, track dependencies, and build up the concatenation myself, but I'm wondering if the canonical one created in the python message generator gets cached somewhere accessible as well?
The use case is for rosserial_server, which uses topic_tools::ShapeShifter
to advertise topics and messages which are not known at compile-time (but are proxied from clients who did know about them... the clients declare the topic type and MD5, but don't store the entire message string). Currently this is being addressed with a shim rospy node, but I'm interested in eliminating that component and doing everything in the C++ binary.
So first, is there some way to do this already? If not, is this functionality which should go somewhere general rather than just sticking it in the rosserial_server codebase?