roslibjs icon indicating copy to clipboard operation
roslibjs copied to clipboard

Allow compression for service calls/responses

Open uahic opened this issue 5 years ago • 3 comments

Hi @ all,

currently I am implementing a service-like interface for a web-app with ROS and transporting large images (gridmaps and such) is one feature. While it is supported on topics it doesnt seem to be possible to pass compression flags via services. One of my colleagues told me that protocol itself does support this for services as well and as far as I can see in the code services are also just using the same websocket-adapter implementation underneath.

Is there any chance to get this support implemented quickly? or if I do it on my own, anything special to consider? Thanks!

uahic avatar Aug 12 '19 14:08 uahic

Rosbridge has a websocket-level compression feature (pre-message deflate) which is more efficient than protocol-level compression, for browsers which implement the standard. Set the rosbridge_websocket.py param use_compression to true.

This will give you some fast compression, but still requires base64 packing the binary data into JSON. What you really want is the option to use CBOR encoding for service responses. CBOR is more efficient for binary data, but tends to be less efficient for small messages.

On the rosbridge side, there is a TODO for service call compression. Topic subscriptions handle compression here.

On the roslib side, you would probably add a compression option to the service call and be done.

mvollrath avatar Aug 12 '19 15:08 mvollrath

@mvollrath thanks! I've implemented the roslib side ( untested though :)) )

Basically I have very large images in arraybuffer (uint8) format. Easily goes up to 16MB and more. Right now I hope there is no need for tiling the images (alternative representations of the map than occupancy gridmaps) and occupancy grids itself.

uahic avatar Aug 12 '19 15:08 uahic

@mvollrath Pullrequest has been sent, I will have a look later on the rosbridge side but I do lack total knowledge of all internals. Some help here would be nice! thanks in advance

edit: after looking at the bridge code, it seems doable, will work on this in a few hours

uahic avatar Aug 12 '19 16:08 uahic