Skip to content

Conversation

@smoriemb
Copy link

@smoriemb smoriemb commented Jan 5, 2023

This pull request is to have mROS2 use the additional feature (fragmented data sending) added in the PR below.

mROS-base/embeddedRTPS#11

The main modification is in the function publish(). It checks if the message should be fragmented, and send with the proper mechanism.
The judgment is based on the message size, and the size is gotten by calcTotalSize() added to the mROS2 serializer. If the calculated size is larger than the size of buf, publish() calls the newly added interface newChangeCallback() of embeddedRTPS to send it as fragmented data. If not, it calls the existing newChange().
A function object is passed to newChangeCallback() that calls it to get fragmented data for each UDP frame. And, the function object shall return the pointer to the fragmented buffer and its size.

To implement this function object, I added some interfaces below to the mROS2 serializer.

  • copyToFragBuf()
    This method copies the serialized message to the given buffer and returns the type below.
    typedef std::pair<bool, uint32_t> FragCopyReturnType;
    The first is if there is any data serialized.
    The second is the serialized size.
  • getPubCnt()
    This method returns the serialized data size.
  • resetCount
    This method resets the counter of serialized data size

I also modify the existing serializer template and std_msgs to add the additional interfaces above. But, for the template, the implementation is insufficient, and we have to extend the generator to generate code for the fragmentation mechanism.
To demonstrato this new feature, I added a specific perpose message type sensor_msgs/msg/Image. But this type should be generated by the generator in the future.

Lastly, this pull request currently points a submodule (embeddedRTPS) in my repository. However, after we find this acceptable, I will modified it to the this repository's one.

@takasehideki
Copy link
Member

going to merge, along with mROS-base/embeddedRTPS#11 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants