micro-ROS / rmw_microxrcedds

RMW implementation using Micro XRCE-DDS middleware.
Apache License 2.0
35 stars 27 forks source link

How to serialize/deserialize message #307

Open styczen opened 5 months ago

styczen commented 5 months ago

Hi,

We are working on a solution which utilizes micro-ROS. Currently we do not want to use any publishers, subsribers etc. but only messages serialization and deserialization.

The idea is to serialize ROS 2 message e.g. std_msgs/msg/Float32 on the board, send it (but not using ROS 2 or micro-ROS) and deserialize on the other side using rclcpp::Serialization<T>.

I explored the codebase and found function which is responsible for publishing the data (rmw_publish).

There is the logic for something which resemble serialization but I could not figure out how to extract it and use as standalone function.

pablogs9 commented 5 months ago

Type support de/serialization in micro-ROS and ROS 2 is a kind of complex procedure that involves code generation. If you are familiar with it, take a look at the XRCE type support.

If not, a good idea would be to generate a micro-ROS environment so you can see the generated code and headers, for example using one of our modules: https://github.com/micro-ROS/rosidl_typesupport_microxrcedds/tree/iron/rosidl_typesupport_microxrcedds_c and then figure out of to extract the code generation procedure to match your requirements.

The micro-ROS type support works as the ROS 2 one, so the documentation is also valid: https://docs.ros.org/en/iron/Concepts/Advanced/About-Internal-Interfaces.html