[ros-users] [Discourse.ros.org] [Next Generation ROS] ROS2: anything equivalent to topic_tools:ShapeShifter?

William Woodall ros.discourse at gmail.com
Tue Dec 12 23:32:05 UTC 2017



Well, we're going to need to provide a function which can serialize and deserialize a `unint8_t[]` given an output structure. For example, with `sensor_msgs/Image.msg` it might be like:

```c++
unint8_t[] buffer = somehow_get_serialized_message_data();
sensor_msgs::msg::Image my_image;
deserialize_message<sensor_msgs::msg::Image>(buffer, my_image);
```

The implementation of this imagined `deserialize_message` function may end up calling an implementation specific function, or at the very least how it is deserialized should be an implementation detail.

But of course what you want is more like:

```c++
std::string sensor_msgs_image_definition = somehow_get_message_definition();
unint8_t[] buffer = somehow_get_serialized_message_data();
// some, as yet, imagined class...
auto message_object = MessageTypeIntrospector(sensor_msgs_image_definition, buffer);
assert(message_object.has_field("height") && message_object.field_is<uint32>("height"));
uint32  height = message_object.get_field<uint32>("height");
```

We have the beginnings of this in https://github.com/ros2/rosidl/tree/master/rosidl_typesupport_introspection_cpp, but I'm 100% certain how much is still needed to support this at the user level. We might not be able to use any of that package at the user level, since it isn't always used in the implementation, but it is at least representing the structure of a message as C++ structs and objects which is part of what we'd need to do. My initial guess is that we would need to have a way to generate the same typesupport structures but given an input string or structure which describes the type.

So I'd actually say we should try to avoid your package needing to reverse engineer how to deserialize, instead that should be provided by our abstraction layer. This allows us to protect the stuff that comes on top from underlying changes, e.g. if we changed from one version of CDR (the serialization standard used in DDS and ROS 2) to another.





---
[Visit Topic](https://discourse.ros.org/t/ros2-anything-equivalent-to-topic-tools-shapeshifter/3393/5) or reply to this email to respond.




More information about the ros-users mailing list