[ros-users] [Discourse.ros.org] [Next Generation ROS] Discussion about uint8[] type transport in ROS2 python

Sam Pfeiffer ros.discourse at gmail.com
Sat Apr 28 14:03:10 UTC 2018



Just a few suggestions on maybe how to deal with this:

Given this is kinda a... corner case, just by monkeypatching the method to use a converting method that's already prepared for the usecase:

    from sensor_msgs.msg import Image
    Image._CONVERT_TO_PY = Image._pre_compiled_conversion_functions.uint8_to_list
    node.create_subscription(Image, '/camera/whatever/image_raw', callback)

Of course, this implies generating the the thing I called `_pre_compiled_conversion_functions`. A better name would come up from the experts, I'm sure. Or there could be a function to just enable that in a more friendly way:

`Image.use_list_conversion()`

Or make an option to choose to use the old list way when instantiating a message that contains this specific problem.

    from sensor_msgs.msg import Image
    Image._CONVERT_TO_PY_MODE = Image._ROS1_COMPATIBILITY_MODE

Or generate two messages when a field of type uint8[] appears:

`from sensor_msgs.msg import Image, Image_ROS1`

Or even allow for every field the mode of conversion in a generic way (keeping the default the most efficient):

    from sensor_msgs.msg import Image
    Image.data.conversion_type = list
    Image.data.conversion_type = bytes

Well, just throwing some ideas around. The monkeypatching way, with maybe a good method name to make it more friendly is probably my favorite.





---
[Visit Topic](https://discourse.ros.org/t/discussion-about-uint8-type-transport-in-ros2-python/4633/2) or reply to this email to respond.




More information about the ros-users mailing list