You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change Image (and other) messages to use byte[] rather than uint8[] #55
In the Image, CompressedImage, and PointCloud2 messages there are data fields that have type uint8[]. I suggest these are chaged to byte[].
Change description
According to the wiki, uint8 is interpreted as a python int, whereas byte is interpreted as a python byte. For the messages where arrays of uint8 are used, it's normally because the data is some arbitrary binary format. Currently, it seems that rclpy takes this binary data, copies it out into a list[int], which client code then normally converts back to some collection of byte types for use. This is much more processing and copying than is necessary.
This should also somewhat mitigate this issue, as no range check will be necessary.
Implementation consideration: evaluate how this plays with current ROS1 serialization of these messages and detail potential additional work to be able to keep bridging such messages over the ros1_bridge
@johnmarkwayve indeed. i should check what exactly would be the gain, now i was under the assumption that most time would be spent in traversing linked lists (i'll try to find out).
I was using the python bindings now to feed an image to a keras model, and while the keras model inference only takes 7msec, but the whole conversion from buffer to python linkedlist to buffer takes almost 40msec..
In the scope of ros2/design#190 the mapping of char[] is defined as bytes in Python. Once that change has been rolled out the image message will be changed to use that type instead of uint8[].
Activity
mikaelarguedas commentedon Aug 16, 2018
Implementation consideration: evaluate how this plays with current ROS1 serialization of these messages and detail potential additional work to be able to keep bridging such messages over the
ros1_bridgesloretz commentedon Aug 16, 2018
Related to ros2/rosidl#190
kervel commentedon Oct 4, 2018
Hello,
i think this would not be sufficient. even for byte[] the generated convert_to_py still creates a python List, see:
https://github.com/ros2/rosidl_python/blob/master/rosidl_generator_py/resource/_msg_support.c.em#L339
i tried to make a ByteImage (by copying Image and changing uint8 to byte) to get faster python IO but i still get a List in python..
i think bytes --> byte[] is only for conversion from python, not conversion to python..;
See also ros2/rosidl#276
Frank
kervel commentedon Oct 5, 2018
@johnmarkwayve indeed. i should check what exactly would be the gain, now i was under the assumption that most time would be spent in traversing linked lists (i'll try to find out).
I was using the python bindings now to feed an image to a keras model, and while the keras model inference only takes 7msec, but the whole conversion from buffer to python linkedlist to buffer takes almost 40msec..
Frank
dirk-thomas commentedon Oct 6, 2018
In the scope of ros2/design#190 the mapping of
char[]is defined asbytesin Python. Once that change has been rolled out the image message will be changed to use that type instead ofuint8[].