Get raw network data of a ros topic
Hey guys,
I try to get the raw data of a topic in ros for some days now. My Problem is, that I receive a complex Message Type from a topic and I have to serialize its data to a <uint8_t>vector to fill the payload of a network package and send it to another application.
If I subscribe the topic, I only get a ConstPtr& to the specific message type and because it's a complex type which change it's size at runtime I can't use simply memcpy() to serialize the data. Of course I can serialize the data with some for loops, but this isn't a smart way to do it.
Instead of deserializing the data by the subscriber, is it possible to get the serialized raw frames directly from the topic?
So I have my subscriber:
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("topic", 1000, &callback);
and my callnack function:
void Listener::callback(SpecialDataType::ConstPtr& msg) { //should serialize data and forward it }
If it is possible to just get the raw eth frame of the topic, I'll only need copy the raw frame in my new payload and send it.
Do you have an idea how to achieve a good solution to such a problem?