blob provides a new message type blob/Blob for binary data.
Currently, only roscpp is supported. Other client libraries like rospy will serialize/deserialize blob data as uint8[], as defined in the message definition.
MyMessage.msg:
blob/Blob map_blob # a serialized (and compressed) nav_msgs/OccupancyGridMap
Publisher:
{
...
MyMessage temp;
nav_msgs::OccupancyGridMap my_map;
...
temp.map_blob.serialize(my_map);
temp.map_blob.setCompressed(true); // enable compression
...
publisher.publish(temp);
}
Subscriber:
void callback(const MyMessageConstPtr& msg)
{
// WARNING: instantiation of the "wrong" data type may result in non-sense data and/or StreamOverrunExceptions
// blob/Blob is not type-safe!
nav_msgs::OccupancyGridMapPtr my_map = msg->map_blob.instantiate<nav_msgs::OccupancyGridMap>();
if (my_map) {
....
}
}