Skip to content

[8] Add partial data typedefs

Igor Bogoslavskyi requested to merge 8-add-partial-typedefs into master

This MR allows to read partial data from the point cloud. Instead of lots of words, here is an example of how it works:

PointCloud2Modifier<PointXYZI> modifier{msg, "frame_id"};
modifier.push_back(create_point<PointXYZI>());
// Send this cloud somewhere and receive it elsewhere
PointCloud2PartialView<PointXYZ> view{msg};
PointXYZ point{view.front()};

This is implemented in the form of two new typedefs: PointCloud2PartialView and PointCloud2PartialModifier that allow for partial data access. The old typedefs are still intact. In order to implement this I had to extend the underlying class and introduce the new iterators that have to be used in case partial data reading is needed.

There are two downsides to this implementation:

  • The partial flavors are less secure. If the user does not provide the correct field generators there is nothing protecting the user from this error and some field will just silently not be filled.
  • This solution only supports data that is aligned in exactly the same way. So if the alignment of the XYZ data in the example above is different the partial view and modifier won't be able to access these data. So it is useful to read the start of some data struct when we know exactly how it starts but don't know and don't care what follows after the starting known data.

Closes #8

Edited by Igor Bogoslavskyi

Merge request reports