rosidl type support and new language
Context: trying to implement support for Ada.
I'm trying to understand how should I bridge the gap from .msg files to Ada data types. I've read this: http://docs.ros2.org/ardent/developer... (unfortunately the rosidl API is not available it seems) and checked relevant rosidl, typesupport packages, but the separation between source templates, generated files and installed headers is causing me some headaches.
Binding the C rcl is easy from Ada, and I already have that. I am able to retrieve an untyped message from a subscription, using the C rcl API and using the rosidl_message_type_support_t
as an opaque type. My main concern right now is if I'm barking the wrong tree, in regard to how data is serialized/deserialized. In the docs I read:
type support means: meta data or functions that are specific to a given type and that are used by the system to perform particular tasks for the given type. The type support for a given message might include things like a list of the names and types for each field in the message. It might also contain a reference to code that can perform particular tasks for that type, e.g. publish a message.
However, I'm failing at finding these functions, and am unsure if they're intended for client lib writers or for the RMW implementations. The *__functions.h
and *__type_support.h
seem obvious candidates but if I'm not mistaken they're more or less boilerplater-y for creation/destruction, and calling the appropriate typesupport macro.
So, in essence, I'm currently hitting a wall at the point of the macros that return a type support struct. I see that each rosidl_message_type_support_t
contains a void pointer, and a handler function rosidl_message_typesupport_handle_function
whose purpose I cannot ascertain.
Besides any general advice on this, one concrete question I have is: am I already at the point at which I have to interpret the raw bytes using the ROS-to-DDS equivalences of message fields, or should I use some C functions that I'm failing to understand to make things simpler? The former seems doable but quite some work that I'm not sure the other client libraries are doing, so I suspect I'm missing something.
Anyway, thanks for the patience and thanks for any help.
After spinning a bit more on all this, I think I might use the
<type>__struct.h
files in my own Ada generated files, and indeed the__functions.h
for allocations of dynamic sizes... But I'm unsure if this is the expected path. The C++ struct headers don't seem to rely on the C ones, for example.But the python ones do seem to follow this path
And after digging some more in the rclcpp I see that there are indeed the calls I was missing to rcl/rmw, so I guess the answer to my question is the second path of leveraging all the rosidl C generated header files. Would be nice if someone in the know could confirm though.
I'd recommend looking at the Python implementation. It's in a similar situation to you where it is using the C data structures but still generates Python objects for each msg type: https://github.com/ros2/rosidl/blob/m...
C++ indeed does not use the C data structures. Instead it generates its own structures and therefore its own typesupport for those structures. So those are the two ways you can approach it, Python reuses the C structs but wraps them in a new structure, but C++ defines both types and typesupport.
Thanks, @William. I have now seen the wrappers in Python and I'll try to do the same. I do not understand though how C++ can generate its own typesupport. Is this not bypassing rcl/rmw somehow? Are there any advantages in doing it that way? Ada is closer to C++ than Python and I'd like to understand