Subscribe to message without deserializing large data structures

asked 2020-09-02 12:33:08 -0500

srubs_r gravatar image

I have a process where a high resolution image is captured (5MP). It is placed (as a 3 channel, non compressed sensor_msgs/msg/Image) in a large message structure that has empty fields for various metadata. This message is passed sequentially between a series of nodes that each populate some of the metadata fields.

Nodes written in C++ don’t have a very high overhead for this subscribing and publishing model, but Python nodes, on the other hand, easily max out a CPU core for such an operation.

From my understanding this extra CPU overhead is caused by the message having to be de-serialized into Python objects on subscription and re-serialized again on publishing. This is especially pronounced because of the large image array. This is mentioned in this issue.

Is there a method to de-serialize certain parts of a message (e.g. metadata string and integer values) whilst not de-serializing other parts (i.e. the large image array)?

I have tested in both the Eloquent and Foxy core Docker containers on an x86-64 platform running Ubuntu 18.04. Ultimately this would run on an arm-64 platform.

edit retag flag offensive close merge delete