We have a non-ros-client that needs to send some huge messages (>200,000 bytes) to ROS.
The non-ros-client only supports tcp-sockets, so I use a self-written tcp2ws wrapper/bridge to connect to rosbridge v2.
This is working well so far (after more testing and fixing some minor issues it can be shared with anyone who is interested..)
Since rosbridge v2 specification draft states that fragmentation and png-compression are in an experimental state, I tried to get it to work but found several problems and have some questions..
I don't think the tcp2ws wrapper is causing the trouble, it's just passing bytes from tcp-sockets to a websockets.. but I might be wrong, so feel free to comment on anything that could be relevant.
1. Is there any version of rosbridge v2 around that has fragmentation support enabled without having to change any code of rosbridge?
Is fragmentation in experimental state (and can be tested / used / ..) or is it in an incomplete and not yet usable state?
2. Is fragmentation meant to be used directly by clients connecting to rosbridge or is it meant to act as a transparent service provided by rosbridge?
When I add the Fragmentation class to capabilities in "rosbridge_protocol.py" and send a message with the op-code "fragmentation", rosbridge starts throwing following error:
fragment: fragment() takes at least 3 arguments (2 given)
After looking through the source code I suspect this is the result of calling a function that can split bigger messages into fragments, basically something similar to what I am doing outside of rosbridge (fragmenting big original message by myself)
Maybe someone could just clarify how fragmentation mechanism is (/will be) designed? ..just to make sure I don't misunderstand the concept behind it..
Also I would like to know if the fragments will be combined by rosbridge and thus not be visible to any other ROS-node?
3. What is the exact format that the fragments should look like?
The specification draft shows following pattern for messages:
{ op: 'fragment', id: <string> , data: <string>, num: <int>, total: <int> }
json.loads(msg) with python cannot decode above line (<string> and <int> filled with correct types), resulting in following error:
Unable to deserialize message from client
For me following example is working, although I'm not sure it is 100% correct.. (means it can be deserialized by rosbridge, fragmentation is not yet working at all)
{"op": "fragment", "id": "1234", "data": "abcdefg", "num": 0, "total": 1}
4. If I got it right, the data-field of a fragment should contain the parts of the string representation of a json-object (e.g. "data": {"bla":"bla"} ).
In case this json-object is not complete, e.g contains only the opening bracket ( { ) without the corresponding closing one or any number of "'s (quotes), deserialization of the message fails.
How am I supposed to split the original string representation JSON-object and fill it into the data-string, if the resulting string cannot be parsed as a correct json-object?
Is there any example of splitting a message into fragments?
Regards,
David Bertram
--
You received this message because you are subscribed to the Google Groups "Rosbridge Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rosbridge-use...@googlegroups.com.
To post to this group, send email to rosbrid...@googlegroups.com.
Visit this group at http://groups.google.com/group/rosbridge-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
thanks for your answer!
Maybe we will try to make use of the PNG compression to shrink our messages..
About the deserialization:
JSON-objects also make use of quotes.. as soon as a quote appears in the data field (no matter if it has outer quotes or not) deserialization fails again... at least what I have seen so far
I will try if it is possible to "double escape" brackets and quotes, so that the final JSON-parser will have a "valid" input string.
If not, we might need some replacement for these things.
David
Chad and Brandon, Thank you for answering and taking the time to write your explanations!
I will look into the code and try to work on those parts.. let's see ;)
Greetings,
David
I looked through your explanations and followed it through the source code..
Your explanations were very helpful to get some insight into the code base.
You mention the following:
"6. Let's assume the OP is "subscribe" since we're discussing fragmentation. Subscriber's subscribe function will be called with the parsed incoming message."
I think this is where we start talking into different directions.
I would have expected something like:
".. the OP is "fragment" since we're discussing fragmentation... "
;-)
I understand that it could be interesting to have rosbridge create fragments from huge messages by itself if a subscriber requests that.
But we (me and my boss ;) ) need just the "opposite". Meaning that we create the fragments manually and have rosbridge taking care of reconstruction and delivery into the ros-system.
So rosbridge would receive message fragments with the op-code "fragment", reconstruct the orginal message after receiving all fragments, and finally treating the reconstructed message just as if it had been sent directly to rosbridge..
We have a "standard" ROS-node subscribing to the topic of those huge messages and we want this node to receive just the original huge message.
For our purpose it should be sufficient if rosbridge can handle incoming fragments and "pass the reconstructed message to the ROS-system".
rosbridge is throwing errors on receiving messages with op-code "fragment".
This op-code should be registered with a function/handler that recombines the fragments and after that rosbridge will pass the reconstructed message to the appropriate OP handler.
I could not (yet) find any class or function that handles this part.
If there is not yet any code for this, I will start implementing a class that can do the following:
- gather fragments
- reconstruct original message
- call appropriate handler for original message (mostly "publish" I guess)
Did I get Fragmentation completely wrong and it's intention was (just) to be able to allow rosbridge clients to define a maximum message length for subscriptions?
After reading the "rosbridge protocol specification.pdf" I expected to use fragmentation just for both "directions"..
Greetings,
David