Allow pointcloud create_cloud function to set specific point_step #223
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If I try to convert a pointcloud message to an array, and then use
create_cloud
to convert it back to a message, it will not work if there is padding at the end.The original lidar data is laid out like this (note the itemsize/padding):
{'names':['x','y','z','intensity','t','reflectivity','ring','ambient','range'], 'formats':['<f4','<f4','<f4','<f4','<u4','<u2','<u2','<u2','<u4'], 'offsets':[0,4,8,16,20,24,26,28,32], 'itemsize':48}
The current
create_cloud
will try to reconstruct the point layout from the field info withdtype_from_fields
, which in this case will take into account field padding, but not the padding at the end. It generates the following (again note the itemsize):{'names':['x','y','z','intensity','t','reflectivity','ring','ambient','range'], 'formats':['<f4','<f4','<f4','<f4','<u4','<u2','<u2','<u2','<u4'], 'offsets':[0,4,8,16,20,24,26,28,32], 'itemsize':36}
The mismatch in data layout will fail an assertion.
The
dtype_from_fields
function does allow for the point_step (itemsize) to be specficied explicitly when there is padding present at the end of the data, but there is currently no way to pass this in from thecreate_cloud
function.Fix adds an optional parameter to allow users to pass in a custom point_step, allowing the data to align properly.