Skip to content

Latest commit

 

History

History
56 lines (47 loc) · 1.6 KB

README.md

File metadata and controls

56 lines (47 loc) · 1.6 KB

blob_tools

blob_tools provides a new message type blob_tools/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.

This can also be used to have union-like message fields where one field of type is blob_tools/Blob can be any valid ROS message type (including custom types) and the type must be remembered in an additonal member, e.g.:

blob_tools/Blob data # either a 'string' or a 'uint32', stored in 'type'

uint8 type # either TYPE_STRING or TYPE_UINT32
uint8 TYPE_STRING = 1
uint8 TYPE_UINT32 = 2

Installation

cd your_catkin_ws/src
git clone [email protected]:CodeFinder2/blob_tools.git

Usage Example

MyMessage.msg:

blob_tools/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 bzip2 compression (apt install libbz2-dev)
    ...
    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) {
        ....
    }
}